7 Replies Latest reply on Sep 23, 2003 4:42 PM by adrian.brock

    JMS Problem

    vincentchun

      Thanks for all first.

      Why I cannot subscribe a message in the following case?
      1. I publish a message first
      2. Then, I subscribe a message

      but I can subscribe a message in the following case:
      1. I subscribe a message first
      2. Then, I publish a message

      I use Servlet to subscribe the message.

      Is the message will stay in JBoss Server after it is published?

      Part of my code:
      TopicPublisher publisher = session.createPublisher(topic);
      publisher.publish(message, DeliveryMode.NON_PERSISTENT, 4, 0);

      The result is same if I use the following codes:
      publisher.publish(message, DeliveryMode.PERSISTENT, 4, 0);
      or
      publisher.publish(message, DeliveryMode.NON_PERSISTENT, 4, 50000);

      How to set the JBoss that can make a message stay in Server?

        • 1. Re: JMS Problem

          Are you using a durable subscription?

          It is not physic, it won't hold messages for subscriptions
          that have been not created yet.

          Regards,
          Adrian

          • 2. Re: JMS Problem
            vincentchun

            Thanks for Adrian first.

            I have used the Durable Subscriber.
            And part of my code as follow:

            String username = "Vincent";
            TopicSubscriber sub = session.createDurableSubscriber(topic, username, "user = '" + username + "'", false);

            Except durable subscriber, is there any extra setting need?

            • 3. Re: JMS Problem
              vincentchun

              I mean, is there any method (or any setting) which can make a message stay in server?

              Thanks for your help!

              • 4. Re: JMS Problem

                Check jbossmq-state.xml
                Do you see ID: in your durable subscriptions?

                Use connection.setClientID()

                Regards,
                Adrian

                • 5. Re: JMS Problem
                  vincentchun

                  Yes, I can see the ID as follow:


                  ID:102
                  Vincent
                  TestTopic
                  user = 'Vincent'


                  What is the meaning of "Use connection.setClientID()"?

                  Thanks for your help!

                  • 6. Re: JMS Problem

                    A durable subscription is a product of the connection's
                    clientID and the subscription name.

                    You can either setClientID on the connection or configure
                    the user with a client id in jbossmq-state.xml
                    (see john/needle in the default config for the latter).

                    Regards,
                    Adrian

                    • 7. Re: JMS Problem

                      ID:102 means you did neither so the connection has
                      an "anonymous" clientID

                      Regards,
                      Adrian