4 Replies Latest reply on Aug 3, 2004 5:02 PM by dzerzhinsky

    Filtering messages (not in MDB)

    dzerzhinsky

      Hi!
      Could someone tell me how can I provide message filtering in simple JMS client. I don't need to create MDB.
      For purposes of clearness I need to mention my problem more in detail.
      I have session bean that performs operation such as creating, removing and updating of entity beans, it sends JMS messages in topic when one of this events performed. And I have some kind of cache on client side that listens for this messages and updates data. But I don't need cache to
      listern JMS messages when client, on which side cache is deployed, is initiator of session bean operations. I suggest to define property "ClientID" to messages and to filter this messages via ConnectionConsumer on client side. I've desided to pass this "ClientID" when call session bean methods.
      As for me, this sheme isn't so bad, but problem is to create ConnectionConsumer, I need instance of ServerSessionPool, but where can I get it?

      If you understood my thoughts, please help me.
      P.S> I've looked through MBean with declaration of StdJMSPool but it doesn't allow to define any JNDI name to access it in client.

      Oleg F. Yavorsky

        • 1. Re: Filtering messages (not in MDB)
          genman


          Those interfaces are only provided for use by the server implementation, i.e. JBoss. They are not designed to be used by you. If you want to filter messages, use a message selector. There are plenty of examples out there on receiving messages without employing a MDB.

          • 2. Re: Filtering messages (not in MDB)
            dzerzhinsky

            Could you point me to some of this examples, please.

            • 3. Re: Filtering messages (not in MDB)
              doflynn

              1) Create a JMS TopicConnecton
              2) Create a JMS TopicSession
              3) Register a message subscription via TopicSession.createSubscriber(topic, selector, local)
              **) note the use of the message selector
              4) Receive messages using the TopicSubscriber.receive()

              Note: if you create a durable subscriber, remember to "unsubscribe()" when it is no longer needed.

              • 4. Re: Filtering messages (not in MDB)
                dzerzhinsky

                Thank you very much.
                The one think I can't understand it's why my cache in this situation still recieves messages. I don't mean that my onMessage() method being called, but when I look at profiling statistics for my test code I see that most part of time it's took to read from soket in JMS listerning thread even if no messages was received. So why it's so, where is performance? I don't need my cache recieve unneeded messages ever.
                Any suggestions?