use of io.spine.server.commandbus.CommandBus in project core-java by SpineEventEngine.
the class ProcessManagerRepository method findOrCreate.
/**
* Loads or creates a process manager by the passed ID.
*
* <p>The process manager is created if there was no manager with such an ID stored before.
*
* <p>The repository injects {@code CommandBus} from its {@code BoundedContext} into the
* instance of the process manager so that it can post commands if needed.
*
* @param id the ID of the process manager to load
* @return loaded or created process manager instance
*/
@Override
@CheckReturnValue
protected P findOrCreate(I id) {
final P result = super.findOrCreate(id);
final CommandBus commandBus = getBoundedContext().getCommandBus();
result.setCommandBus(commandBus);
return result;
}
use of io.spine.server.commandbus.CommandBus in project core-java by SpineEventEngine.
the class CommandService method post.
@SuppressWarnings("MethodDoesntCallSuperMethod")
// as we override default implementation with `unimplemented` status.
@Override
public void post(Command request, StreamObserver<Ack> responseObserver) {
final CommandClass commandClass = CommandClass.of(request);
final BoundedContext boundedContext = boundedContextMap.get(commandClass);
if (boundedContext == null) {
handleUnsupported(request, responseObserver);
} else {
final CommandBus commandBus = boundedContext.getCommandBus();
commandBus.post(request, responseObserver);
}
}
use of io.spine.server.commandbus.CommandBus in project core-java by SpineEventEngine.
the class MultiTenantCommandBusShould method allow_to_specify_failure_bus_via_builder.
@Test
public void allow_to_specify_failure_bus_via_builder() {
final FailureBus expectedFailureBus = mock(FailureBus.class);
final CommandBus commandBus = CommandBus.newBuilder().setCommandStore(commandStore).setFailureBus(expectedFailureBus).build();
assertNotNull(commandBus);
final FailureBus actualFailureBus = commandBus.failureBus();
assertEquals(expectedFailureBus, actualFailureBus);
}
use of io.spine.server.commandbus.CommandBus in project core-java by SpineEventEngine.
the class CommandService method post.
@SuppressWarnings("MethodDoesntCallSuperMethod")
// as we override default implementation with `unimplemented` status.
@Override
public void post(Command request, StreamObserver<Response> responseObserver) {
final CommandClass commandClass = CommandClass.of(request);
final BoundedContext boundedContext = boundedContextMap.get(commandClass);
if (boundedContext == null) {
handleUnsupported(request, responseObserver);
} else {
final CommandBus commandBus = boundedContext.getCommandBus();
commandBus.post(request, responseObserver);
}
}
use of io.spine.server.commandbus.CommandBus in project core-java by SpineEventEngine.
the class MultiTenantCommandBusShould method have_failure_bus_if_no_custom_set.
@Test
public void have_failure_bus_if_no_custom_set() {
final CommandBus bus = CommandBus.newBuilder().setCommandStore(commandStore).build();
assertNotNull(bus.failureBus());
}
Aggregations