2 Replies Latest reply on Jun 27, 2008 11:17 AM by Adrian Brock

    Discussion: Using MessageSelector or sth. else?

    Kevin Lohmann Newbie

      Hi *,

      due to what Adrien Brock (thx for looking after the issue!) said on http://jira.jboss.com/jira/browse/JBAS-5670 I would like to know how to use message selectors correctly respectively which constructs to use.

      The situation:
      We have one queue. To this queue we send messages with a property (lets call it 'arg') and we don't know, how many 'arg'-values exist (so we can't create a concrete number of queues beforehand). We have some consumers which are interested in messages with some specific 'arg'-values. At the moment we solve this by using message selectors. By now we guessed that this is the correct way (we are aware of slow performance).

      But then Adrien wrote yesterday:

      WARNING: This kind of use of message selectors is NOT recommended


      So we are interested in how the above situation could be solved in a recommended way.

      Thx for discussion,
      Kevin

        • 1. Re: Discussion: Using MessageSelector or sth. else?
          testrot Newbie

          Hello,

          if you don't know the number of queues at the time the app server is started, it might be possible to create queues programmatically, at runtime.

          But I don't know if programmatically created queues are full fledged queues. I don't know if:
          - they can be clustered
          - messages are still accessible after a server restart

          Did anybody try this approach? Does anybody know the difference between programmatically created queues and queues created by configuration?

          Greetings,
          Martin

          • 2. Re: Discussion: Using MessageSelector or sth. else?
            Adrian Brock Master

            JMS doesn't have such an automatic semantic for creating queues.
            Queues + selectors will do it, but it won't scale.
            There is no index backing the selector.

            The only way you could achieve it scalably would be use
            a single topic and then create Durable Topic Subscriptions
            for each "arg" value.

            But this is a bit cumbersome because durable topic subscriptions require
            you create client ids so you can reconnect to them and you have
            to make sure they exist before you send the message.

            To me, it sounds more like a solution for a database than JMS.