4 Replies Latest reply on Nov 2, 2009 2:40 PM by timfox

    Pub/sub pattern with Core APIs

      Good morning,

      I am interested in trying HornetQ for asynchronous pub/sub. We have a system that needs to 'dispatch' messages that multiple consumers will receive asynchronously. I am used to doing this in Tibco RV, so I am wanting to try the same approach with HornetQ.

      Firstly, is this possible with the Core API, or will I need to use JMS? I am trying the JMS topic-based examples, and I do have more questions, but they can wait.

      Thanks,

      Simon

        • 1. Re: Pub/sub pattern with Core APIs
          timfox

          Core does not distinguish between publish subscribe and point to point messaging, since, in effect, point to point is just a special case of pub sub where there's only one subscriber.

          With core, if a message is sent to an address, then all queues bound to that address will receive that message. That gives you pub-sub. This is discussed a bit in the user manual, section on messaging concepts.

          • 2. Re: Pub/sub pattern with Core APIs

            Tim, thank you for that pointer. I am clearer now on how to create a producer that sends to a specific address, but I am having trouble creating consumers that use a specific address.

            I want to be able to send messages on arbitrary addresses that appear out of thin air, with a hierarchical structure such as:

            type.thing.1
            type.thing.2

            And then I'd want to create consumers that could receive messages on any number of or just one of those. I can't find a method in the ClientSession that lets me specify an address 'pattern' using wild-cards (or not, as the case may be). I see the filter expression parameter, but that doesn't seem to do what I want.

            Can you point me to that part of the API or an example?

            Thanks,

            Simon

            • 3. Re: Pub/sub pattern with Core APIs
              timfox

              You don't create a consumer on the address, you create it on a queue (see the ClientSession api).

              When you create a queue on an address, you can specify a wildcard for the adress and the queue will retain any messages sent to any matching addresses.

              It's like this

              address --------0..* queues ----- 0..* consumers

              I.e. an address can have zero or more queues.

              A queue can have zero or more consumers

              • 4. Re: Pub/sub pattern with Core APIs
                timfox