8 Replies Latest reply on Jul 3, 2008 5:06 AM by mbreuer

    Message Consumer fails when using messageSelector

    mbreuer

      I am evaluating JBoss 4.2.2 and JBoss Messaging 1.4.0SP3. When using MessageConsumer with a messageSelector, the communication hangs.
      The response ObjectMessage is build in the right way, msg.setJMSCorrelationID() and msg.setJMSType() are set. The MessageProducer sends
      the message, but the receiver doesn't receive it.

      The messageSelector looks like this: (JMSCorrelationID = '1213880979122' AND JMSType='java.lang.String')
      It seems to be okay. (mistakes will produce an exception)

      cfB = (ConnectionFactory) ic.lookup("/ConnectionFactory");
       connectionB = (Connection) cfB.createConnection();
       sessionB = connectionB.createSession(false, Session.AUTO_ACKNOWLEDGE );
       queue = (Queue) ic.lookup("queue/B"); // one of the example queues
       consumer = sessionB.createConsumer(queue, messagleSelector );
       Message msg = consumer.receive();


      Note: the code works when running outside JBossAS, but does not receive messages from inside the container.

      After setting messageSelector=null a message is received. The debug-inspector shows there are no message headers (JMSCorrelationID,JMSType) are set. I verified the sender, while sending the jms header attributes are set (checked with debugging inspector).
      It seems the headers are lost during transport ....

      Differences:
      Outside JBossAS the inspector indicates a SpyObjectMessage while inside the container a JbossObjectMessage is used.

      Any ideas what's wrong? JBoss Messaging was installed with ant (messaging-node1). A cluster configuration (based on all) is used with a single node.
      In the past the code was used with jboss 4.0.3 and JBossMQ. In run fine, but after switching to jboss-messaging the hangs occur.

      Questions:
      1.) How can i solve the problem?
      2.) Is there a difference in these lines or are they equivalent?
      msg.setJMSCorrelationID(correlationId); // 1
      msg.setStringProperty("JMSCorrelationID", correlationId ); //2

      markus



        • 1. Re: Message Consumer fails when using messageSelector
          jmesnil

           

          "mbreuer" wrote:
          I am evaluating JBoss 4.2.2 and JBoss Messaging 1.4.0SP3. When using MessageConsumer with a messageSelector, the communication hangs.

          ...
          Differences:
          Outside JBossAS the inspector indicates a SpyObjectMessage while inside the container a JbossObjectMessage is used.


          SpyObjectMessage is a class from JBossMQ, not JBoss Messaging.
          Are you sure you're using JBoss Messaging outside the container?


          2.) Is there a difference in these lines or are they equivalent?
          msg.setJMSCorrelationID(correlationId); // 1
          msg.setStringProperty("JMSCorrelationID", correlationId ); //2



          #2 is not legal: you're not allowed to start the name of a property by "JMS".
          JMSCorrelationID must be set using #1 to work

          hope it helps,
          jeff

          • 2. Re: Message Consumer fails when using messageSelector
            mbreuer

            Thanks for the hint!

            Probably the client classpath (outside) jboss contains a wrong jar, i will check it.

            What about the behavior inside the container? JBossObjectMessage seems to be the right one. After setting JMSCorrelationID the object contains (in debugger) the header property. Any idea, how the information is lost on way to the consument? jbossmq.jar is not in the jboss-classpath (recursive search over whole folder).
            The JBossMessaging is installed as described in the instructions.
            Note: MDBs are well running, the problems only occur when using direct jms access. (jms client).

            markus

            • 3. Re: Message Consumer fails when using messageSelector
              timfox

              After installing, please run the examples as explained in the user guide.

              If they don't all run successfully that means your installation was botched.

              In which case you would need to re-install.

              • 4. Re: Message Consumer fails when using messageSelector
                mbreuer

                The example runs without trouble.

                I used the example for my eclipse testclient. As noted, my test-client used the the wrong classpath, i will verify this. Primary goal to get jboss messaging running inside the container.

                The message driven beans work fine. Also my jms-client works in general. In my opinion the defect affects message headers only. So receiving without selector works, too.

                markus

                • 5. Re: Message Consumer fails when using messageSelector
                  mbreuer

                  Any idea, why the receive fails?

                  How can i find out, what goes wrong? Are there special log entries?
                  The ObjectMessage is stored to an oracle database, but the header fields are of type blob, so a can't take a look into.

                  • 6. Re: Message Consumer fails when using messageSelector
                    timfox

                    Sounds like your selector is just wrong, where are you setting JMSType="java.lang.String"?

                    Please post a simple java example demonstrating the problem (both sender and receiver).

                    • 7. Re: Message Consumer fails when using messageSelector
                      mbreuer

                      I tried it again and reinstalled jboss 4.2.2.GA with messaging. After that it look a bit different. First of all, the consumers receive the messages. But they don't receive immediatelly, they wait up to nearly timeout seconds.

                      Message msg = MessageConsumer.receive(60000);

                      Sometimes the call returns immediatelly, but sometime it takes up to timeout seconds. I created a simle test-app, doing the same. This test-app does not hang.

                      The process flow is following:

                      thread-1: send to queue A
                      receive( queue B, by selector, timeout );

                      thread-2: Message Driven Bean
                      onMessage(...) {
                      // do somehing
                      send response to queue B
                      // do something more
                      }

                      The original code is based on ejb2.x Mdb and causes hangs. My sample App uses an Ejb3 Mdb.
                      After doSend() is see an entry in JBM_MSG table. So i think to jms operation is successfull commited, isn't?



                      • 8. Re: Message Consumer fails when using messageSelector
                        mbreuer

                        Solved! The problematic code was instantiated several times, so at least one jms-session per request was created. Seems this blocks the queue for a while, because the other (old) session processes the request and puts it back (no consumer) after a specific period.