0

I have 2 different microservices todo-service and validation-service and command types CreateTodoCommand and ValidateTodoCommand.

If I have one command handler in one service and another one in the second service I receive No node known to accept exception on sending a command that the service is not aware of.

Can I split my @CommandHandlers to have them in different services?

Stepan
  • 41
  • 2
  • 7
  • It should be ok to have them in a separate service. From domain boundary perspective, the validation-service should only do validatePayload(rawInput) and pass the validated value to the Todo-Service as CreateTodoCmd(validatedPayload) – Rjk Jun 16 '18 at 05:37

1 Answers1

1

Yes, that's definitely possible @Stephan. Assuming you're in a Spring Boot environment, the only thing you have to do is set the right dependency for the type of DistributedCommandBus you want (thus SpringCloud or JGroups) and set the axon.distributed.enabled property to true.

The framework will automatically search for all the @CommandHandler annotated functions. If your application still states it cannot find 'a node to expect the command', then something fails during the wiring process.

Or simpler put, I can think of two reasons: 1) Your @CommandHandler annotated functions aren't registered to the DistributedCommandBus. 2) The message-handling information isn't shared between your nodes.

Any how, the simple answer to your question is: yes, you can have your @CommandHandler annotated functions in different services.

Why it isn't working though, is something different.

Steven
  • 6,936
  • 1
  • 16
  • 31
  • I wonder if you have a code sample for `DistributedCommandBus` somewhere on github? – Stepan Jun 19 '18 at 11:41
  • I don't have one openly available, but like I pointed out, setting up should be very simple in a Spring Boot environment. So to help you further with this: Are you using Spring Boot? – Steven Jun 21 '18 at 06:24