[英]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.