|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.extras.client.MuleClient
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 UMOEndpointURI 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 MuleManager.getInstance()
MuleEndpointURI
Field Summary | |
protected static Log |
logger
logger used by this class |
Constructor Summary | |
MuleClient()
Creates a default Mule client that will use the default serverEndpoint to connect to a remote server instance. |
|
MuleClient(boolean startManager)
Creates a default Mule client that will use the default serverEndpoint to connect to a remote server instance. |
|
MuleClient(String configResources)
Configures a Mule CLient instance using the the default MuleXmlConfigurationBuilder to parse the config resources |
|
MuleClient(String configResources,
ConfigurationBuilder builder)
Configures a Mule Client instance |
|
MuleClient(String configResources,
ConfigurationBuilder builder,
String user,
String password)
Configures a Mule Client instance |
|
MuleClient(String user,
String password)
Configures a new MuleClient and either uses an existing Manager running in this JVM or creates a new empty manager |
Method Summary | |
void |
dispatch(String url,
Object payload,
Map messageProperties)
Dispatches an event asynchronously to a endpointUri via a mule server. |
void |
dispatch(String url,
UMOMessage message)
Dispatches an event asynchronously to a endpointUri via a mule server. |
void |
dispatchDirect(String component,
Object payload,
Map messageProperties)
dispatches an event asynchronously to the components |
void |
dispatchDirect(String component,
UMOMessage message)
dispatches an event asynchronously to the components |
void |
dispatchStream(String url,
UMOStreamMessageAdapter message)
Dispatches a Stream event asynchronously to a endpointUri via a mule server. |
void |
dispose()
Will dispose the MuleManager instance *IF* a new instance was created for this client. |
MuleConfiguration |
getConfiguration()
|
protected UMOEndpoint |
getDefaultClientEndpoint(UMODescriptor descriptor,
Object payload)
|
protected UMOEndpoint |
getEndpoint(String uri,
String type)
|
protected UMOEvent |
getEvent(UMOMessage message,
String uri,
boolean synchronous,
boolean streaming)
Packages a mule event for the current request |
UMOManager |
getManager()
Overriding methods may want to return a custom manager here |
Object |
getProperty(Object key)
|
RemoteDispatcher |
getRemoteDispatcher(String serverEndpoint)
|
RemoteDispatcher |
getRemoteDispatcher(String serverEndpoint,
String user,
String password)
|
UMOMessage |
receive(String url,
long timeout)
Will receive an event from an endpointUri determined by the url |
UMOMessage |
receive(String url,
String transformers,
long timeout)
Will receive an event from an endpointUri determined by the url |
UMOMessage |
receive(String url,
UMOTransformer transformer,
long timeout)
Will receive an event from an endpointUri determined by the url |
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. |
void |
registerComponent(Object component,
String name,
UMOEndpointURI listenerEndpoint)
Registers a java object as a Umo pcomponent that listens for events on the given url. |
void |
registerComponent(UMODescriptor descriptor)
Registers a user configured MuleDescriptor of a components to the server. |
UMOMessage |
send(String url,
Object payload,
Map messageProperties)
Sends an event synchronously to a endpointUri via a mule server and a resulting message is returned. |
UMOMessage |
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. |
UMOMessage |
send(String url,
UMOMessage message)
Sends an event synchronously to a endpointUri via a mule server and a resulting message is returned. |
UMOMessage |
send(String url,
UMOMessage message,
int timeout)
Sends an event synchronously to a endpointUri via a mule server and a resulting message is returned. |
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. |
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. |
FutureMessageResult |
sendAsync(String url,
UMOMessage 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. |
FutureMessageResult |
sendAsync(String url,
UMOMessage 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. |
UMOMessage |
sendDirect(String component,
String transformers,
Object payload,
Map messageProperties)
sends an event synchronously to a components |
UMOMessage |
sendDirect(String component,
String transformers,
UMOMessage message)
sends an event synchronously to a components |
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. |
FutureMessageResult |
sendDirectAsync(String component,
String transformers,
UMOMessage 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. |
void |
sendNoReceive(String url,
Object payload,
Map messageProperties)
Sends an event synchronously to a endpointUri via a mule server without waiting for the result. |
UMOStreamMessageAdapter |
sendStream(String url,
UMOStreamMessageAdapter message)
|
UMOStreamMessageAdapter |
sendStream(String url,
UMOStreamMessageAdapter message,
int timeout)
Sends a streaming event synchronously to a endpointUri via a mule server and a resulting stream is set on the passed Stream Mesage Adapter. |
void |
setProperty(Object key,
Object value)
|
void |
unregisterComponent(String name)
Unregisters a previously register components. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Log logger
Constructor Detail |
public MuleClient() throws UMOException
UMOException
public MuleClient(boolean startManager) throws UMOException
startManager
- start the Mule Manager if it has not yet been initialised
UMOException
public MuleClient(String configResources) throws UMOException
configResources
- a config resource location to configure this client
with
ConfigurationException
- is there is a MuleManager instance already
running in this JVM or if the builder fails to configure the
Manager
UMOException
public MuleClient(String user, String password) throws UMOException
user
- the username to use when connecting to a remote server instancepassword
- the password for the user
UMOException
public MuleClient(String configResources, ConfigurationBuilder builder) throws ConfigurationException
configResources
- a config resource location to configure this client
withbuilder
- the configuration builder to use
ConfigurationException
- is there is a MuleManager instance already
running in this JVM or if the builder fails to configure the
Managerpublic MuleClient(String configResources, ConfigurationBuilder builder, String user, String password) throws ConfigurationException
configResources
- a config resource location to configure this client
withbuilder
- the configuration builder to useuser
- the username to use when connecting to a remote server instancepassword
- the password for the user
ConfigurationException
- is there is a MuleManager instance already
running in this JVM or if the builder fails to configure the
ManagerMethod Detail |
public void dispatch(String url, Object payload, Map messageProperties) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. In
the case of Jms you could set the JMSReplyTo property in these
properties.
UMOException
public void dispatch(String url, UMOMessage message) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagemessage
- the message to send
UMOException
public void dispatchStream(String url, UMOStreamMessageAdapter message) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagemessage
- the message to send
UMOException
public UMOStreamMessageAdapter sendStream(String url, UMOStreamMessageAdapter message) throws UMOException
UMOException
public UMOStreamMessageAdapter sendStream(String url, UMOStreamMessageAdapter message, int timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagemessage
- The message to sendtimeout
- The time in milliseconds the the call should block waiting for
a response
UMOException
public UMOMessage sendDirect(String component, String transformers, Object payload, Map messageProperties) throws UMOException
component
- the name of the Mule components to send totransformers
- a comma separated list of transformers to apply to the
result messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. as
null
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic UMOMessage sendDirect(String component, String transformers, UMOMessage message) throws UMOException
component
- the name of the Mule components to send totransformers
- a comma separated list of transformers to apply to the
result messagemessage
- the message to send
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic void dispatchDirect(String component, Object payload, Map messageProperties) throws UMOException
component
- the name of the Mule components to dispatch topayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. as
null
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic void dispatchDirect(String component, UMOMessage message) throws UMOException
component
- the name of the Mule components to dispatch tomessage
- the message to send
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, Object payload, Map messageProperties) throws UMOException
url
- the url to make a request onpayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. as
null
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, UMOMessage message) throws UMOException
url
- the url to make a request onmessage
- the message to send
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, Object payload, Map messageProperties, int timeout) throws UMOException
url
- the url to make a request onpayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. as
nulltimeout
- how long to block in milliseconds waiting for a result
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, UMOMessage message, int timeout) throws UMOException
url
- the url to make a request onmessage
- the message to sendtimeout
- how long to block in milliseconds waiting for a result
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendDirectAsync(String component, String transformers, Object payload, Map messageProperties) throws UMOException
component
- the name of the Mule components to send totransformers
- a comma separated list of transformers to apply to the
result messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. as
null
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendDirectAsync(String component, String transformers, UMOMessage message) throws UMOException
component
- the name of the Mule components to send totransformers
- a comma separated list of transformers to apply to the
result messagemessage
- the message to send
UMOException
- if the dispatch fails or the components or
transfromers cannot be foundpublic UMOMessage send(String url, Object payload, Map messageProperties) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. In
the case of Jms you could set the JMSReplyTo property in these
properties.
UMOException
public UMOMessage send(String url, UMOMessage message) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagemessage
- the Message for the event
UMOException
public UMOMessage send(String url, Object payload, Map messageProperties, int timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. In
the case of Jms you could set the JMSReplyTo property in these
properties.timeout
- The time in milliseconds the the call should block waiting for
a response
UMOException
public UMOMessage send(String url, UMOMessage message, int timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagemessage
- The message to sendtimeout
- The time in milliseconds the the call should block waiting for
a response
UMOException
public UMOMessage receive(String url, long timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagetimeout
- how long to block waiting to receive the event, if set to 0 the
receive will not wait at all and if set to -1 the receive will wait
forever
UMOException
public UMOMessage receive(String url, String transformers, long timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagetransformers
- A comma separated list of transformers used to apply to
the result messagetimeout
- how long to block waiting to receive the event, if set to 0 the
receive will not wait at all and if set to -1 the receive will wait
forever
UMOException
public UMOMessage receive(String url, UMOTransformer transformer, long timeout) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagetransformer
- A transformer used to apply to the result messagetimeout
- how long to block waiting to receive the event, if set to 0 the
receive will not wait at all and if set to -1 the receive will wait
forever
UMOException
protected UMOEvent getEvent(UMOMessage message, String uri, boolean synchronous, boolean streaming) throws UMOException
message
- the event payloaduri
- the destination endpointUrisynchronous
- whether the event will be synchronously processedstreaming
-
UMOException
protected UMOEndpoint getEndpoint(String uri, String type) throws UMOException
UMOException
protected UMOEndpoint getDefaultClientEndpoint(UMODescriptor descriptor, Object payload) throws UMOException
UMOException
public void sendNoReceive(String url, Object payload, Map messageProperties) throws UMOException
url
- the Mule url used to determine the destination and transport of the
messagepayload
- the object that is the payload of the eventmessageProperties
- any properties to be associated with the payload. In
the case of Jms you could set the JMSReplyTo property in these
properties.
UMOException
public UMOManager getManager()
public void registerComponent(Object component, String name, UMOEndpointURI listenerEndpoint) throws UMOException
component
- any java object, Mule will it's endpointUri discovery to
determine which event to invoke based on the evnet payload typename
- The identifying name of the components. This can be used to later
unregister itlistenerEndpoint
- The url endpointUri to listen to
UMOException
public void registerComponent(Object component, String name, MuleEndpointURI listenerEndpoint, MuleEndpointURI sendEndpoint) throws UMOException
component
- any java object, Mule will it's endpointUri discovery to
determine which event to invoke based on the evnet payload typename
- The identifying name of the components. This can be used to later
unregister itlistenerEndpoint
- The url endpointUri to listen tosendEndpoint
- The url endpointUri to dispatch to
UMOException
public void registerComponent(UMODescriptor descriptor) throws UMOException
MyBean implementation = new MyBean();
descriptor.setImplementationInstance(implementation);
Calling this method is equivilent to calling UMOModel.registerComponent(..)
descriptor
- the componet descriptor to register
UMOException
- the descriptor is invalid or cannot be initialised or
startedUMOModel
public void unregisterComponent(String name) throws UMOException
name
- the name of the componet to unregister
UMOException
- if unregistering the components fails, i.e. The
underlying transport fails to unregister a listener. If the
components does not exist, this method should not throw an
exception.UMOModel
public RemoteDispatcher getRemoteDispatcher(String serverEndpoint) throws UMOException
UMOException
public RemoteDispatcher getRemoteDispatcher(String serverEndpoint, String user, String password) throws UMOException
UMOException
public void dispose()
dispose
in interface Disposable
public void setProperty(Object key, Object value)
public Object getProperty(Object key)
public MuleConfiguration getConfiguration()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |