Version 4

    By default, JBossMQ silently removes expired JMS message from its destination. As of JBoss 4.0.4 and 3.2.8, 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:

     

      <mbean code="org.jboss.mq.server.jmx.Queue"
             name="jboss.mq.destination:service=Queue,name=D">
        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
        <depends optional-attribute-name="ExpiryDestination">jboss.mq.destination:service=Queue,name=ex</depends>
      </mbean>
    

     

    This is how the expiry destination is indicated when configured on the

    destination manager:

      <mbean code="org.jboss.mq.server.jmx.DestinationManager" name="jboss.mq:service=DestinationManager">
        <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache</depends>
        <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager</depends>
        <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager</depends>
        <depends optional-attribute-name="ExpiryDestination">jboss.mq.destination:service=Queue,name=ex</depends>
        <depends>jboss:service=Naming</depends>
      </mbean>
    

    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.