By default, JBossMQ silently removes expired JMS message from its destination.
As of JBoss 4.0.4, expired messages can now be moved into a separate
destination.
There are two ways to configure this feature: Either per Queue or Topic or by
DestinationManager MBean. If set on the DestinationManager, every Queue and Topic
by default will use the configured expiry destination.
The MBean attribute ExpiryDestination indicates the javax.management.ObjectName
of the expiry destination. This destination must be located on the same server
and be a JBossMQ destination.
In this example jboss-service.xml configuration, expired messages on queue "D"
will be moved to the "ex" queue:
jboss.mq:service=DestinationManager
jboss.mq.destination:service=Queue,name=ex
This is how the expiry destination is indicated when configured on the
destination manager:
jboss.mq:service=MessageCache
jboss.mq:service=PersistenceManager
jboss.mq:service=StateManager
jboss.mq.destination:service=Queue,name=ex
jboss:service=Naming
Once moved, messages can be processed using a simple javax.jms.MessageConsumer
or a MDB. The original destination is indicated by the javax.jms.Message
property "JBOSS_ORIG_DESTINATION" and the time of expiration is indicated with
"JBOSS_ORIG_EXPIRATION". These constants are defined in
org.jboss.mq.SpyMessage. The destination is a String property set to the value
of Message.getJMSDestination().toString() and expiration time is indicated as a
Long property set from Message.getJMSExpiration().
The expiry destination cannot be changed when the queue or topic is active.
Errors: If the expiry destination is unavailable or an error occurs during the
move (such as org.jboss.mq.DestinationFullException), the expired message will
disappear from the server until the destination is restarted.