Hello,
can somebody please point me to documentation or show me some example how to properly configure axon to publish messages to rabbit?
I was searching the forum and found this thread https://groups.google.com/forum/#!searchin/axonframework/rabbitmq|sort:date/axonframework/7c-k-U7tQtc/8OWjyvq5AgAJ but the configuration seems to be from older releases of axon. I need configuration with exchange creation.
When I want to consume events from rabbit I can configure something like this:
@Bean
public SpringAMQPMessageSource objectTypeEventsSource(Serializer serializer) {
return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)) {
@RabbitListener(queues = "objectTypeLocalizationQueue")
@Override
public void onMessage(Message message, Channel channel) throws Exception {
super.onMessage(message, channel);
}
};
}
Do I need also create bindings for this e.g something like bellow or will axon autoconfigure that for me if I supply property axon.amqp.exchange?:
@Bean
public Queue queue() {
return QueueBuilder.durable("objectTypeLocalizationQueue").build();
}
@Bean
public Exchange exchange() {
return ExchangeBuilder.fanoutExchange("axon.events.exchange").durable(true).build();
}
@Bean
public Binding binding() {
return BindingBuilder.bind(queue()).to(exchange());
}
@Autowired
public void configure(AmqpAdmin admin) {
admin.declareQueue(queue());
admin.declareExchange(exchange());
admin.declareBinding(binding());
}
Also how are you guys configuring the exchanges when you have multiple distributed processors of same type (separate microservices) and the same database (with same schema -> I know that this is not good from microservices point of view, but …) I don’t want to have one message to be consumed by all processor of same type.
When I publish message to rabbit does it mean that my “local” event handlers are consuming messages from rabbit or my local listeners still consume messages from “local event bus”?
I’m just trying to understand how to configure rabbit for multiple microservices. If somebody can share some good stuff where to learn more about configuring exchanges/queues it would be very helpful.