I have an easy example of spring boot 1.5.22 + amqp and the problem is that queue is not getting created dynamically, and it should.
@Component
class ReceiverComponent {
@RabbitListener(queues = 'spring-boot-queue-2')
public void receive_2(String content) {
System.out.println("[ReceiveMsg-2] receive msg: " + content);
}
@Component
class SenderComponent {
@Autowired
private AmqpAdmin amqpAdmin;
// The default implementation of this interface is RabbitTemplate, which
currently has only one implementation.
@Autowired
private AmqpTemplate amqpTemplate;
/**
* send message
*
* @param msgContent
*/
public void send_2(String msgContent) {
amqpTemplate.convertAndSend(RabbitConfig.SPRING_BOOT_EXCHANGE,
RabbitConfig.SPRING_BOOT_BIND_KEY, msgContent);
}
@Configuration
class RabbitConfig {
// Queue name
public final static String SPRING_BOOT_QUEUE = "spring-boot-queue-2";
// Switch name
public final static String SPRING_BOOT_EXCHANGE = "spring-boot-exchange-
2";
// Bound values
public static final String SPRING_BOOT_BIND_KEY = "spring-boot-bind-key-
2";
}
The error i'm getting is :
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'spring-boot-queue-2' in vhost '/', class-id=50, method-id=10)
Does it has to do something with right on the rabbitmq ? The version installed is 3.7.13 and my coonection data is :
spring:
# Configure rabbitMQspring:
rabbitmq:
host: 127.0.0.1
port: 5672
username: guest
password: guest