Why are NON_PERSISTENT messages kept in queue?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrea_Gambirasio
Posted On:   Tuesday, February 24, 2004 05:45 AM

Hi all, We implemented a producer-consumer system and we want the follwing behaviour: We send a message on a queue on which we know a consumer is listening. We want the message to be consumed by the consumer and to be erased in the queue: in addition to this we want the message not to stay in the queue even if the consumer is not there. We set the queue parameters to cachesize = 500 cleanup interval = 120000 max messages = -1 queue persistence = as message And the message params to JMSDeliveryMode = NON_PERSISTENT JMSDestination = queryqueue@router1 JMSExpiration = 0 JMSRedelivered = false    More>>

Hi all,

We implemented a producer-consumer system and we want the follwing behaviour:

We send a message on a queue on which we know a consumer is listening.
We want the message to be consumed by the consumer and to be erased in the queue: in addition to this we want the message not to stay in the queue even if the consumer is not there.


We set the queue parameters to


  • cachesize = 500

  • cleanup interval = 120000

  • max messages = -1

  • queue persistence = as message


And the message params to

  • JMSDeliveryMode = NON_PERSISTENT

  • JMSDestination = queryqueue@router1

  • JMSExpiration = 0

  • JMSRedelivered = false

  • JMSType = QueryMessage



The (unwanted) effect that we have is that the queue keeps all the messages, with an obvious consequent growth of the used memory.

What's the correct way to instruct a queue not to retain messages?

thanks

   <<Less

Re: Why are NON_PERSISTENT messages kept in queue?

Posted By:   Andreas_Mueller  
Posted On:   Tuesday, February 24, 2004 06:00 AM

The only way to remove messages from a queue is by consuming it or when the message expires. What you have to do is to set the message time-to-live (either via the connection factory as a default or by calling your producers setTimeToLive(long) or by specifying the ttl as a parameter of your send method; don't set it directly in the message since it will be overwritten with the default as per JMS spec). The cleanup interval of 120000 will remove expired messages every 2 minutes from the queue.


Read this doc chapter, please.


The setting of PERSISTENT/NON_PERSISTENT is a quality-of-service. Persistent messages are stored on disk and survive reboots. Non-persistent messages are not stored on disk (execpt for swapping) and don't survive reboots.
About | Sitemap | Contact