[jboss-user] [Messaging, JMS & JBossMQ] - Re: Rerun DLQ messages?
rocken7
do-not-reply at jboss.com
Tue May 8 14:47:40 EDT 2007
So here is how to rerun expected messages from the DLQ. The close() calls are not perfect ...
And I coded up a JMX call to do this:
try
| {
| InitialContext ctx = new InitialContext();
| QueueConnection qc = TxsQueue.newConnection(ctx);
| Queue queue = TxsQueue.newQueue( ctx, "queue/DLQ" );
| QueueSession session = qc.createQueueSession(true, javax.jms.Session.AUTO_ACKNOWLEDGE);
| QueueReceiver qr = session.createReceiver(queue);
| qc.start();
|
| for( Message m = qr.receiveNoWait(); m != null; )
| {
| if( m instanceof ObjectMessage )
| {
| ObjectMessage om = (ObjectMessage) m;
| Object obj = om.getObject();
|
| if(obj instanceof BaseTaskMessage)
| {
| TxsQueue.send(Constants.MDB_TASKS, om.getObject());
| }
| else if( obj instanceof BaseEmailMessage )
| {
| TxsQueue.send(Constants.MDB_EMAIL, om.getObject());
| }
| }
|
| m = qr.receiveNoWait();
| }
|
| qr.close();
| session.close();
| qc.close();
| }
| catch(Exception e)
| {
| e.printStackTrace();
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044027#4044027
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044027
More information about the jboss-user
mailing list