|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.module.client.MuleClient
public class 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 a 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
MuleEndpointURI
Field Summary | |
---|---|
protected static Log |
logger
logger used by this class |
Fields inherited from interface org.mule.api.lifecycle.Disposable |
---|
PHASE_NAME |
Constructor Summary | |
---|---|
protected |
MuleClient()
Creates a Mule client that will use the default serverEndpoint when connecting to a remote server instance. |
|
MuleClient(boolean startContext)
|
|
MuleClient(MuleContext context)
|
|
MuleClient(String configResources)
Configures a Mule client instance using the the default SpringXmlConfigurationBuilder to parse configResources . |
|
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 Mule client and either uses an existing Manager running in this JVM or creates a new empty MuleContext |
Method Summary | |
---|---|
void |
dispatch(String url,
MuleMessage message)
Dispatches an event asynchronously to a endpointUri via a Mule server. |
void |
dispatch(String url,
Object payload,
Map messageProperties)
Dispatches an event asynchronously to a endpointUri via a Mule server. |
void |
dispatchDirect(String componentName,
MuleMessage message)
Dispatches an event asynchronously to a component |
void |
dispatchDirect(String component,
Object payload,
Map messageProperties)
Dispatches an event asynchronously to a component |
void |
dispose()
Will dispose the MuleManager instance if a new instance was created for this client. |
MuleConfiguration |
getConfiguration()
|
protected InboundEndpoint |
getDefaultClientEndpoint(Service service,
Object payload,
boolean sync)
|
protected MuleEvent |
getEvent(MuleMessage message,
MessageExchangePattern exchangePattern)
|
protected InboundEndpoint |
getInboundEndpoint(String uri)
|
MuleContext |
getMuleContext()
The overriding method may want to return a custom MuleContext here |
protected OutboundEndpoint |
getOutboundEndpoint(String uri,
MessageExchangePattern exchangePattern,
Integer responseTimeout)
|
Object |
getProperty(String key)
|
RemoteDispatcher |
getRemoteDispatcher(String serverEndpoint)
|
RemoteDispatcher |
getRemoteDispatcher(String serverEndpoint,
String user,
String password)
|
void |
registerComponent(Object component,
String name,
EndpointURI listenerEndpoint)
Deprecated. Use the RegistryContext to get the registry and register the service there |
void |
registerComponent(Object component,
String name,
MuleEndpointURI listenerEndpoint,
MuleEndpointURI sendEndpoint)
Deprecated. Use the RegistryContext to get the registry and register the service there |
MuleMessage |
request(String url,
List transformers,
long timeout)
Will receive an event from an endpointUri determined by the URL |
MuleMessage |
request(String url,
long timeout)
Will receive an event from an endpointUri determined by the URL. |
MuleMessage |
request(String url,
String transformers,
long timeout)
Will receive an event from an endpointUri determined by the URL |
MuleMessage |
send(String url,
MuleMessage message)
Sends an event synchronously to a endpointUri via a Mule server and a resulting message is returned. |
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. |
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. |
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. |
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. |
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. |
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. |
MuleMessage |
sendDirect(String componentName,
String transformers,
MuleMessage message)
Sends an event synchronously to a component |
MuleMessage |
sendDirect(String component,
String transformers,
Object payload,
Map messageProperties)
Sends an event synchronously to a component |
FutureMessageResult |
sendDirectAsync(String component,
String transformers,
MuleMessage message)
Snds an event to a component 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,
Object payload,
Map messageProperties)
Sends an event to a component 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<String,Object> messageProperties)
Sends an event synchronously to a endpointUri via a Mule server without waiting for the result. |
void |
setProperty(String key,
Object value)
|
void |
unregisterComponent(String name)
Deprecated. Use the RegistryContext to get the registry and unregister the service there |
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 |
---|
protected MuleClient() throws MuleException
MuleException
public MuleClient(boolean startContext) throws MuleException
MuleException
public MuleClient(MuleContext context) throws MuleException
MuleException
public MuleClient(String configResources) throws MuleException
SpringXmlConfigurationBuilder
to parse configResources
.
configResources
- a config resource location to configure this client
with
ConfigurationException
- if there is a MuleContext
instance already
running in this JVM or if the builder fails to configure the
Manager
MuleException
public MuleClient(String user, String password) throws MuleException
MuleContext
user
- the username to use when connecting to a remote server instancepassword
- the password for the user
MuleException
public MuleClient(String configResources, ConfigurationBuilder builder) throws ConfigurationException, InitialisationException
configResources
- a config resource location to configure this client
withbuilder
- the configuration builder to use
ConfigurationException
- is there is a MuleContext
instance already
running in this JVM or if the builder fails to configure the
Manager
InitialisationException
public MuleClient(String configResources, ConfigurationBuilder builder, String user, String password) throws ConfigurationException, InitialisationException
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 MuleContext
instance already
running in this JVM or if the builder fails to configure the
Manager
InitialisationException
Method Detail |
---|
public void dispatch(String url, Object payload, Map messageProperties) throws MuleException
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.
MuleException
public void dispatch(String url, MuleMessage message) throws MuleException
url
- the Mule URL used to determine the destination and transport of the
messagemessage
- the message to send
MuleException
public MuleMessage sendDirect(String component, String transformers, Object payload, Map messageProperties) throws MuleException
component
- the name of the Mule component 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
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic MuleMessage sendDirect(String componentName, String transformers, MuleMessage message) throws MuleException
componentName
- the name of the Mule component to send totransformers
- a comma separated list of transformers to apply to the
result messagemessage
- the message to send
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic void dispatchDirect(String component, Object payload, Map messageProperties) throws MuleException
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
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic void dispatchDirect(String componentName, MuleMessage message) throws MuleException
componentName
- the name of the Mule components to dispatch tomessage
- the message to send
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, Object payload, Map messageProperties) throws MuleException
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
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, MuleMessage message) throws MuleException
url
- the URL to make a request onmessage
- the message to send
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, Object payload, Map messageProperties, int timeout) throws MuleException
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
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendAsync(String url, MuleMessage message, int timeout) throws MuleException
url
- the url to make a request onmessage
- the message to sendtimeout
- how long to block in milliseconds waiting for a result
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendDirectAsync(String component, String transformers, Object payload, Map messageProperties) throws MuleException
tcp://localhost:60504
is used.
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.
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic FutureMessageResult sendDirectAsync(String component, String transformers, MuleMessage message) throws MuleException
tcp://localhost:60504
is used.
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
MuleException
- if the dispatch fails or the components or
transfromers cannot be foundpublic MuleMessage send(String url, Object payload, Map messageProperties) throws MuleException
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.
null
if the the components invoked
explicitly sets a return as null
.
MuleException
public MuleMessage send(String url, MuleMessage message) throws MuleException
url
- the Mule URL used to determine the destination and transport of the
messagemessage
- the Message for the event
null
if the the components invoked
explicitly sets a return as null
.
MuleException
public MuleMessage send(String url, Object payload, Map messageProperties, int timeout) throws MuleException
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
null
if the the components invoked
explicitly sets a return as null
.
MuleException
public MuleMessage send(String url, MuleMessage message, int timeout) throws MuleException
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
null
if the the components invoked
explicitly sets a return as null
.
MuleException
public MuleMessage request(String url, long timeout) throws MuleException
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
null
if no message was received
MuleException
public MuleMessage request(String url, String transformers, long timeout) throws MuleException
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
null
if no message was received
MuleException
public MuleMessage request(String url, List transformers, long timeout) throws MuleException
url
- the Mule URL used to determine the destination and transport of the
messagetransformers
- Transformers used to modify 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
null
if no message was received
MuleException
protected MuleEvent getEvent(MuleMessage message, MessageExchangePattern exchangePattern) throws MuleException
MuleException
protected InboundEndpoint getInboundEndpoint(String uri) throws MuleException
MuleException
protected OutboundEndpoint getOutboundEndpoint(String uri, MessageExchangePattern exchangePattern, Integer responseTimeout) throws MuleException
MuleException
protected InboundEndpoint getDefaultClientEndpoint(Service service, Object payload, boolean sync) throws MuleException
MuleException
public void sendNoReceive(String url, Object payload, Map<String,Object> messageProperties) throws MuleException
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.
MuleException
public MuleContext getMuleContext()
MuleContext
here
@Deprecated public void registerComponent(Object component, String name, EndpointURI listenerEndpoint) throws MuleException
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
MuleException
@Deprecated public void registerComponent(Object component, String name, MuleEndpointURI listenerEndpoint, MuleEndpointURI sendEndpoint) throws MuleException
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
MuleException
@Deprecated public void unregisterComponent(String name) throws MuleException
name
- the name of the componet to unregister
MuleException
- 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.Model
public RemoteDispatcher getRemoteDispatcher(String serverEndpoint) throws MuleException
MuleException
public RemoteDispatcher getRemoteDispatcher(String serverEndpoint, String user, String password) throws MuleException
MuleException
public void dispose()
dispose
in interface Disposable
public void setProperty(String key, Object value)
public Object getProperty(String key)
public MuleConfiguration getConfiguration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |