commandGateway = DefaultCommandGateway.builder() .commandBus(commandBus) .retryScheduler(retryScheduler) .dispatchInterceptors((MessageDispatchInterceptor<CommandMessage<?>>) messages -> (index, message) -> { if (Thread.currentThread() == testThread) { return message.andMetaData( }).build();
/** * Instantiate a Builder to be able to create a {@link DefaultCommandGateway}. * <p> * The {@code dispatchInterceptors} are defaulted to an empty list. * The {@link CommandBus} is a <b>hard requirements</b> and as such should be provided. * * @return a Builder to be able to create a {@link DefaultCommandGateway} */ public static Builder builder() { return new Builder(); }
@ConditionalOnMissingBean @Bean public CommandGateway commandGateway(CommandBus commandBus) { return DefaultCommandGateway.builder().commandBus(commandBus).build(); }
/** * Returns a {@link DefaultCommandGateway} that will use the configuration's {@link CommandBus} to dispatch * commands. * * @param config The configuration that supplies the command bus. * @return The default command gateway. */ protected CommandGateway defaultCommandGateway(Configuration config) { return DefaultCommandGateway.builder().commandBus(config.commandBus()).build(); }
public void testCommandDispatchInterceptorExceptionOnRetryThreadIsThrownToCaller() { commandGateway = DefaultCommandGateway.builder() .commandBus(commandBus) .retryScheduler(retryScheduler) .build();
final Thread testThread = Thread.currentThread(); commandGateway = DefaultCommandGateway.builder() .commandBus(commandBus) .retryScheduler(retryScheduler) .build();
/** * Creates an instance of the AnnotatedSagaTestFixture to test sagas of the given {@code sagaType}. * * @param sagaType The type of saga under test */ @SuppressWarnings({"unchecked"}) public SagaTestFixture(Class<T> sagaType) { this.sagaType = sagaType; eventScheduler = new StubEventScheduler(); deadlineManager = new StubDeadlineManager(); eventBus = SimpleEventBus.builder().build(); sagaStore = new InMemorySagaStore(); registeredResources.add(eventBus); commandBus = new RecordingCommandBus(); registeredResources.add(commandBus); registeredResources.add(eventScheduler); registeredResources.add(deadlineManager); registeredResources.add(DefaultCommandGateway.builder().commandBus(commandBus).build()); fixtureExecutionResult = new FixtureExecutionResultImpl<>(sagaStore, eventScheduler, deadlineManager, eventBus, commandBus, sagaType, fieldFilters); handlerDefinition = ClasspathHandlerDefinition.forClass(sagaType); }
@SuppressWarnings("unchecked") @Before public void setUp() { eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); Repository<MyAggregate> myAggregateRepository = EventSourcingRepository.builder(MyAggregate.class) .eventStore(eventStore) .build(); CommandBus commandBus = SimpleCommandBus.builder().build(); commandGateway = DefaultCommandGateway.builder().commandBus(commandBus).build(); AggregateAnnotationCommandHandler<MyAggregate> myAggregateCommandHandler = AggregateAnnotationCommandHandler.<MyAggregate>builder() .aggregateType(MyAggregate.class) .repository(myAggregateRepository) .build(); myAggregateCommandHandler.subscribe(commandBus); }
@ConditionalOnMissingBean @Bean public CommandGateway commandGateway(CommandBus commandBus) { return DefaultCommandGateway.builder().commandBus(commandBus).build(); }
/** * Returns the CommandGateway used to send commands to command handlers. * * @param commandBus the command bus to be used by the gateway * @return the CommandGateway used to send commands to command handlers */ @NoBeanOfType(CommandGateway.class) @Bean public CommandGateway commandGateway(CommandBus commandBus) { return DefaultCommandGateway.builder().commandBus(commandBus).build(); }
/** * Instantiate a Builder to be able to create a {@link DefaultCommandGateway}. * <p> * The {@code dispatchInterceptors} are defaulted to an empty list. * The {@link CommandBus} is a <b>hard requirements</b> and as such should be provided. * * @return a Builder to be able to create a {@link DefaultCommandGateway} */ public static Builder builder() { return new Builder(); }
/** * Returns a {@link DefaultCommandGateway} that will use the configuration's {@link CommandBus} to dispatch * commands. * * @param config The configuration that supplies the command bus. * @return The default command gateway. */ protected CommandGateway defaultCommandGateway(Configuration config) { return DefaultCommandGateway.builder().commandBus(config.commandBus()).build(); }