org.jboss.ejb.plugins.jms
Class DLQHandler

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ejb.plugins.jms.DLQHandler
All Implemented Interfaces:
MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class DLQHandler
extends ServiceMBeanSupport (src)

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. Created: Thu Aug 23 21:17:26 2001


Nested Class Summary
protected  class DLQHandler.DLQSynchronization (src)
          Remove a redelivered message from the DLQ's buffer when it is acknowledged
 
Field Summary
static java.lang.String JBOSS_ORIG_DESTINATION
          JMS property name holding original destination.
static java.lang.String JBOSS_ORIG_MESSAGEID
          JMS property name holding original JMS message id.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DLQHandler(JMSProviderAdapter (src)  providerAdapter)
           
 
Method Summary
protected  void createService()
          Initalize the service.
protected  void deleteFromBuffer(java.lang.String id)
          Delete the entry in the message counter buffer for specifyed JMS id.
protected  void destroyService()
          Sub-classes should override this method to provide custum 'destroy' logic.
 boolean handleRedeliveredMessage(Message (src)  msg, Transaction (src)  tx)
          Check if a message has been redelivered to many times.
 void importXml(org.w3c.dom.Element element)
          Takes an MDBConfig Element
protected  int incrementResentCount(java.lang.String id)
          Increment the counter for the specific JMS message id.
protected  Message (src) makeWritable(Message (src)  msg, boolean trace)
          Make the Message properties writable.
protected  void sendMessage(Message (src)  msg)
          Send message to the configured dead letter queue, defaults to queue/DLQ.
protected  void startService()
          Sub-classes should override this method to provide custum 'start' logic.
protected  void stopService()
          Sub-classes should override this method to provide custum 'stop' logic.
 java.lang.String toString()
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, 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 (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JBOSS_ORIG_DESTINATION

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

See Also:
Constant Field Values (src)

JBOSS_ORIG_MESSAGEID

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

See Also:
Constant Field Values (src)
Constructor Detail

DLQHandler

public DLQHandler(JMSProviderAdapter (src)  providerAdapter)
Method Detail

createService

protected void createService()
                      throws java.lang.Exception
Initalize the service.

Overrides:
createService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception - Service failed to initalize.

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'stop' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
stopService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

destroyService

protected void destroyService()
                       throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'destroy' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
destroyService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

handleRedeliveredMessage

public boolean handleRedeliveredMessage(Message (src)  msg,
                                        Transaction (src)  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(Message (src)  msg)
                    throws JMSException (src) 
Send message to the configured dead letter queue, defaults to queue/DLQ.

Throws:
JMSException (src)

incrementResentCount

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

Returns:
the new counter value.

deleteFromBuffer

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


makeWritable

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

Returns:
the writable message.
Throws:
JMSException (src)

importXml

public void importXml(org.w3c.dom.Element element)
               throws DeploymentException (src) 
Takes an MDBConfig Element

Throws:
DeploymentException (src)

toString

public java.lang.String toString()