dcsimg
Implement hook on application server shutdown to avoid processing queues
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   nuka_teodor
Posted On:   Thursday, October 26, 2006 08:42 AM

Hello,

I am using Jboss for a JMs application. We have 2 MDB listening on queues (one of them is a persistent queue).
When we stop with the shutdown call the JBoss server, in the case of a graceful shutdown, we want to control the shutdown of queues and avoid duplication on message processing by implementing a hook in the shutdown
(i.e Stop all listeners that are currently taking messages from the queues).

I don't kow how to implement this issue,

thanks for help,

rgds,

Nuka

Re: Implement hook on application server shutdown to avoid processing queues

Posted By:   WarnerJan_Veldhuis  
Posted On:   Thursday, October 26, 2006 04:19 PM

Create an MBean and deploy that in a seperate .sar file in the deploy directory, with a jboss-service.xml (A .sar is just a .jar, with an 's'). I just happen to have made this, so enjoy...

The MBean interface

public interface ShutdownMonitorMBean {

/**
* Fired when the MBean is created
* @throws Exception
*/
public void create() throws Exception;

/**
* Fired when the MBean is started
* @throws Exception
*/
public void start() throws Exception;

/**
* Fired when the MBean is stopped
*/
public void stop();

/**
* Fired when the MBean is destroyed
*/
public void destroy();

}


The MBean implementation (some methods left out for clarity)


/**
* The ShutdownMonitor will send a message to all the connected clients if the applications server has gone down.
* This MBean should be packaged in a separate SAR-archive, and dropped in the deploy directory
*/
public class ShutdownMonitor implements ShutdownMonitorMBean {
/**
* All MBeans require a default constructor
*/
public ShutdownMonitor() {
}

/**
* Fired when the MBean is created
*
* @throws Exception
*/
public void create() throws Exception {

}

/**
* Fired when the MBean is destroyed
*/
public void destroy() {

}

/**
* Fired when the MBean is started
*
* @throws Exception
*/
public void start() throws Exception {
started = true;
}

/**
* Fired when the MBean is stopped
*/
public void stop() {
if ( started ) {
//here you shutdown something else
started = false;
}
}


}



The jboss-service.xml






jboss:service=Naming
jboss.mq:service=DestinationManager jboss.mq.destination:service=Topic,name=mytopic




About | Sitemap | Contact