0
votes

trying to implement the Durable feature on a Topic consumer. Placed a name to the jms consumer and also clientID. (Obviously added the durable="true")

Now as far as i've read. The Topic will register the consumer as "durable" when it gets running for the first time.

So basically i did this, deployed the producer and consumer. It gets registered as a durable consumer. Publish a message to the topic, the consumer gets it. Now i undeploy the consumer and publish another message the consumer should be receive whenever gets up. When I deploy the consumer again, i get the common temp-topic://XXXXXXXXXXXX destination doesn't exist.

Why is this happening? Shouldn't i be getting the "lost" message?

This is my current jms activemq connector configuration for the publisher:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd ">
    <jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="false"  doc:name="Active MQ" maxRedelivery="1" persistentDelivery="true" durable="true" clientId="RoutingTopic">
        <reconnect count="5"  />
    </jms:activemq-connector>

    <message-properties-transformer name="MessagePropertiesTransformer" doc:name="Message Properties" overwrite="true">
        <add-message-property key="BACKEND_SUBSCRIBER" value="#[flowVars['backend']]"/>
        <add-message-property key="MULE_EVENT_TIMEOUT" value="60000"/>
    </message-properties-transformer>

    <flow name="jmsFlow1" doc:name="jmsFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="jms" doc:name="HTTP"/>
        <set-variable variableName="#['id']" value="#[message.inboundProperties['id']]" doc:name="set dynamic id"/>
        <set-variable variableName="#['backend']" value="#[message.inboundProperties['backend']]" doc:name="setting backend"/>
        <set-payload value="#['This is a message test for id '] #[flowVars['id']]" doc:name="set random string as payload"/>
        <choice doc:name="Choice">
            <when expression="#[true]">
                <processor-chain>                
                    <jms:outbound-endpoint exchange-pattern="request-response"  connector-ref="Active_MQ" doc:name="JMS Topic Requestor" transformer-refs="MessagePropertiesTransformer" topic="ESB.Topic">
                    </jms:outbound-endpoint>
                </processor-chain>
            </when>
            <otherwise>
                <processor-chain>
                    <logger message="This is the default case" level="INFO" doc:name="Logger"/>
                </processor-chain>
            </otherwise>
        </choice>
    </flow>
</mule>

This is one of the consumers, i got 2, but both are basically the same thing

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd ">
    <jms:activemq-connector name="UpCity_Connector" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="false" maxRedelivery="0" doc:name="Active MQ" clientId="RandomName" durable="true"/>
    <flow name="jmsAdapterConsumerFlow1" doc:name="fmsAdapterConsumerFlow1">
        <jms:inbound-endpoint exchange-pattern="request-response"  connector-ref="UpCity_Connector" doc:name="JMS Replier Consumer" topic="ESB.Topic">
            <jms:selector expression="BACKEND_SUBSCRIBER='randombackend'"/>
        </jms:inbound-endpoint>
        <set-payload value="#[payload + ' returned from a random backend']" doc:name="Add string to payload"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

Thanks.

1
Do you have persistent deliveries? Can you show your JMS connector config? Also: Mule version?David Dossot
@DavidDossot posted the config, David. Haven't set the persistentDelivery in this one. With persistentDelivery the data would be stored using kahaDB in the disk, right? inside the kaha.db file.msqar
Depends on how ActiveMQ's persistence is configured on your broker, but by default, yes, it'll be in KahaDB. Yes try adding persistentDelivery="true" on your connector config. Also I do not see durable="true" on it nor a clientId attribute. Is this the right config?David Dossot
But this is the publisher one, does the publisher also needs to be durable=true? i placed durable to only 1 consumer of the 2.msqar
Im also passing through the consumer twice! o.O that's very weird, why would consume it twice??msqar

1 Answers

1
votes

Durable Messaging is a little tricky in JMS, as your config/code will have to meet several criteria to get this to work correctly:

  • enable persistence in your broker's config (in ActiveMQ this is either done in the connection string as David posted, or in your configuration xml
  • create a durable subscriber (ActiveMQ API)

I'm not sure that mule creates durable subscribers. However, you can check that in ActiveMQ's web console. There you can get a list of the current durable subscriptions.