我想在Spring-JMS中实现一个带有activeMQ的解决方案,我想创建持久订阅主题。其目的是,如果用户关闭了一段时间的订阅,并再次使用相同的客户端ID和订阅名称重新创建durablesubscription,则订阅者应该收到订阅结束时的所有消息。Spring - ActiveMQ - 持久订阅 - 关闭连接并重新获得脱机消息
我想要实现在ORACLE网址为长期订阅提到以下逻辑:https://docs.oracle.com/cd/E19798-01/821-1841/bncgd/index.html
但我不能履行本使用弹簧JMS。根据URL,我需要获取messageConsumer实例并在该方法上调用close()来暂停从主题接收消息。但我不知道如何得到它。
以下是我的配置。请让我知道如何修改配置来执行此操作。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:userName="admin"
p:password="admin"
p:brokerURL="tcp://127.0.0.1:61616"
primary="true"
></bean>
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer" p:durableSubscriptionName="gxaa-durable1" p:clientId="gxaa-client1">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="adiTopic"/>
<property name="messageListener" ref="adiListener"/>
</bean>
<bean id="configTemplate" class="org.springframework.jms.core.JmsTemplate"
p:connectionFactory-ref="connectionFactory"
p:defaultDestination-ref="adiTopic" primary="true"
p:pubSubDomain="true">
</bean>
<bean id="adiTopic" class="org.apache.activemq.command.ActiveMQTopic" p:physicalName="gcaa.adi.topic"></bean>
<bean id="adiListener" class="com.gcaa.asset.manager.impl.AdiListener"></bean>
谢谢哈森。当jmsContainer重新启动时,它将消息传递给持久订阅。 – learner
我开始探索上述解决方案时有一个问题。我无法从使用上述解决方案的持久订阅中完全取消订阅。 – learner
我已经更新了我的答案 –