简体   繁体   English

如何使用Java Spring Boot应用程序制作持久性JMS消息?

[英]how to make persistent JMS messages with java spring boot application?

I am trying to make a queue with activemq and spring boot using this link and it looks fine. 我正在尝试使用此链接使用activemq和spring boot进行排队,看起来不错。 What I am unable to do is to make this queue persistent after application goes down. 我无法做的是在应用程序关闭后使此队列持久化。 I think that SimpleJmsListenerContainerFactory should be durable to achieve that but when I set factory.setSubscriptionDurable(true) and factory.setClientId("someid") I am unable to receive messages any more. 我认为SimpleJmsListenerContainerFactory应该可以持久实现这一目标,但是当我设置factory.setSubscriptionDurable(true)factory.setClientId("someid")我将无法再接收消息。 I would be greatfull for any suggestions. 如果有任何建议,我将不胜感激。

I guess you are embedding the broker in your application. 我猜您是在应用程序中嵌入了代理。 While this is ok for integration tests and proof of concepts, you should consider having a broker somewhere in your infrastructure and connect to it. 尽管可以进行集成测试和概念验证,但您应该考虑在基础结构中的某个位置放置一个代理并将其连接。 If you choose that, refer to the ActiveMQ documentation and you should be fine. 如果选择该选项,请参考ActiveMQ文档,应该可以。

If you insist on embedding it, you need to provide a brokerUrl that enables message persistence . 如果您坚持要嵌入它,则需要提供一个启用消息持久性的brokerUrl

Having said that, it looks like you misunderstand durable subscriber and message persistence. 话虽如此,您似乎误解了持久的订户和消息持久性。 The latter can be achieved by having a broker that actually stores the content of the queue somewhere so that if the broker is stopped and restarted, it can restore the content of its queue. 后者可以通过使代理实际将队列的内容存储在某个位置来实现,这样,如果代理停止并重新启动,它就可以恢复其队列的内容。 The former is to be able to receive a message even if the listener is not active at a period of time. 前者即使在一段时间内未处于活动状态,也能够接收消息。

you can enable persistence of messages using ActiveMQConnectionFactory. 您可以使用ActiveMQConnectionFactory启用消息的持久性。

as mentioned in the spring boot link you provided, this ActiveMQConnectionFactory gets created automatically by spring boot.so you can have this bean in your application configuration created manually and you can set various property as well. 如您提供的spring boot链接中所述,此ActiveMQConnectionFactory由spring boot自动创建。因此,您可以在应用程序配置中手动创建此bean,还可以设置各种属性。

    ActiveMQConnectionFactory cf = new   ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");

Here is the link http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html 这是链接http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot JMS应用程序的单元测试将消息留在队列中 - Unit Test of Spring Boot JMS Application Leaves Messages on Queue 如何确保JMS队列将消息保留在持久性存储中而不是堆中? - How to make sure that JMS queue keep messages in a persistent storage rather than heap? 如何创建单独的 JMS 消费者和发布者 spring 引导应用程序? - How to create separate JMS consumer and publisher spring boot application? 如何通过Spring JMS在两个Java应用程序之间交换消息? - how to exchange messages between two java applications via Spring JMS? 如何在Spring中过滤JMS消息 - How to filter jms messages in spring 如何使用 Spring JMS 使用来自 websphere 应用程序服务器的 JMS 消息 - How to consume JMS messages from the websphere application server using Spring JMS 如何通过 Spring 引导 web 应用程序创建到 Kafka 的持久连接 - How to create a persistent connection to Kafka through Spring Boot web application 尝试使用 Java (JMS) 中的选择器在 Tibco EMS 上使用持久消息时遇到问题 - Trouble trying to consume persistent messages on Tibco EMS with selectors in Java (JMS) 如何使用 spring 引导 java 应用程序从服务总线队列中持续拉取消息 - How to continuously pull messages from service bus queue by using spring boot java application 如何使用 spring boot 连续接收来自 IBM MQ JMS 的消息? - How to receive messages from IBM MQ JMS using spring boot continuously?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM