13 Replies Latest reply on Dec 5, 2008 8:03 AM by rododendro.ivan

    Expiaration date does not work ?

    rododendro.ivan

      Hello,
      we post some PERSISTENT messages on a Topic which is subscribed by a durable subscriber. Expired messages are not removed from persistence (JBM_MSG) util an acknoledge is called. Right now (04 dec 08 16:17) a message with expiration = 1228402690296 (Thu Dec 04 15:58:10 CET 2008) is still on my database.

      JBM version is 1.4.1-CR1, persistence provider is oracle 10i, post office is not clustered.

      Any idea ?
      thank you
      Ivan

        • 1. Re: Expiaration date does not work ?
          ataylor

           

          Expired messages are not removed from persistence (JBM_MSG) util an acknoledge is called


          That's correct, all messages must be kept in storage until they are properly consumed, i.e. they have been acknowledged or rolled back. If they are acked they are deleted from the database, if the message is rolled back it is re scheduled for delivery, if at thi stime it has expired it is then deleted.

          • 2. Re: Expiaration date does not work ?
            rododendro.ivan

            From JMS 1.1 specification:

            At the cost of higher overhead, a subscriber can be made durable. A durable
            subscriber registers a durable subscription with a unique identity that is retained
            by JMS. Subsequent subscriber objects with the same identity resume the
            subscription in the state it was left in by the prior subscriber. If there is no
            active subscriber for a durable subscription, JMS retains the subscription’s
            messages until they are received by the subscription or until they expire.


            I don't know what you mean for "rollback" in this case... the message is posted on the topic, delivered once, never acked. Then the topic is unsuscribed and the session is closed, I'm expecting not to find the message in the topic when specified TTL has expired.

            As the ack is a client responsablity, the goal is not to have too many messages wating for an ack which is not under the control of the system.

            What do you mean for "rollback"? Maybe session.recover() ?

            Thank you
            Ivan




            • 3. Re: Expiaration date does not work ?
              ataylor

               

              I don't know what you mean for "rollback" in this case... the message is posted on the topic, delivered once, never acked. Then the topic is unsuscribed and the session is closed, I'm expecting not to find the message in the topic when specified TTL has expired.


              Ok, I think I'm misunderstanding you here, I assumed that when you said the messages weren't being acked that you were using CLIENT_ACKNOWLEDGE mode and weren't acking consumed messages, If this was the case the when the session is closed i would expect the messages to added back into the queue for redelivery or if they had expired, deleted completely. If this is not the case can you provide a standalone test case and i'll take a look.

              PS thanks for quoting the spec to me :)

              • 4. Re: Expiaration date does not work ?
                timfox

                 

                "ivan.rododendro" wrote:
                Hello,
                we post some PERSISTENT messages on a Topic which is subscribed by a durable subscriber. Expired messages are not removed from persistence (JBM_MSG) util an acknoledge is called. Right now (04 dec 08 16:17) a message with expiration = 1228402690296 (Thu Dec 04 15:58:10 CET 2008) is still on my database.

                JBM version is 1.4.1-CR1, persistence provider is oracle 10i, post office is not clustered.

                Any idea ?
                thank you
                Ivan


                That is perfectly correct behaviour.

                JMS does not mandate that expired messages are removed before delivery. In JBM 1.x expired messages are actually expired at delivery time,

                All JMS spec says is that expired messages shouldn't be delivered.

                • 5. Re: Expiaration date does not work ?
                  rododendro.ivan

                  This is a stand-alone test case:

                  public class JmsTestClient {
                  
                   private static final String SUBSCRIBER_NAME = "test-sub";
                  
                   private static final String TEXT_MESSAGE = "Text message in SRMChangedEvent";
                  
                   private static final String TOPIC_NAME = "/topic/TestTopic";
                  
                   private TopicSubscriber durableSubscriber;
                  
                   private TopicSession subscriberSession;
                  
                   private TopicConnection connection;
                  
                   public JmsTestClient() throws NamingException {
                   System.getProperties().put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                   System.getProperties().put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                   System.getProperties().put("java.naming.provider.url", "localhost");
                   }
                  
                   public static void main(String[] args) {
                  
                   try {
                   JmsTestClient testClient = new JmsTestClient();
                  
                   testClient.createDurableSubscriber();
                  
                   testClient.postMessage();
                  
                   testClient.consumeMessage();
                  
                   testClient.unsuscribe();
                  
                   } catch (Exception e) {
                   e.printStackTrace();
                   }
                   }
                  
                   private void unsuscribe() throws Exception {
                   durableSubscriber.close();
                   try {
                   subscriberSession.unsubscribe(SUBSCRIBER_NAME);
                   } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                   }
                   subscriberSession.close();
                   }
                  
                   private void postMessage() throws Exception {
                   InitialContext initialContext = new InitialContext();
                   JBossConnectionFactory topicConnectionFactory = (JBossConnectionFactory) initialContext
                   .lookup("ConnectionFactory");
                   Topic destination = (Topic) initialContext.lookup(TOPIC_NAME);
                   TopicConnection connection = topicConnectionFactory.createTopicConnection();
                  
                   TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                   TopicPublisher producer = session.createPublisher(destination);
                   Message message = session.createTextMessage(TEXT_MESSAGE);
                  
                   producer.setDeliveryMode(DeliveryMode.PERSISTENT);
                   producer.setTimeToLive(43200);
                   producer.send(message);
                  
                   producer.close();
                   session.close();
                   connection.stop();
                   connection.close();
                   }
                  
                   private void consumeMessage() throws Exception {
                  
                   System.out.println("Waiting for message...");
                   TextMessage message = (TextMessage) durableSubscriber.receive();
                   System.out.println("Received");
                  
                   if (message.getText().equals(TEXT_MESSAGE))
                   System.out.println("message text is ok");
                   }
                  
                   private void createDurableSubscriber() throws Exception {
                   final InitialContext initialContext = new InitialContext();
                   final JBossConnectionFactory topicConnectionFactory = (JBossConnectionFactory) initialContext
                   .lookup("ConnectionFactory");
                   final Topic destination = (Topic) initialContext.lookup(TOPIC_NAME);
                   connection = topicConnectionFactory.createTopicConnection();
                   connection.setClientID("test");
                  
                   subscriberSession = connection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
                   durableSubscriber = subscriberSession.createDurableSubscriber(destination, SUBSCRIBER_NAME, null, false);
                  
                   connection.start();
                   }
                  }


                  As the message is never acked when we try to unsuscribe durable subscriber JBM throws an exception but - client code - the session is closed anyway.

                  The durable subscriber is removed anyway, the message is no more in the topic (checked on JMX console) but it still be on the database, with DELIVERY_COUNT = 1.

                  So unacked messages will never be removed from persistence?

                  Thank you very much, and sorry to have posted the spec, I did it only to have a common "starting point"

                  Ivan.




                  • 6. Re: Expiaration date does not work ?
                    timfox

                    I don't understand from your post what problem you are trying to describe.

                    Can you explain again a bit more clearly?

                    • 7. Re: Expiaration date does not work ?
                      rododendro.ivan

                      Ok, let's try again:

                      1) A topic is created
                      2) A durable subscriber is created fro the topic
                      3) A message is sent on the topic
                      4) The durable subscriber pulls the message from the topic ( receive() ) but don't ack
                      5) The durable subscriber is closed, subscriber session.unsuscribe(name) is called but an exception is thrown and then the subsciber session is closed.

                      As result of this a message, expired, with DELIVERY_COUNT = 1 will remain on the database forever. Is that normal ?

                      Hope it's clearer, thank you
                      Ivan

                      • 8. Re: Expiaration date does not work ?
                        timfox

                        What exception is thrown?

                        • 9. Re: Expiaration date does not work ?
                          rododendro.ivan

                          This one

                          java.lang.IllegalStateException: Cannot remove references while deliveries are in progress (Channel 518), there are 1


                          I

                          • 10. Re: Expiaration date does not work ?
                            timfox

                            Ok. thx.

                            Can you create a jira report with all the information in it, including stack trace.

                            Also I notice you're using a CR release and JBoss 5. Can you upgrate to JBoss 5.0.GA to check the problem occurs in that.

                            • 11. Re: Expiaration date does not work ?
                              rododendro.ivan

                              Did'nt know that 5.0GA was out, I'll check it soon.

                              How do I create a JIRA report ?

                              I

                              • 12. Re: Expiaration date does not work ?
                                timfox

                                 

                                "ivan.rododendro" wrote:
                                Did'nt know that 5.0GA was out, I'll check it soon.


                                It was released this morning :)


                                How do I create a JIRA report ?

                                I


                                jira.jboss.com, click create new issue.

                                • 13. Re: Expiaration date does not work ?
                                  rododendro.ivan

                                  The behaviour is the same in 5.0GA, I opened the issue: https://jira.jboss.org/jira/browse/JBMESSAGING-1462

                                  5.0GA has a much improved startup time, all developers will appreciate!

                                  I