Hi,

I modified a bit the JMSSenderBean from the doc to support JMSExpiration. I 
just added an extra argument which is the value of the time to live and do 
before sending the message: msg.setJMSExpiration(timeToLive);.

I made a simple test case which creates a queue, posts a message with a 
timeToLive of 5 seconds, makes the thread sleep and gets the message from the 
queue. When I check the content of the queue through the JMX Console after the 
message being posted, I see that the JMSExpiration properties of the message is 
set to 0 whereas I set it to 5 sec !?

I'm using jboss 3.2.4 with j2sdk 1.4.2_05.

What could be wrong ?

Code for the test


  |         // Create a queue
  |         JmsSenderLocal sender = JmsSenderUtil.getLocalHome().create();
  |         Queue queue = 
JmsQueueManagerUtil.getLocalHome().create().getQueue("dummyQueue_0");
  |         
  |         // Post a message
  |         sender.send(new TextMessageCreator("dummyMessage_0"), queue, null, 
5000);
  |         
  |         // Sleep for at least 10 seconds
  |         sleep(10);
  | 
  |         // Get the message from the queue
  |         JmsReceiverLocal receiver = JmsReceiverUtil.getLocalHome().create();
  |         assertNull(receiver.receive(queue));
  | 

Sleep is a method calling thread.sleep()

The modified send method


  |     public void send(MessageCreator messageCreator, Queue queue, Date 
deliveryDate, long timeToLive) throws JMSException {
  |         if (logger.isDebugEnabled()) {
  |             logger.debug("Sending message [" + messageCreator + "] to queue 
[" + queue.getQueueName() + "]");
  |         }
  | 
  |         QueueConnection connection = null;
  |         QueueSession session = null;
  |         QueueSender sender = null;
  | 
  |         try {
  |             connection = openQueueConnection();
  |             session = connection.createQueueSession(false, 
QueueSession.AUTO_ACKNOWLEDGE);
  |             sender = session.createSender(queue);
  |             Message msg = messageCreator.getMessage(session);
  | 
  |             if (deliveryDate != null) {
  |                 logger.debug("Message will be delivered on 
["+deliveryDate+"]");
  |                 msg.setLongProperty("JMS_JBOSS_SCHEDULED_DELIVERY", 
deliveryDate.getTime());
  |             }
  |             
  |             if (timeToLive >= 0) {
  |                 msg.setJMSExpiration(System.currentTimeMillis() + 
timeToLive);
  |             }
  |             sender.send(msg);
  |         } finally {
  |             closeQueueSender(sender);
  |             closeSession(session);
  |             closeConnection(connection);
  |         }
  |     }
  | 

The message


  | SpyTextMessage {
  | Header { 
  |    jmsDestination  : QUEUE.dummyQueue_0
  |    jmsDeliveryMode : 2
  |    jmsExpiration   : 0
  |    jmsPriority     : 4
  |    jmsMessageID    : ID:8-11083781808063
  |    jmsTimeStamp    : 1108378180806
  |    jmsCorrelationID: null
  |    jmsReplyTo      : null
  |    jmsType         : null
  |    jmsRedelivered  : false
  |    jmsProperties   : {}
  |    jmsPropReadWrite: true
  |    msgReadOnly     : false
  |    producerClientId: ID:8
  | }
  | Body {
  |    text            :dummyMessage_0
  | }
  | }
  | 

If you need the log in trace mode just tell me and I will post it.

Regards,

Fred.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3866434#3866434

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3866434


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to