0
votes

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.

2

2 Answers

1
votes

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.

0
votes

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);
    }
}