1 2 3 4 Previous Next 51 Replies Latest reply on Nov 8, 2012 7:46 AM by ataylor

    Divert to multiple destinations

    pacodelucia

      Hi

       

      After having found the solution to all my problems last week on this forum I have a question regarding the solution: diverts

       

      What I'm trying to do is somehow implement a topic with queues on the hornetq server.

       

      - I have a queue A where message are written to by a client

      - I would like to have two queues B and C (at the moment) where the messages that are written to A are forwarded. In the future I would like to have more Queues.

      - The message in A should be deleted after copying it to B and C.

       

      At the moment I see two solutions using diverts:

       

      1. Instead of having A, B and C just have A and B. The first consumer will read directly from A. A "non-exclusive" divert will copy messages from A to B.

      2. I could define also an "exclusive divert" from A to B (so the message is deleted in A). Then I could define a "non exclusive" divert from B to C. So I'm basically chaning the Queues together with diverts.

       

       

      For "symmetric" reasons I would prefer to be abel to define multiple forwarding addresses for a "exclusive" divert like this:

       

      <divert name="bla">

           <address>jms.queue.sourcequeue</address>

           <forwarding-address>jms.queue.A</forwarding-address>

           <forwarding-address>jms.queue.B</forwarding-address>

           <exclusive>true</exclusive>

      </divert>

       

       

      I now that you cannot do this. It is just to explain what I mean. The question is: Exists a similar solution to this or will I have to implement one of the described solutions above?

       

      I cannot use a Topic because there will be multiple "subscribers" to the same "subscription" (we have to jboss instances that are not clustered but access the same topic using the same subscription).

       

      Thanks and regards

      Oliver

        • 1. Re: Divert to multiple destinations
          jmesnil

          pacodelucia wrote:

           

          What I'm trying to do is somehow implement a topic with queues on the hornetq server.

           

          - I have a queue A where message are written to by a client

          - I would like to have two queues B and C (at the moment) where the messages that are written to A are forwarded. In the future I would like to have more Queues.

          - The message in A should be deleted after copying it to B and C.

          is JMS a requirement? If you are able to use HornetQ core API, it's much simpler:

           

          * the sender sends messages to an address A

          * HornetQ server creates multiple queues B, C, D bound to address A

          * each consumer consumes from its own queue (B, C, or D)

          • 2. Re: Divert to multiple destinations
            pacodelucia

            Thanks for your reply. Yes, JMS is a requirement. Isn't it possible to do something like this with JMS? I mean JMS is just to write and read from the queues but what you do inside hornet can be done regardless of JMS or am I wrong? A divert for example is not JMS but still I can access my queues using JMS.

             

            Thanks

            • 3. Re: Divert to multiple destinations
              ataylor

              I think what Jeff is saying is this, using JMS when we create a queue it gets a default address of the same name, so jms.queue.myQ would have an address of jms.queue.myQ. since a divert diverts to an address it can only be forwarded to 1 queue. However if using core you can bind any core queue to any address, so you can have multiple queues all on the sane address (this is how topics are implemented).

              • 4. Re: Divert to multiple destinations
                mlange

                Hi jeff,

                 

                I have tried to implement this concept with a simple example. But I can't get it to run as expected.

                 

                I have created a queue which has multiple bindings configured:

                 

                Deployed queue: abo

                     Binding: abo.binding.1

                     Binding: abo.binding.2

                     Binding: abo.binding.3

                     Binding: abo.binding.4

                 

                I am sending messages to the "jms.queue.abo" address using core. Ok so far. You mentioned "each consumer consumes from its own queue (B, C, or D)". Is it possible to consume now from the four address bindings e.g. "abo.binding.1"? Is core a requirement on the consumer side as weil?

                 

                Thanks,

                Marek

                • 5. Re: Divert to multiple destinations
                  ataylor

                  I have created a queue which has multiple bindings configured:

                   

                  Deployed queue: abo

                       Binding: abo.binding.1

                       Binding: abo.binding.2

                       Binding: abo.binding.3

                       Binding: abo.binding.4

                  Marek, this doesn't really make sense, its not queues that have bindings it addresses, and its the queue that is the binding, so for instance:

                   

                  <queue name="abo.binding.1">

                       <address>abo</address>

                  </queue>

                   

                  would bind the queue abo.binding.1 to the address abo

                  • 6. Re: Divert to multiple destinations
                    mlange

                    Hi Andy,

                     

                    yes I realized this as well. Thanks for clarifying.

                     

                    Regarding my second question: can we use plain JMS for consuming from these specific queues, e.g. "abo.binding.1"? Or is the core API also needed on the consumer?

                     

                    Thanks,

                    Marek

                    • 7. Re: Divert to multiple destinations
                      ataylor

                      Regarding my second question: can we use plain JMS for consuming from these specific queues, e.g. "abo.binding.1"? Or is the core API also needed on the consumer?

                      The JMS layer just uses the core API under the covers, so yes in theory you will be able to use JMS, however the destinations won't be bound in JNDI and you would have to follow the jms naming conventions for destinations, i.e. jms.queue.foo etc

                      • 8. Re: Divert to multiple destinations
                        mlange

                        In theory yes. I tested with different combinatons but sending to an address using core api and receiving through plain JMS does not work.

                         

                        Two queues:

                         


                        <queue name="abo">
                          
                        <address>jms.queue.abo</address>
                           <durable>false</durable>
                           </queue>
                          
                           <queue name="abo.fezadm.live">
                          
                        <address>jms.queue.abo</address>
                           <durable>false</durable>
                           </queue>

                         

                        Sending to "jms.queue.abo" (core API). Receiving from "abo.fezadm.live" (plain JMS). No message is received.

                         

                        When consuming from "abo" it works. What am I doing wrong?

                         

                        Thanks,

                        Marek

                        • 9. Re: Divert to multiple destinations
                          ataylor

                          can you post/attach your config and example code please and i will take a look

                          • 10. Re: Divert to multiple destinations
                            mlange

                            Hi Andy,

                             

                            I wanted to test this first on integration using JBoss EAP6. I only had tested this using the embedded JMS hornetq server. Unfortunately the next problem occured: we are using the HornetQ RA to connect from JBoss EAP4 to the JBoss EAP HornetQ. Therefore we are using a pooled JMS XA Connectionfactory inside the appserver. The question is: is it possible to use the HornetQ Core API in this combination or is just plain JMS supported:

                             

                            java.lang.ClassCastException: org.hornetq.ra.HornetQRAConnectionFactoryImpl cannot be cast to org.hornetq.jms.client.HornetQConnectionFactory

                             

                            I can move this question to another thread of course.

                             

                            And sending to a core address is also possible with EAP6 as JMS server? I did not see any configuration as we have it in hornetq-configuration.xml where the address is part of the queue definition. In domain.xml messaging subsystem there are only jms-destinations configured....

                             

                            Thanks a lot for your input!

                            • 11. Re: Divert to multiple destinations
                              ataylor

                              I wanted to test this first on integration using JBoss EAP6. I only had tested this using the embedded JMS hornetq server. Unfortunately the next problem occured: we are using the HornetQ RA to connect from JBoss EAP4 to the JBoss EAP HornetQ. Therefore we are using a pooled JMS XA Connectionfactory inside the appserver. The question is: is it possible to use the HornetQ Core API in this combination or is just plain JMS supported:

                              no the RA connection factories are the Application Servers not HornetQ altho they do use HornetQ under the covers.

                              And sending to a core address is also possible with EAP6 as JMS server? I did not see any configuration as we have it in hornetq-configuration.xml where the address is part of the queue definition. In domain.xml messaging subsystem there are only jms-destinations configured....

                              As far as i know you can configure core addresses, it should be the same, unless there is a bug (thid is AS7 code not HQ)

                              • 12. Re: Divert to multiple destinations
                                jmesnil

                                Marek Neumann wrote:

                                 

                                And sending to a core address is also possible with EAP6 as JMS server? I did not see any configuration as we have it in hornetq-configuration.xml where the address is part of the queue definition. In domain.xml messaging subsystem there are only jms-destinations configured....

                                You can also configure core queues in the AS7 configuration files. For example:

                                 

                                                <core-queues>

                                                    <queue name="myQueue">

                                                        <address>myAddress</address>

                                                    </queue>

                                                </core-queues>

                                • 13. Re: Divert to multiple destinations
                                  mlange

                                  no the RA connection factories are the Application Servers not HornetQ altho they do use HornetQ under the covers.

                                  Is my assumption correct that the advantage to use the JMS Connection Factory from the appserver only provides pooling mechanisms? XA transaction support can also be realized using the HornetQ XA Connection Factory?

                                  • 14. Re: Divert to multiple destinations
                                    ataylor

                                    Is my assumption correct that the advantage to use the JMS Connection Factory from the appserver only provides pooling mechanisms?

                                    correct

                                    XA transaction support can also be realized using the HornetQ XA Connection Factory?

                                    Yes, it supports XA but you would have to enlist it with the transaction manager yourself if you did it that way

                                    1 2 3 4 Previous Next