我编写了spring AMQP生成器示例,它运行在RabbitMQ服务器上,它使用Spring amqp通过MessageListener发送消息和消费这些消息。在这里,我想将队列和消息持久性设置为false。你能不能请任何人帮助我如何设置“耐久”标志为假使用注释。
以下是示例代码
@Configuration
public class ProducerConfiguration {
protected final String queueName = "hello.queue";
@Bean
public RabbitTemplate rabbit
我创建了一个带有消息过期args的队列,但在启动服务器时得到了以下错误。
[SimpleAsyncTaskExecutor-1] o.s.a.r.c.RabbitAdmin [RabbitAdmin.java:375] Auto-declaring a non-durable Queue (TEST_QUEUE). It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
pool-1-threa
我有一个有3个节点的兔集群。一个节点有一个持久的、非镜像的经典队列,名为test-queue。
我有一个使用spring默认连接工厂new CachingConnectionFactory()的spring引导应用程序,它首先确保队列存在,然后订阅它的消息。一切都很好
然后,我开始了对rabbitmq集群的滚动更新,在该集群中,节点被一个接一个地重新启动。
在此过程中,我从日志中观察到:
一开始,我看到输出低于
Received shutdown signal for consumer tag=amq.ctag-pzPHM_GEd5e-J5Y_L2W7_g com.rabbitmq.clien
我有一个发布者正在发布关于主题的消息,我有2个订阅者S1 & S2正在接收这些消息。当我的发布者发送一条消息,并且两个订阅者都在运行时,他们都会收到该消息。但是,当我的订阅服务器没有启动,而我的发布者发送消息时,当订阅服务器出现时,它们就不会收到消息。我的订阅服务器如何接收未运行的消息?
注意:我正在使用Spring。
MessageProducer.java
@RestController
@RequestMapping("/rest/produce")
public class MessageProducer {
private static final L
下面是一个小型Spring程序,预期它会将一条消息插入到rabbitmq队列中:
public class Main {
public static void main(String [] args) throws IOException {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(QueueConfiguration.class);
AmqpTemplate template = context.getBean(AmqpTemplate.clas