0

I am new to Spring AMQP and want to use annotation based configuration for both producers and consumers using latest spring amqp 1.5.4 ,

Is there any pseoudo code available for configuration which does the logic for creating connection or @Queue etc.

Akshat
  • 575
  • 2
  • 12
  • 28

2 Answers2

1

Probably the quickest way to get started would be use Spring Boot - boot will create all the beans you need (connecting to localhost by default but easily overridable with properties).

You can also look at some of the Spring AMQP test cases.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
0

Have a class annotated with @Configuration in Spring Boot which can provide you with annotation based bean definition : Here is a sample :

@Configuration
public class QueueConfig {

@Bean
    public AmqpAdmin amqpAdmin() {
        return new RabbitAdmin(connectionFactory());
    }
@Bean
    public RabbitTemplate rabbitTemplate() {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());
        rabbitTemplate.setExchange("myQueue");
        return rabbitTemplate;
    }

@Bean
    Queue rabbitQueue() {
        return new Queue(WORKERS_QUEUE_NAME, true, false, false, null);
    }
}
javadev
  • 1,639
  • 2
  • 17
  • 35