org.jboss.ejb.plugins.jms
Class DLQHandler

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.ejb.plugins.jms.DLQHandler
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class DLQHandler
extends org.jboss.system.ServiceMBeanSupport
implements javax.jms.ExceptionListener

Places redeliveded messages on a Dead Letter Queue.

The Dead Letter Queue handler is used to not set JBoss in an endles loop when a message is resent on and on due to transaction rollback for message receipt.

It sends message to a dead letter queue (configurable, defaults to queue/DLQ) when the message has been resent a configurable amount of times, defaults to 10.

The handler is configured through the element MDBConfig in container-invoker-conf.

The JMS property JBOSS_ORIG_DESTINATION in the resent message is set to the name of the original destination (Destination.toString()) if it is present.

The JMS property JBOSS_ORIG_MESSAGEID in the resent message is set to the id of the original message.

Version:
$Revision: 57209 $
Author:
Jason Dillon, Scott.Stark@jboss.org, Adrian Brock

Nested Class Summary
protected  class DLQHandler.DLQSynchronization
          Remove a redelivered message from the DLQ's buffer when it is acknowledged
 
Field Summary
static String JBOSS_ORIG_DESTINATION
          JMS property name holding original destination.
static String JBOSS_ORIG_MESSAGEID
          JMS property name holding original JMS message id.
static String PROPERTY_DELIVERY_COUNT
          Standard property for delivery count
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DLQHandler(JMSProviderAdapter providerAdapter, JMSContainerInvoker invoker)
           
 
Method Summary
protected  void createService()
           
protected  void deleteFromBuffer(String id)
          Delete the entry in the message counter buffer for specifyed JMS id.
protected  void destroyService()
           
 boolean handleRedeliveredMessage(javax.jms.Message msg, Transaction tx)
          Check if a message has been redelivered to many times.
 void importXml(Element element)
          Takes an MDBConfig Element
protected  int incrementResentCount(String id)
          Increment the counter for the specific JMS message id.
protected  javax.jms.Message makeWritable(javax.jms.Message msg, boolean trace)
          Make the Message properties writable.
 void onException(javax.jms.JMSException e)
           
protected  void sendMessage(javax.jms.Message msg)
          Send message to the configured dead letter queue, defaults to queue/DLQ.
protected  void startService()
           
protected  void stopService()
           
 String toString()
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_DELIVERY_COUNT

public static final String PROPERTY_DELIVERY_COUNT
Standard property for delivery count

See Also:
Constant Field Values

JBOSS_ORIG_DESTINATION

public static final String JBOSS_ORIG_DESTINATION
JMS property name holding original destination.

See Also:
Constant Field Values

JBOSS_ORIG_MESSAGEID

public static final String JBOSS_ORIG_MESSAGEID
JMS property name holding original JMS message id.

See Also:
Constant Field Values
Constructor Detail

DLQHandler

public DLQHandler(JMSProviderAdapter providerAdapter,
                  JMSContainerInvoker invoker)
Method Detail

onException

public void onException(javax.jms.JMSException e)
Specified by:
onException in interface javax.jms.ExceptionListener

createService

protected void createService()
                      throws Exception
Overrides:
createService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

startService

protected void startService()
                     throws Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

destroyService

protected void destroyService()
                       throws Exception
Overrides:
destroyService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

handleRedeliveredMessage

public boolean handleRedeliveredMessage(javax.jms.Message msg,
                                        Transaction tx)
Check if a message has been redelivered to many times. If message has been redelivered to many times, send it to the dead letter queue (default to queue/DLQ).

Returns:
true if message is handled (i.e resent), false if not.

sendMessage

protected void sendMessage(javax.jms.Message msg)
                    throws javax.jms.JMSException
Send message to the configured dead letter queue, defaults to queue/DLQ.

Throws:
javax.jms.JMSException

incrementResentCount

protected int incrementResentCount(String id)
Increment the counter for the specific JMS message id.

Returns:
the new counter value.

deleteFromBuffer

protected void deleteFromBuffer(String id)
Delete the entry in the message counter buffer for specifyed JMS id.


makeWritable

protected javax.jms.Message makeWritable(javax.jms.Message msg,
                                         boolean trace)
                                  throws javax.jms.JMSException
Make the Message properties writable.

Returns:
the writable message.
Throws:
javax.jms.JMSException

importXml

public void importXml(Element element)
               throws org.jboss.deployment.DeploymentException
Takes an MDBConfig Element

Throws:
org.jboss.deployment.DeploymentException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.