@Test public void smokeTest_sendAsynchron() { List<AsynchronMessageHandler> injectedAsynchronousHandlers = new ArrayList<>(); List<SynchronMessageHandler> injectedSynchronousHandlers = new ArrayList<>(); DomainMessageService service = new DomainMessageService(injectedSynchronousHandlers, injectedAsynchronousHandlers ); service.eventInspector=new DummyEventInspector(); DomainMessage request = new DomainMessage(MessageID.USER_REMOVED_FROM_PROJECT); service.sendAsynchron(request); }
public void sendAsynchron(DomainMessage request) { assertRequestNotNull(request); int inspectionId = eventInspector.createInspectionId(); eventInspector.inspectSendAsynchron(request, inspectionId); MessageID messageID = request.getMessageId(); List<AsynchronMessageHandler> handlersForThisMessageId = asynchronHandlers.get(messageID); if (handlersForThisMessageId == null || handlersForThisMessageId.isEmpty()) { LOG.error("Domain request with message id:{}, not handled by any asynchronous handler!", messageID); return; } for (AsynchronMessageHandler handler : handlersForThisMessageId) { taskExecutor.execute(new AsynchronMessageHandlerTaskAdapter(handler, inspectionId, request)); } }
DomainMessageService { public void sendAsynchron(DomainMessage request) { assertRequestNotNull(request); int inspectionId = eventInspector.createInspectionId(); eventInspector.inspectSendAsynchron(request, inspectionId); MessageID messageID = request.getMessageId(); List<AsynchronMessageHandler> handlersForThisMessageId = asynchronHandlers.get(messageID); if (handlersForThisMessageId == null || handlersForThisMessageId.isEmpty()) { LOG.error("Domain request with message id:{}, not handled by any asynchronous handler!", messageID); return; } for (AsynchronMessageHandler handler : handlersForThisMessageId) { taskExecutor.execute(new AsynchronMessageHandlerTaskAdapter(handler, inspectionId, request)); } } }
DomainMessageService { public void sendAsynchron(DomainMessage request) { assertRequestNotNull(request); int inspectionId = eventInspector.createInspectionId(); eventInspector.inspectSendAsynchron(request, inspectionId); MessageID messageID = request.getMessageId(); List<AsynchronMessageHandler> handlersForThisMessageId = asynchronHandlers.get(messageID); if (handlersForThisMessageId == null || handlersForThisMessageId.isEmpty()) { LOG.error("Domain request with message id:{}, not handled by any asynchronous handler!", messageID); return; } for (AsynchronMessageHandler handler : handlersForThisMessageId) { taskExecutor.execute(new AsynchronMessageHandlerTaskAdapter(handler, inspectionId, request)); } } @Autowired // does auto registration of synchron message handlers by spring  DomainMessageService(List<SynchronMessageHandler> injectedSynchronousHandlers, List<AsynchronMessageHandler> injectedAsynchronousHandlers); }
DomainMessageService { public void sendAsynchron(DomainMessage request) { assertRequestNotNull(request); int inspectionId = eventInspector.createInspectionId(); eventInspector.inspectSendAsynchron(request, inspectionId); MessageID messageID = request.getMessageId(); List<AsynchronMessageHandler> handlersForThisMessageId = asynchronHandlers.get(messageID); if (handlersForThisMessageId == null || handlersForThisMessageId.isEmpty()) { LOG.error("Domain request with message id:{}, not handled by any asynchronous handler!", messageID); return; } for (AsynchronMessageHandler handler : handlersForThisMessageId) { taskExecutor.execute(new AsynchronMessageHandlerTaskAdapter(handler, inspectionId, request)); } } @Autowired // does auto registration of synchron message handlers by spring  DomainMessageService(List<SynchronMessageHandler> injectedSynchronousHandlers, List<AsynchronMessageHandler> injectedAsynchronousHandlers); DomainMessageSynchronousResult sendSynchron(DomainMessage request); void sendAsynchron(DomainMessage request); }
DomainMessageService { public void sendAsynchron(DomainMessage request) { assertRequestNotNull(request); int inspectionId = eventInspector.createInspectionId(); eventInspector.inspectSendAsynchron(request, inspectionId); MessageID messageID = request.getMessageId(); List<AsynchronMessageHandler> handlersForThisMessageId = asynchronHandlers.get(messageID); if (handlersForThisMessageId == null || handlersForThisMessageId.isEmpty()) { LOG.error("Domain request with message id:{}, not handled by any asynchronous handler!", messageID); return; } for (AsynchronMessageHandler handler : handlersForThisMessageId) { taskExecutor.execute(new AsynchronMessageHandlerTaskAdapter(handler, inspectionId, request)); } } @Autowired // does auto registration of synchron message handlers by spring  DomainMessageService(List<SynchronMessageHandler> injectedSynchronousHandlers, List<AsynchronMessageHandler> injectedAsynchronousHandlers); DomainMessageSynchronousResult sendSynchron(DomainMessage request); void sendAsynchron(DomainMessage request);  }