99import org .springframework .beans .factory .annotation .Value ;
1010import org .springframework .context .annotation .Bean ;
1111import org .springframework .context .annotation .Configuration ;
12+ import org .springframework .context .annotation .Primary ;
1213
1314@ Configuration
1415public class RabbitMQConfig {
@@ -26,27 +27,28 @@ public RabbitMQConfig(ConnectionFactory connectionFactory) {
2627 }
2728
2829 @ Bean
29- public Queue notificationQueue () {
30+ Queue notificationQueue () {
3031 return new Queue (this .notificationQueue );
3132 }
3233
3334 @ Bean
34- public TopicExchange internalExchange () {
35+ TopicExchange internalExchange () {
3536 return new TopicExchange (this .internalExchange );
3637 }
3738
3839 // bind queue to exchange with routing key
3940 @ Bean
40- public Binding binding () {
41+ Binding binding () {
4142 return BindingBuilder
4243 .bind (notificationQueue ())
4344 .to (internalExchange ())
4445 .with (this .internalNotificationRoutingKey );
4546 }
4647
4748 // Configure amqp template that allows to send messages
49+ @ Primary
4850 @ Bean
49- public AmqpTemplate amqpTemplate () {
51+ AmqpTemplate amqpTemplate () {
5052 RabbitTemplate rabbitTemplate = new RabbitTemplate (connectionFactory );
5153 rabbitTemplate .setMessageConverter (jacksonConverter ());
5254 return rabbitTemplate ;
@@ -55,7 +57,7 @@ public AmqpTemplate amqpTemplate() {
5557 //Build the rabbit listener container & connect to RabbitMQ broker to listener message
5658 // that allows to consume messages from queues (listener)
5759 @ Bean
58- public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory () {
60+ SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory () {
5961 SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory ();
6062 factory .setConnectionFactory (connectionFactory );
6163 factory .setMessageConverter (jacksonConverter ());
@@ -64,7 +66,7 @@ public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory
6466
6567 // Jackson2JsonMessageConverter is used to convert messages to JSON format
6668 @ Bean
67- public MessageConverter jacksonConverter () {
69+ MessageConverter jacksonConverter () {
6870 MessageConverter jackson2JsonMessageConverter = new Jackson2JsonMessageConverter ();
6971 return jackson2JsonMessageConverter ;
7072 }
0 commit comments