/** * Dispatches an event asynchronously to a endpointUri via a mule server. the Url determines where * to dispathc the event to, this can be in the form of * * @param url the Mule url used to determine the destination and transport of the message * @param payload the object that is the payload of the event * @param messageProperties any properties to be associated with the payload. In the case of Jms * you could set the JMSReplyTo property in these properties. * @throws org.mule.api.MuleException */ public void dispatch(String url, Object payload, Map messageProperties) throws MuleException { MuleMessage message = new DefaultMuleMessage(payload, messageProperties); MuleEvent event = getEvent(message, url, false); try { event.getSession().dispatchEvent(event); } catch (MuleException e) { throw e; } catch (Exception e) { throw new DispatchException( ClientMessages.failedToDispatchClientEvent(), event.getMessage(), event.getEndpoint(), e); } }
/** * Sends an object (payload) synchronous to the given url and returns a MuleMessage response back. * * @param url the Mule url used to determine the destination and transport of the message * @param payload the object that is the payload of the event * @param messageProperties any properties to be associated with the payload. In the case of Jms * you could set the JMSReplyTo property in these properties. * @return a umomessage response. * @throws org.mule.api.MuleException */ public MuleMessage send(String url, Object payload, Map messageProperties) throws MuleException { MuleMessage message = new DefaultMuleMessage(payload, messageProperties); MuleEvent event = getEvent(message, url, true); MuleMessage response; try { response = event.getSession().sendEvent(event); } catch (MuleException e) { throw e; } catch (Exception e) { throw new DispatchException( ClientMessages.failedToDispatchClientEvent(), event.getMessage(), event.getEndpoint(), e); } return response; }