Dispatch Command from app1 and handle it from app2 on the same JVM

Hi everyone,

I’ve built a spring mvc web app as a test where I’m dispatching a CreateUserCommand and handling it successfully in the same application.

Now I’ve divided the app into 2 separate applications where I’m dispatching the command form app1 and handling it in app2.

However, app2 isn’t handling the command. I suppose there is a missing configuration to tie the two apps together.

Do I need a distributed command bus? the 2 apps are on the same machine and are deployed to tomcat.

The only configuration I added to both applications is:

<axon:annotation-config />

<axon:command-bus id=“commandBus” transaction-manager=“transactionManager”/>

It seems that I indeed need to use a distributed command bus and the documentation mentions that##
could be used, however; I don’t see how it should be added to my applications.Help anyone?! :slight_smile:

Check out the quickstart samples (https://github.com/AxonFramework/AxonFramework/tree/master/quickstart/src/main/java/org/axonframework/quickstart). there is a DistributedCommandBus runner there that shows how it can be done.



Thanks Allard for the link. Since I’m using spring MVC with no main() method, where should this piece of code go?

  // Start the GossipRouter if it is not already running
        GossipRouter gossipRouter = new GossipRouter();
        try {
        } catch (BindException e) {
            System.out.println("Gossip router is already started in another JVM instance.");

**I'm kinda new to spring, so I'm not sure how to proceed since I'm wiring everything via XML.**


the gossip router is a component you can use for nodes to detect eachother. JGroups allows several ways, such as Multicast Discovery, Unicast (where you need to supply a list of potential members) and Gossip. The latter requires you to start a Gossip router on a machine, and tell the other machines where this GossipRouter is running. When your GossipRouter is down, nodes won’t be able to join, but nodes that have already joined will be able to continue working.

In the sample, I run the GossipRouter as part of the sample. In you case, you would just need to run GossipRouter.main() to run it with default settings.




it seems that the nodes aren’t connected to eachother. Are you sure both nodes connect to the same GossipRouter instance? If the nodes detect eachother, you should be able to see that in the logs (on info level, if I recall correctly). When nodes fail to connect, that should also be visible.
What do you see in you log files?



Thanks Allard for the reply. I just updated all jars and everything seems to work now .

Crazy dependencies I guess :smiley: