1 10 11 package org.mule.providers.jms; 12 13 import javax.jms.Message ; 14 import javax.resource.spi.work.Work ; 15 16 import org.mule.impl.MuleMessage; 17 import org.mule.umo.UMOComponent; 18 import org.mule.umo.endpoint.UMOEndpoint; 19 import org.mule.umo.lifecycle.InitialisationException; 20 import org.mule.umo.provider.UMOConnector; 21 import org.mule.umo.provider.UMOMessageAdapter; 22 23 27 public class JmsMessageReceiver extends SingleJmsMessageReceiver 28 { 29 30 public JmsMessageReceiver(UMOConnector connector, UMOComponent component, UMOEndpoint endpoint) 31 throws InitialisationException 32 { 33 super(connector, component, endpoint); 34 } 35 36 public void onMessage(Message message) 37 { 38 try 39 { 40 if (logger.isDebugEnabled()) 41 { 42 logger.debug("Message received of type: " + message.getClass().getName()); 43 if (message.getJMSDestination() != null) 44 { 45 logger.debug("Message received on " + message.getJMSDestination() + " (" 46 + message.getJMSDestination().getClass().getName() + ")"); 47 } 48 else 49 { 50 logger.debug("Message received on unknown destination"); 51 } 52 logger.debug("Message CorrelationId is: " + message.getJMSCorrelationID()); 53 logger.debug("Jms Message Id is: " + message.getJMSMessageID()); 54 } 55 56 if (message.getJMSRedelivered()) 57 { 58 if (logger.isDebugEnabled()) 59 { 60 logger.debug("Message with correlationId: " + message.getJMSCorrelationID() 61 + " has redelivered flag set, handing off to Exception Handler"); 62 } 63 redeliveryHandler.handleRedelivery(message); 64 } 65 getWorkManager().scheduleWork(new Worker(message)); 66 } 67 catch (Exception e) 68 { 69 handleException(e); 70 } 71 } 72 73 private class Worker implements Work 74 { 75 private Message message; 76 77 public Worker(Message message) 78 { 79 this.message = message; 80 } 81 82 87 public void run() 88 { 89 try 90 { 91 UMOMessageAdapter adapter = connector.getMessageAdapter(message); 92 routeMessage(new MuleMessage(adapter)); 93 } 94 catch (Exception e) 95 { 96 getConnector().handleException(e); 97 } 98 } 99 100 public void release() 101 { 102 } 104 } 105 } 106 | Popular Tags |