How to Configure NATS publisher and subscriber

Hello all,

I am trying to configure NATS as the message broker in my application, but I don’t seem to find any documentation that can point me in the right direction i.e defining a queue, publishing events to that queue and subscribing events from the queue.
I am using Axon 3.0.5 and SpringBoot

I will appreciate any help given.


Hi Diane,

Without really knowing any specifics of NATS, I couldn’t help you with how to configure NATS.
Guessing though that it’s some form of amqp solution, I suggest having a look at the axon-amqp module.
That module contains a SpringAMQPPublisher and SpringAMQPMessageSource, which can be used to send and receive message from/to a queue.
The reference guide does have some specifics on this as well.

I’m not sure if this will help answer your question though, so if this doesn’t suffice, please ask for more help if required. :slight_smile:


Hi Steven,

Thanks a lot for your response.

It doesn’t really solve my problem. I have used the RabbitMQ as a message broker, and the spring configurations were ok, as spring makes provision for Rabbit.

But now I want to switch to NATS, but just can’t figure out how to do the configuration.

I will appreciate any further help.


Hi Diane,

it seems to me that the issue is more NATS related than Axon specific. The axon-amqp module shows how to do the connection on the Axon APIs. If course that module focuses on AMQP, but anything Spring AMQP does to connect to an AMQP broker, some NATS client will do that for NATS. How NATS clients work is a different matter. I haven’t worked with it before. I’m sure there must be some documentation of mailinglists around where they focus on it.



Thanks for the feedback Allard. I will find some good documentation on it