1 10 11 package org.mule.providers.jbi.components; 12 13 import org.mule.impl.MuleEvent; 14 import org.mule.impl.MuleSession; 15 import org.mule.providers.AbstractConnector; 16 import org.mule.providers.jbi.JbiUtils; 17 import org.mule.umo.UMOEvent; 18 import org.mule.umo.UMOMessage; 19 import org.mule.umo.provider.UMOMessageDispatcher; 20 21 import javax.jbi.messaging.MessageExchange; 22 import javax.jbi.messaging.MessagingException; 23 import javax.jbi.messaging.NormalizedMessage; 24 25 33 public class MuleDispatcher extends AbstractEndpointComponent implements MessageExchangeListener 34 { 35 36 public void onExchange(MessageExchange messageExchange) throws MessagingException 37 { 38 if (logger.isDebugEnabled()) 39 { 40 logger.debug("In Mule Dispatcher"); 41 } 42 try 43 { 44 UMOMessageDispatcher dispatcher = muleEndpoint.getConnector().getDispatcher(muleEndpoint); 45 NormalizedMessage out = messageExchange.getMessage(IN); 46 UMOMessage message = JbiUtils.createMessage(out); 47 if (logger.isDebugEnabled()) 48 { 49 logger.debug("Dispatching Message via Mule: " + message); 50 } 51 MuleSession session = new MuleSession(message, 52 ((AbstractConnector)muleEndpoint.getConnector()).getSessionHandler()); 53 54 UMOEvent event = new MuleEvent(message, muleEndpoint, session, muleEndpoint.isSynchronous()); 55 if (muleEndpoint.isSynchronous()) 56 { 57 logger.debug("Dispatching to: " + muleEndpoint.getEndpointURI()); 58 logger.debug("Payload is: " + event.getMessageAsString()); 59 60 UMOMessage result = dispatcher.send(event); 61 } 63 else 64 { 65 dispatcher.dispatch(event); 66 } 67 } 68 catch (Exception e) 69 { 70 handleException(e); 71 error(messageExchange, e); 72 } 73 } 74 } 75 | Popular Tags |