| java.lang.Object org.mule.module.client.MuleClient
MuleClient | public class MuleClient implements Disposable(Code) | | MuleClient is a simple interface for Mule clients to send and
receive events from a Mule Server. In most Mule applications events are triggered
by some external occurrence such as a message being received on a queue or file
being copied to a directory. The Mule client allows the user to send and receive
events programmatically through its Api.
The client defines a EndpointURI which is used to determine how a message is
sent of received. The url defines the protocol, the endpointUri destination of the
message and optionally the endpoint to use when dispatching the event. For
example:
vm://my.object dispatches to a my.object destination
using the VM endpoint. There needs to be a global VM endpoint registered for the
message to be sent.
jms://jmsProvider/orders.topic dispatches a JMS message via the
globally registered jmsProvider over a topic destination called
orders.topic .
jms://orders.topic is equivalent to the above except that the
endpoint is determined by the protocol, so the first JMS endpoint is used.
Note that there must be a configured MuleManager for this client to work. It will
use the one available using muleContext
See Also: org.mule.endpoint.MuleEndpointURI |
Field Summary | |
final protected static Log | logger |
Method Summary | |
public void | dispatch(String url, Object payload, Map messageProperties) Dispatches an event asynchronously to a endpointUri via a mule server. | public void | dispatch(String url, MuleMessage message) Dispatches an event asynchronously to a endpointUri via a mule server. | public void | dispatchDirect(String component, Object payload, Map messageProperties) dispatches an event asynchronously to the components
Parameters: component - the name of the Mule components to dispatch to Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public void | dispatchDirect(String componentName, MuleMessage message) | public void | dispose() Will dispose the MuleManager instance *IF* a new instance was created for this
client. | public MuleConfiguration | getConfiguration() | protected ImmutableEndpoint | getDefaultClientEndpoint(Service service, Object payload) | protected MuleEvent | getEvent(MuleMessage message, String uri, boolean synchronous, boolean streaming) | protected InboundEndpoint | getInboundEndpoint(String uri) | public MuleContext | getMuleContext() | protected OutboundEndpoint | getOutboundEndpoint(String uri) | public Object | getProperty(String key) | public RemoteDispatcher | getRemoteDispatcher(String serverEndpoint) | public RemoteDispatcher | getRemoteDispatcher(String serverEndpoint, String user, String password) | public void | registerComponent(Object component, String name, EndpointURI listenerEndpoint) Registers a java object as a Umo pcomponent that listens for events on the
given url. | public void | registerComponent(Object component, String name, MuleEndpointURI listenerEndpoint, MuleEndpointURI sendEndpoint) Registers a java object as a Umo pcomponent that listens for and sends events
on the given urls. | public MuleMessage | request(String url, long timeout) | public MuleMessage | request(String url, String transformers, long timeout) | public MuleMessage | request(String url, List transformers, long timeout) | public MuleMessage | send(String url, Object payload, Map messageProperties) Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public MuleMessage | send(String url, MuleMessage message) Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned. | public MuleMessage | send(String url, Object payload, Map messageProperties, int timeout) Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public MuleMessage | send(String url, MuleMessage message, int timeout) Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned. | public FutureMessageResult | sendAsync(String url, Object payload, Map messageProperties) sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public FutureMessageResult | sendAsync(String url, MuleMessage message) sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code. | public FutureMessageResult | sendAsync(String url, Object payload, Map messageProperties, int timeout) sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public FutureMessageResult | sendAsync(String url, MuleMessage message, int timeout) sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code. | public MuleMessage | sendDirect(String component, String transformers, Object payload, Map messageProperties) sends an event synchronously to a components
Parameters: component - the name of the Mule components to send to Parameters: transformers - a comma separated list of transformers to apply to theresult message Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public MuleMessage | sendDirect(String componentName, String transformers, MuleMessage message) | public FutureMessageResult | sendDirectAsync(String component, String transformers, Object payload, Map messageProperties) sends an event to a components on a local Mule instance, while making the
result of the event trigger available as a Future result that can be accessed
later by client code. | public FutureMessageResult | sendDirectAsync(String component, String transformers, MuleMessage message) sends an event to a components on a local Mule instance, while making the
result of the event trigger available as a Future result that can be accessed
later by client code. | public void | sendNoReceive(String url, Object payload, Map messageProperties) Sends an event synchronously to a endpointUri via a mule server without
waiting for the result.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. | public void | setProperty(String key, Object value) | public void | unregisterComponent(String name) Unregisters a previously register components. |
logger | final protected static Log logger(Code) | | logger used by this class
|
MuleClient | public MuleClient() throws MuleException(Code) | | Creates a default Mule client that will use the default serverEndpoint to
connect to a remote server instance.
throws: MuleException - |
MuleClient | public MuleClient(String configResources) throws MuleException(Code) | | Configures a Mule CLient instance using the the default
MuleXmlConfigurationBuilder to parse the config resources
Parameters: configResources - a config resource location to configure this clientwith throws: ConfigurationException - is there is a MuleManager instance alreadyrunning in this JVM or if the builder fails to configure theManager |
MuleClient | public MuleClient(String user, String password) throws MuleException(Code) | | Configures a new MuleClient and either uses an existing Manager running in
this JVM or creates a new empty muleContext
Parameters: user - the username to use when connecting to a remote server instance Parameters: password - the password for the user throws: MuleException - |
dispatch | public void dispatch(String url, Object payload, Map messageProperties) throws MuleException(Code) | | 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
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. Inthe case of Jms you could set the JMSReplyTo property in theseproperties. throws: org.mule.api.MuleException - |
dispatch | public void dispatch(String url, MuleMessage message) throws MuleException(Code) | | 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
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: message - the message to send throws: org.mule.api.MuleException - |
dispatchDirect | public void dispatchDirect(String component, Object payload, Map messageProperties) throws MuleException(Code) | | dispatches an event asynchronously to the components
Parameters: component - the name of the Mule components to dispatch to Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. asnull throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
dispatchDirect | public void dispatchDirect(String componentName, MuleMessage message) throws MuleException(Code) | | dispatches an event asynchronously to the components
Parameters: componentName - the name of the Mule components to dispatch to Parameters: message - the message to send throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
dispose | public void dispose()(Code) | | Will dispose the MuleManager instance *IF* a new instance was created for this
client. Otherwise this method only cleans up resources no longer needed
|
getEvent | protected MuleEvent getEvent(MuleMessage message, String uri, boolean synchronous, boolean streaming) throws MuleException(Code) | | Packages a mule event for the current request
Parameters: message - the event payload Parameters: uri - the destination endpointUri Parameters: synchronous - whether the event will be synchronously processed Parameters: streaming - the MuleEvent throws: MuleException - |
getMuleContext | public MuleContext getMuleContext()(Code) | | Overriding methods may want to return a custom muleContext here
the UMOManager to use |
registerComponent | public void registerComponent(Object component, String name, EndpointURI listenerEndpoint) throws MuleException(Code) | | Registers a java object as a Umo pcomponent that listens for events on the
given url. By default the ThreadingProfile for the components will be set so
that there will only be one thread of execution.
Parameters: component - any java object, Mule will it's endpointUri discovery todetermine which event to invoke based on the evnet payload type Parameters: name - The identifying name of the components. This can be used to laterunregister it Parameters: listenerEndpoint - The url endpointUri to listen to throws: MuleException - |
registerComponent | public void registerComponent(Object component, String name, MuleEndpointURI listenerEndpoint, MuleEndpointURI sendEndpoint) throws MuleException(Code) | | Registers a java object as a Umo pcomponent that listens for and sends events
on the given urls. By default the ThreadingProfile for the components will be
set so that there will only be one thread of execution.
Parameters: component - any java object, Mule will it's endpointUri discovery todetermine which event to invoke based on the evnet payload type Parameters: name - The identifying name of the components. This can be used to laterunregister it Parameters: listenerEndpoint - The url endpointUri to listen to Parameters: sendEndpoint - The url endpointUri to dispatch to throws: MuleException - |
request | public MuleMessage request(String url, long timeout) throws MuleException(Code) | | Will receive an event from an endpointUri determined by the url
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: timeout - how long to block waiting to receive the event, if set to 0 thereceive will not wait at all and if set to -1 the receive will waitforever the message received or null if no message was received throws: org.mule.api.MuleException - |
request | public MuleMessage request(String url, String transformers, long timeout) throws MuleException(Code) | | Will receive an event from an endpointUri determined by the url
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: transformers - A comma separated list of transformers used to apply tothe result message Parameters: timeout - how long to block waiting to receive the event, if set to 0 thereceive will not wait at all and if set to -1 the receive will waitforever the message received or null if no message was received throws: org.mule.api.MuleException - |
request | public MuleMessage request(String url, List transformers, long timeout) throws MuleException(Code) | | Will receive an event from an endpointUri determined by the url
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: transformers - Transformers used to modify the result message Parameters: timeout - how long to block waiting to receive the event, if set to 0 thereceive will not wait at all and if set to -1 the receive will waitforever the message received or null if no message was received throws: org.mule.api.MuleException - |
send | public MuleMessage send(String url, Object payload, Map messageProperties) throws MuleException(Code) | | Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. Inthe case of Jms you could set the JMSReplyTo property in theseproperties. A return message, this could be null if the the components invokedexplicitly sets a return as null throws: org.mule.api.MuleException - |
send | public MuleMessage send(String url, MuleMessage message) throws MuleException(Code) | | Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: message - the Message for the event A return message, this could be null if the the components invokedexplicitly sets a return as null throws: org.mule.api.MuleException - |
send | public MuleMessage send(String url, Object payload, Map messageProperties, int timeout) throws MuleException(Code) | | Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. Inthe case of Jms you could set the JMSReplyTo property in theseproperties. Parameters: timeout - The time in milliseconds the the call should block waiting fora response A return message, this could be null if the the components invokedexplicitly sets a return as null throws: org.mule.api.MuleException - |
send | public MuleMessage send(String url, MuleMessage message, int timeout) throws MuleException(Code) | | Sends an event synchronously to a endpointUri via a mule server and a
resulting message is returned.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: message - The message to send Parameters: timeout - The time in milliseconds the the call should block waiting fora response A return message, this could be null if the the components invokedexplicitly sets a return as null throws: org.mule.api.MuleException - |
sendAsync | public FutureMessageResult sendAsync(String url, Object payload, Map messageProperties) throws MuleException(Code) | | sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. asnull the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendAsync | public FutureMessageResult sendAsync(String url, MuleMessage message) throws MuleException(Code) | | sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: message - the message to send the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendAsync | public FutureMessageResult sendAsync(String url, Object payload, Map messageProperties, int timeout) throws MuleException(Code) | | sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. asnull Parameters: timeout - how long to block in milliseconds waiting for a result the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendAsync | public FutureMessageResult sendAsync(String url, MuleMessage message, int timeout) throws MuleException(Code) | | sends an event request to a Url, making the result of the event trigger
available as a Future result that can be accessed later by client code.
Parameters: url - the url to make a request on Parameters: message - the message to send Parameters: timeout - how long to block in milliseconds waiting for a result the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendDirect | public MuleMessage sendDirect(String component, String transformers, Object payload, Map messageProperties) throws MuleException(Code) | | sends an event synchronously to a components
Parameters: component - the name of the Mule components to send to Parameters: transformers - a comma separated list of transformers to apply to theresult message Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. asnull the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendDirect | public MuleMessage sendDirect(String componentName, String transformers, MuleMessage message) throws MuleException(Code) | | sends an event synchronously to a components
Parameters: componentName - the name of the Mule components to send to Parameters: transformers - a comma separated list of transformers to apply to theresult message Parameters: message - the message to send the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendDirectAsync | public FutureMessageResult sendDirectAsync(String component, String transformers, Object payload, Map messageProperties) throws MuleException(Code) | | sends an event to a components on a local Mule instance, while making the
result of the event trigger available as a Future result that can be accessed
later by client code. If forwardDirectRequests flag s set and the components
is not found on the local Mule instance it will forward to a remote server.
Users can endpoint a url to a remote Mule server in the constructor of a Mule
client, by default the default Mule server url tcp://localhost:60504 is used.
Parameters: component - the name of the Mule components to send to Parameters: transformers - a comma separated list of transformers to apply to theresult message Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. asnull the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendDirectAsync | public FutureMessageResult sendDirectAsync(String component, String transformers, MuleMessage message) throws MuleException(Code) | | sends an event to a components on a local Mule instance, while making the
result of the event trigger available as a Future result that can be accessed
later by client code. If forwardDirectRequests flag s set and the components
is not found on the local Mule instance it will forward to a remote server.
Users can endpoint a url to a remote Mule server in the constructor of a Mule
client, by default the default Mule server url tcp://localhost:60504 is used.
Parameters: component - the name of the Mule components to send to Parameters: transformers - a comma separated list of transformers to apply to theresult message Parameters: message - the message to send the result message if any of the invocation throws: org.mule.api.MuleException - if the dispatch fails or the components ortransfromers cannot be found |
sendNoReceive | public void sendNoReceive(String url, Object payload, Map messageProperties) throws MuleException(Code) | | Sends an event synchronously to a endpointUri via a mule server without
waiting for the result.
Parameters: url - the Mule url used to determine the destination and transport of themessage Parameters: payload - the object that is the payload of the event Parameters: messageProperties - any properties to be associated with the payload. Inthe case of Jms you could set the JMSReplyTo property in theseproperties. throws: org.mule.api.MuleException - |
unregisterComponent | public void unregisterComponent(String name) throws MuleException(Code) | | Unregisters a previously register components. This will also unregister any
listeners for the components Calling this method is equivilent to calling
Model.unregisterComponent(..)
Parameters: name - the name of the componet to unregister throws: MuleException - if unregistering the components fails, i.e. Theunderlying transport fails to unregister a listener. If thecomponents does not exist, this method should not throw anexception. See Also: org.mule.api.model.Model |
|
|