You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Hassen Bennour <be...@gmail.com> on 2016/09/03 11:26:04 UTC
Re: Durable subscriber
Crishel,
When i seen Tim mail i verified our last exchange and seen that it was not
via the AMQ users group because I reply automatically.
We are here to share our knowledge and helps each other.
I reply to the group to let Tim understanding better the problem and
gaining time because I do not understood where is your problem because I
tested all the configs and client and as i said for me everything works as
expected and messages are persisted after restart for the durable
subscriber.
Le 2 sept. 2016 10:23, "Crishel Yumul" <cr...@toro.io> a écrit :
>
> Maybe your client was configured also to have a persistent message
delivery?
>
>> On Sep 2, 2016, at 4:02 PM, Hassen Bennour <be...@gmail.com>
wrote:
>>
>> default delivery mode in JMS is PERSISTENT and this is the default one
used by AMQ client.
>> if at the AMQ broker level persistence is not disabled , because it is
enabled by default, messages will be persisted
>>
>>
>>
>> Kind regards.
>>
>> BENNOUR HASSEN
>>
>> SOA Architect / Java Software Engineer
>>
>> 2016-09-02 7:01 GMT+02:00 Crishel Yumul <cr...@toro.io>:
>>>
>>> Should it be configured on my app to send persistent messages instead
of my broker setting itself?
>>>
>>>> On Sep 2, 2016, at 7:55 AM, Crishel Yumul <cr...@toro.io>
wrote:
>>>>
>>>> Really??!? Have you checked the subscribers tab on your web console
whether you user is durable or non? Mine’s persisting only the topics but
the messages are gone :(
>>>>>
>>>>> On Sep 1, 2016, at 5:30 PM, Hassen Bennour <be...@gmail.com>
wrote:
>>>>>
>>>>> how did you deduced that it does not work ?
>>>>> i tried with your exact config with a durable subscriber and their
message are persisted and dispatched after broker restart
>>>>>
>>>>>
>>>>>
>>>>> Kind regards.
>>>>>
>>>>> BENNOUR HASSEN
>>>>>
>>>>> SOA Architect / Java Software Engineer
>>>>>
>>>>> 2016-09-01 10:49 GMT+02:00 Crishel Yumul <cr...@toro.io>:
>>>>>>
>>>>>> Still no effect. Here’s my broker xml. Don’t you think this have
something to do with the users being a durable subscribers?
>>>>>>
>>>>>> ———>
>>>>>>
>>>>>> <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="demo-activemq" dataDirectory="${activemq.data}" useJmx="true"
advisorySupport="true" persistent="true" deleteAllMessagesOnStartup="false"
useShutdownHook="false" schedulerSupport="true" start="false">
>>>>>>
>>>>>>
>>>>>>
>>>>>> <destinationPolicy>
>>>>>> <policyMap>
>>>>>> <policyEntries>
>>>>>> <policyEntry topic=">"
>>>>>> producerFlowControl="false"
>>>>>> gcInactiveDestinations="true"
>>>>>> inactiveTimoutBeforeGC="500"
>>>>>> memoryLimit="5mb"
>>>>>> expireMessagesPeriod=“0"
>>>>>> advisoryWhenFull="true"
>>>>>> maxDestinations=“-1"
>>>>>> persistJMSRedelivered="true"
>>>>>> sendAdvisoryIfNoConsumers="true">
>>>>>>
>>>>>> <pendingMessageLimitStrategy>
>>>>>> <constantPendingMessageLimitStrategy
limit="20"/> <!-- 20 seconds worth -->
>>>>>> </pendingMessageLimitStrategy>
>>>>>>
>>>>>> <dispatchPolicy>
>>>>>> <strictOrderDispatchPolicy />
>>>>>> </dispatchPolicy>
>>>>>>
>>>>>> <subscriptionRecoveryPolicy>
>>>>>> <timedSubscriptionRecoveryPolicy
recoverDuration="60000" /> <!-- 1 minutes worth -->
>>>>>> </subscriptionRecoveryPolicy>
>>>>>>
>>>>>> </policyEntry>
>>>>>> <policyEntry tempTopic="true"
advisoryForConsumed="true" />
>>>>>> </policyEntries>
>>>>>> </policyMap>
>>>>>> </destinationPolicy>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <managementContext>
>>>>>> <managementContext createConnector="true"
rmiServerPort="1098" connectorPort="1099"/>
>>>>>> </managementContext>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <plugins>
>>>>>> <!--Configure authentication; Username, passwords and
groups -->
>>>>>> <runtimeConfigurationPlugin checkPeriod="1000" />
>>>>>> <jaasAuthenticationPlugin
configuration="activemq-domain" />
>>>>>>
>>>>>> <authorizationPlugin>
>>>>>> <map>
>>>>>> <authorizationMap>
>>>>>> <authorizationEntries>
>>>>>> <authorizationEntry
topic=“some.topic.>" read=“some1,some2,some3,admin"
write="some1,some2,some3,admin" admin="some1,some2,some3,admin" />
>>>>>> <authorizationEntry
topic="ActiveMQ.Advisory.>"
>>>>>>
read="saas-admin,some2,some1,some3,username"
>>>>>>
write="saas-admin,some2,some1,some3,username"
>>>>>>
admin="saas-admin,some2,some1,some3,username"/>
>>>>>> </authorizationEntries>
>>>>>> </authorizationMap>
>>>>>> </map>
>>>>>> </authorizationPlugin>
>>>>>>
>>>>>> </plugins>
>>>>>>
>>>>>>
>>>>>> <persistenceAdapter>
>>>>>> <!-- <kahaDB directory="${activemq.data}/kahadb"
indexWriteBatchSize="1000" enableIndexWriteAsync="true"/> -->
>>>>>> <kahaDB
directory="/Users/crishel.yumul/Documents/dataStore"
>>>>>> indexWriteBatchSize="1000"
>>>>>> enableIndexWriteAsync="true"
>>>>>> concurrentStoreAndDispatchTopics="true"
>>>>>> />
>>>>>> </persistenceAdapter>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <systemUsage>
>>>>>> <systemUsage>
>>>>>> <memoryUsage>
>>>>>> <memoryUsage percentOfJvmHeap="70"/>
>>>>>> </memoryUsage>
>>>>>> <storeUsage>
>>>>>> <storeUsage limit="2 gb"/>
>>>>>> </storeUsage>
>>>>>> <tempUsage>
>>>>>> <tempUsage limit="1 gb"/>
>>>>>> </tempUsage>
>>>>>> </systemUsage>
>>>>>> </systemUsage>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <!--
>>>>>> The transport connectors expose ActiveMQ over a given
protocol to
>>>>>> clients and other brokers. For more information, see:
>>>>>>
>>>>>> http://activemq.apache.org/configuring-transports.html
>>>>>> -->
>>>>>> <transportConnectors>
>>>>>> <transportConnector name="openwire" uri="tcp://
0.0.0.0:61616?maximumConnections=1000&wireformat.maxFrameSize=104857600
<http://0.0.0.0:61616?maximumConnections=1000&wireformat.maxFrameSize=104857600>
"/>
>>>>>> <transportConnector name="amqp" uri="amqp://
0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600
<http://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600>
"/>
>>>>>> </transportConnectors>
>>>>>>
>>>>>> <!-- destroy the spring context on shutdown to stop jetty -->
>>>>>>
>>>>>>
>>>>>> <shutdownHooks>
>>>>>> <bean xmlns="http://www.springframework.org/schema/beans"
class="org.apache.activemq.hooks.SpringContextHook" />
>>>>>> </shutdownHooks>
>>>>>>
>>>>>> </broker>
>>>>>>
>>>>>>
>>>>>> <import resource="jetty.xml"/>
>>>>>>
>>>>>>
>>>>>>
>>>>>> </beans>
>>>>>>
>>>>>> ———>
>>>>>> thanks
>>>>>>
>>>>>>
>>>>>>> On Sep 1, 2016, at 4:44 PM, Hassen Bennour <be...@gmail.com>
wrote:
>>>>>>>
>>>>>>> Simply http://activemq.apache.org/persistence.html
>>>>>>>
>>>>>>> Configuring Kaha Persistence
>>>>>>> In the broker XML specify the persistence adaptor to be Kaha e.g.
>>>>>>> ActiveMQ 5.0 and above:
>>>>>>> <broker brokerName="broker" persistent="true"
useShutdownHook="false">
>>>>>>> <persistenceAdapter>
>>>>>>> <kahaPersistenceAdapter directory="activemq-data"
maxDataFileLength="33554432"/>
>>>>>>> </persistenceAdapter>
>>>>>>> </broker>
>>>>>>>
>>>>>>> Le 1 sept. 2016 01:46, "Crishel Yumul" <cr...@toro.io> a
écrit :
>>>>>>>>
>>>>>>>> I want my messages on every topics will be retain in case of
broker failure or restart.
>>>>>>>>
>>>>>>>>> On Aug 31, 2016, at 5:41 PM, Hassen Bennour <
bennour.hassen@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>> Can you explain more ?
>>>>>>>>>
>>>>>>>>> Le 31 août 2016 10:47, "Crishel Yumul" <cr...@toro.io> a
écrit :
>>>>>>>>>>
>>>>>>>>>> Yass’s! Thanks. One last question..
>>>>>>>>>> Is there anyway the messages will retain even if the master
broker stopped and the slave will be up?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>>
>>>>>>>>>>> On Aug 31, 2016, at 4:44 PM, Hassen Bennour <
bennour.hassen@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Ok this is a good example but i thnik you need to work with
your developers is better to know how to configure another powerful things
of AMQ client
>>>>>>>>>>>
>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>>> xsi:schemaLocation="
http://www.springframework.org/schema/beans
>>>>>>>>>>>
http://www.springframework.org/schema/beans/spring-beans.xsd">
>>>>>>>>>>>
>>>>>>>>>>> <bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
>>>>>>>>>>> <property name="connectionFactory">
>>>>>>>>>>> <bean
class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>>>>>>>> <property name="brokerURL"
value="${jms.url}"/>
>>>>>>>>>>> <property name="userName"
value="${jms.username}"/>
>>>>>>>>>>> <property name="password"
value="${jms.password}"/>
>>>>>>>>>>> <property name="clientID" value="${clientId}" />
>>>>>>>>>>> </bean>
>>>>>>>>>>> </property>
>>>>>>>>>>> </bean>
>>>>>>>>>>> <!-- in bound Topic -->
>>>>>>>>>>> <bean id="myDestination"
class="org.apache.activemq.command.ActiveMQTopic">
>>>>>>>>>>> <constructor-arg value="${inbound.destination.name}" />
>>>>>>>>>>> </bean>
>>>>>>>>>>> <bean id="defaultMessageListener"
class="DefaultMessageListener">
>>>>>>>>>>> <property name="messageListener"
ref="messageListenerRepository" />
>>>>>>>>>>> </bean>
>>>>>>>>>>> <bean id="messageListenerAdapter"
>>>>>>>>>>>
class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
>>>>>>>>>>> <constructor-arg
>>>>>>>>>>> ref="defaultMessageListener" />
>>>>>>>>>>> </bean>
>>>>>>>>>>>
>>>>>>>>>>> <!-- Listener Contatiner-->
>>>>>>>>>>> <bean id="jmsContainer" destroy-method="shutdown"
>>>>>>>>>>>
class="org.springframework.jms.listener.DefaultMessageListenerContainer" >
>>>>>>>>>>> <property name="connectionFactory" ref="connectionFactory" />
>>>>>>>>>>> <property name="destination" ref="myDestination" />
>>>>>>>>>>> <property name="messageListener" ref="messageListenerAdapter" />
>>>>>>>>>>> <property name="subscriptionDurable" value="true" />
>>>>>>>>>>> </bean>
>>>>>>>>>>> </beans>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> public class DefaultMessageListener implements MessageListener {
>>>>>>>>>>>
>>>>>>>>>>> @Override
>>>>>>>>>>> public void handleMessage(String message) throws Exception {
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> @Override
>>>>>>>>>>> public void handleMessage(Map message) throws Exception {
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> @Override
>>>>>>>>>>> public void handleMessage(byte[] message) throws Exception {
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> @Override
>>>>>>>>>>> public void handleMessage(Serializable message) throws
Exception {
>>>>>>>>>>> }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Kind regards.
>>>>>>>>>>>
>>>>>>>>>>> BENNOUR HASSEN
>>>>>>>>>>>
>>>>>>>>>>> SOA Architect / Java Software Engineer
>>>>>>>>>>>
>>>>>>>>>>> 2016-08-31 10:14 GMT+02:00 Crishel Yumul <crishel.yumul@toro.io
>:
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks but I’m no programmer. I’m just dealing with Spring.
Here’s the current config of my customer:
>>>>>>>>>>>>
>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>>>> xsi:schemaLocation="
http://www.springframework.org/schema/beans
>>>>>>>>>>>>
http://www.springframework.org/schema/beans/spring-beans.xsd">
>>>>>>>>>>>>
>>>>>>>>>>>> <bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
>>>>>>>>>>>> <property name="connectionFactory">
>>>>>>>>>>>> <bean
class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>>>>>>>>> <property name="brokerURL"
value="${jms.url}"/>
>>>>>>>>>>>> <property name="userName"
value="${jms.username}"/>
>>>>>>>>>>>> <property name="password"
value="${jms.password}"/>
>>>>>>>>>>>> </bean>
>>>>>>>>>>>> </property>
>>>>>>>>>>>> </bean>
>>>>>>>>>>>> </beans>
>>>>>>>>>>>>
>>>>>>>>>>>>> On Aug 31, 2016, at 4:12 PM, Hassen Bennour <
bennour.hassen@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>
>>>>>>>>>>>>> here is an example
>>>>>>>>>>>>>
>>>>>>>>>>>>> import javax.jms.Connection;
>>>>>>>>>>>>> import javax.jms.ConnectionFactory;
>>>>>>>>>>>>> import javax.jms.JMSException;
>>>>>>>>>>>>> import javax.jms.Message;
>>>>>>>>>>>>> import javax.jms.MessageListener;
>>>>>>>>>>>>> import javax.jms.Session;
>>>>>>>>>>>>> import javax.jms.Topic;
>>>>>>>>>>>>> import javax.jms.TopicSubscriber;
>>>>>>>>>>>>>
>>>>>>>>>>>>> import org.apache.activemq.ActiveMQConnectionFactory;
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class DurableSubscriberListener {
>>>>>>>>>>>>>
>>>>>>>>>>>>> public static void main(String[] args) throws JMSException {
>>>>>>>>>>>>> Connection conn = null;
>>>>>>>>>>>>> try {
>>>>>>>>>>>>> ConnectionFactory cf = new ActiveMQConnectionFactory();
>>>>>>>>>>>>> conn = cf.createConnection();
>>>>>>>>>>>>> Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
>>>>>>>>>>>>> Topic dest = session.createTopic("topic");
>>>>>>>>>>>>> conn.setClientID("durableSubscriber");
>>>>>>>>>>>>> TopicSubscriber durableSubscriber =
session.createDurableSubscriber(dest, "durableSubscriber");
>>>>>>>>>>>>> durableSubscriber.setMessageListener(new MessageListener() {
>>>>>>>>>>>>> @Override
>>>>>>>>>>>>> public void onMessage(Message message) {
>>>>>>>>>>>>> // TODO Auto-generated method stub
>>>>>>>>>>>>>
>>>>>>>>>>>>> }
>>>>>>>>>>>>> });
>>>>>>>>>>>>> conn.start();
>>>>>>>>>>>>> } catch (Exception e) {
>>>>>>>>>>>>> // TODO Auto-generated catch block
>>>>>>>>>>>>> e.printStackTrace();
>>>>>>>>>>>>> } finally {
>>>>>>>>>>>>> if (conn != null) {
>>>>>>>>>>>>> try {
>>>>>>>>>>>>> conn.close();
>>>>>>>>>>>>> } catch (Exception e) {
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> you have all examples under AMQ installation
, ${ACTIVEMQ_HOME}/examples\openwire\exploring-jms\TopicPubSubSamples\DurableChat
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Kind regards.
>>>>>>>>>>>>>
>>>>>>>>>>>>> BENNOUR HASSEN
>>>>>>>>>>>>>
>>>>>>>>>>>>> SOA Architect / Java Software Engineer
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2016-08-31 9:28 GMT+02:00 Crishel Yumul <crishel.yumul@toro.io
>:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Good day!
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I would like to ask how to create a durable subscriber.
Written and video tutorials just made me confuse. Can you help me again
this time? Thanks a lot. I have a lot questions.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards,
>>>>>>>>>>>>>> Crishel Yumul
>>>>>>>>>>>>>> DevOps
>>>>>>>>>>>>>> TORO Limited
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>