6 Replies Latest reply on Dec 30, 2012 10:49 AM by chris.j.prior

    Clustered Topic with Diverts

    chris.j.prior

      Hi,

       

      I am looking for some advice as to functionality in HornetQ for the following scenario.

       

      I have 2 stand alone HornetQ 2.2.14.Final servers (A & B) which each have a cluster connection defined using a static connector pointed to the other server.

       

      Also defined on each server are a JMS Queue (jms.queue.queueA) and a JMS Topic (jms.topic.clustered.topicA). The cluster connections are defined so as to include the topic as a clustered address but not the queue.

       

        <cluster-connection name="cluster">

             <address>jms.*.cluster</address>   

             <connector-ref>netty</connector-ref>  

             <use-duplicate-detection>true</use-duplicate-detection> 

             <forward-when-no-consumers>true</forward-when-no-consumers>

             <max-hops>1</max-hops>     

            <static-connectors>

              <connector-ref>netty-node1</connector-ref>

          </static-connectors>

           </cluster-connection>

        </cluster-connections>

       

      Finally a divert is defined on each server such that some of the messages delivered to jms.queue.queueA are diverted into the local jms.topic.clustered.topicA.

       

      I have removed the filter as it is not relevant.

       

      <divert name="my-divert">

              <address>jms.queue.queueA</address>

              <forwarding-address>jms.topic.cluster.topicA</forwarding-address>

              <exclusive>false</exclusive>

          </divert>

       

      I have run various test against this configuration and the following scenarios appear to be playing out.

       

      1. If I deliver the message to queueA then the divert copies the message to the local topicA where it is consumed by an appropriate subscriber of the local topicA. No messages are received by subscribers of the remote topicA.
      2. If I deliver the message directly to topicA then messages are consumed by subscribers of both the local and remote topic A. This demonstrates that the cluster / topic are configured properly.

       

      So my questions are:

       

      1. Is HornetQ designed such that messages diverted from one address to another clustered address are not then passed to remote nodes in the cluster?
      2. Assuming HornetQ is not designed as specified in (1), are there any examples which I can refer to in trying to configure my own servers to do this?
      3. If this is by design are there any other options which could allow some of the messages delivered to a queue to be redistributed to multiple subscribers across a cluster?

       

      I appreciate you are all very busy, so I offer my thanks in advance for any guidance you can provide.

       

      Chris

        • 1. Re: Clustered Topic with Diverts
          gaohoward
            <cluster-connection name="cluster">

                 <address>jms.*.cluster</address>   

                 <connector-ref>netty</connector-ref>  

                 <use-duplicate-detection>true</use-duplicate-detection> 

                 <forward-when-no-consumers>true</forward-when-no-consumers>

                 <max-hops>1</max-hops>     

                <static-connectors>

                  <connector-ref>netty-node1</connector-ref>

              </static-connectors>

               </cluster-connection>

            </cluster-connections>

           

          The address is used internally by cluster-connection. It has nothing to do with any queues or topics in your application. just give it a plane string would be fine . like :

           

          <address>jms</address>

          • 2. Re: Clustered Topic with Diverts
            chris.j.prior

            Hi,

             

            Thank you for replying.

             

            I had thought the address element defined which addresses were included in the cluster. i.e if the address element matches a particular address then messages received on that address may be forwarded to other nodes in the cluster.

             

            Is this not correct? If so can you explain what the address element is used for?

             

            Is hornetQ capable of doing what I require.

             

            Many thanks again for any help you can give me.

            • 3. Re: Clustered Topic with Diverts
              gaohoward

              Hi Chris,

               

              I'm sorry my previous comment is confusing. Actually you are right about the address. It is used to make sure the messages are correctly redistributed among clustered queues whose addresses match the address pattern.

              In hornetq's code, the address is used to define a filter of  a special queue that is used to receive important updates from other nodes, like queue created and consumer created, etc. This filter conforms to JMS filter syntax and the relevant part is defined as ' LIKE <addrsss>%'.  If the address is 'jms' then the real expression is 'LIKE jms%'.

               

              So I think you can achieve your goal by proper constructing your 'address' values. Note JMS filters uses SQL92 standards so character '*' may not be a valid wildcard. Use '%' instead and see if it works.

               

              Howard

              • 4. Re: Clustered Topic with Diverts
                chris.j.prior

                Hi Howard,

                 

                Thanks for replying once again. I think we may be at a cross purpose; although it is possible I am suffering from a lack of knowledge as to how the code works.

                 

                The setup I am looking to achieve is one where I can divert a message from a non-clustered queue to a clustered topic and have that same message be propogated around a cluster of nodes as if it had been delivered directly to the clustered queue.

                 

                The reason I suspect the problem lies in the combination of a divert and a clustered address is that if I deliver the message directly to the clustered topic, it is propogated around the clustered nodes as expected; this is without making any changes to the cluster configurations address filter. This suggests to me that the cluster connection's address filter is configured correctly.

                 

                To provide more explanation of why I am using the jms.*.clustered filter rather than a straight forward jms filter: I want to cluster all addresses which from a JMS standpoint have addresses of 'clustered.*' regardless of their status as a queue or a topic, I do not however want all addresses to be clustered, there are some JMS queues configured without the 'clustered.*'. element of the address and the * in the first case acts as a word based wild card.

                 

                In any case I believe that because I am able to send messages directly to the clustered address and have it act like it is clustered, rules out the possibility of an incorrectly configured cluster address filter.

                 

                Does hornetq support the capability to have a message first diverted and then clustered? Or can I only take advantage of the cluster if I deliver a message directly to the clustered address?

                 

                Once again thanks in advance for your continued support.

                 

                Chris

                • 5. Re: Clustered Topic with Diverts
                  gaohoward

                  Hi Chris,

                   

                  I think hornetq supports this kind of pattern.  A divert is just forwarding a message to an address without being aware of whether this address is clustered or not. So there is no problem in your design. It should work, i.e. when you send a message to a queueA on node0, the divert will route a copy of it to the topic on node0, which happens to be clustered. So if

                   

                  1. there is a consumer on queueA, it will receive a copy of the message (because the divert is non-exlusive);

                  2. there is a subscriber on topicA on node0, it will receive a copy of the message. (because the divert route a copy to the topic); and

                  3, there is another subscriber on topicA on node1, it will receive a copy of the message (because the topic is clustered so hornetQ server will re-distribute the copy to node1).

                   

                  I tried some test to simulate the above use-case (the config is similar to yours) and I found the only problem is the address value. If it is "jms.*.cluster", a message sent to queueA will be received by consumer to that queue and the subscriber to the topicA on that node the producer is connected to. Similarly sending a message directly to topicA, only the local subscriber can receive the message.

                   

                  If I use "jms.%.cluster" however it all works. Meaning the message sent to queueA will be received by the queue's consumer and both topicA's subscribers.

                   

                  I'm testing this with 2.2.24.GA thou.

                   

                  Howard

                  • 6. Re: Clustered Topic with Diverts
                    chris.j.prior

                    Thanks Howard, I suspect this will overcome my problem. I had thought that the address element used the hornetq wildcard syntax; thanks for correcting my assumption.