org.apache.servicemix.eip.patterns
Class AsyncBridge
java.lang.Object
org.apache.servicemix.common.endpoints.AbstractEndpoint
org.apache.servicemix.common.endpoints.SimpleEndpoint
org.apache.servicemix.common.endpoints.ProviderEndpoint
org.apache.servicemix.eip.EIPEndpoint
org.apache.servicemix.eip.patterns.AsyncBridge
- All Implemented Interfaces:
- Endpoint
public class AsyncBridge
- extends EIPEndpoint
The async bridge pattern is used to bridge an In-Out exchange with two In-Only
(or Robust-In-Only) exchanges. This pattern is the opposite of the Pipeline.
The AsyncBridge uses a correlation identifier to be able to correlate the received
In-Out exchange, the In-Only sent as the request and the In-Only received as the response.
Defaults values are provided to configure those correlation ids. The default behavior
is to use the exchange id of the incoming In-Out exchange as the correlation id and set
it on the request exchange. The same property with the same value should be present on the
response exchange in order for the AsyncBridge to work. ServiceMix components usually take
care of propagating such properties, but failing to propagate it will result in errors.
- Author:
- gnodet
- See Also:
Pipeline
|
Field Summary |
static java.lang.String |
CORRID
|
|
Method Summary |
org.apache.servicemix.expression.Expression |
getRequestCorrId()
|
org.apache.servicemix.expression.Expression |
getResponseCorrId()
|
java.lang.String |
getResponseCorrIdProperty()
|
ExchangeTarget |
getTarget()
|
long |
getTimeout()
|
protected java.util.Date |
getTimeout(javax.jbi.messaging.MessageExchange exchange)
|
boolean |
isUseRobustInOnly()
|
protected void |
onTimeout(java.lang.String correlationId)
|
void |
process(javax.jbi.messaging.MessageExchange exchange)
|
protected void |
processAsync(javax.jbi.messaging.MessageExchange exchange)
|
protected void |
processSync(javax.jbi.messaging.MessageExchange exchange)
|
void |
setRequestCorrId(org.apache.servicemix.expression.Expression requestCorrId)
The expression used to compute the correlation id used to correlate the response and
the request. |
void |
setResponseCorrId(org.apache.servicemix.expression.Expression responseCorrId)
The expression used to compute the correlation id from the response exchange. |
void |
setResponseCorrIdProperty(java.lang.String responseCorrIdProperty)
Name of the property used by default to compute the correlation id on the response
exchange. |
void |
setTarget(ExchangeTarget target)
The target which will be used to send an In-Only or Robust-In-Only exchange to. |
void |
setTimeout(long timeout)
The timeout property controls the amount of time that the async bridge will wait for the response
after having sent the request. |
void |
setUseRobustInOnly(boolean useRobustInOnly)
Boolean flag to control if In-Only or Robust-In-Only exchange should be used
when sending the request. |
void |
start()
|
| Methods inherited from class org.apache.servicemix.eip.EIPEndpoint |
chooseFirstEndpointWithDescriptor, copyAttachments, copyProperties, getDefinition, getDefinitionFromDescription, getDefinitionFromWsdlExchangeTarget, getDefinitionFromWsdlResource, getDescription, getDescriptionForExchangeTarget, getEndpointsForExchangeTarget, getLockManager, getStore, getStoreFactory, getTimerManager, getWsdlExchangeTarget, getWsdlResource, setLockManager, setStore, setStoreFactory, setTimerManager, setWsdlExchangeTarget, setWsdlResource, stop |
| Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint |
getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString, validate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CORRID
public static final java.lang.String CORRID
- See Also:
- Constant Field Values
AsyncBridge
public AsyncBridge()
getTimeout
public long getTimeout()
- Returns:
- the timeout
setTimeout
public void setTimeout(long timeout)
- The timeout property controls the amount of time that the async bridge will wait for the response
after having sent the request. The default value is 0 which means that no timeout apply. If set
to a non zero value, a timer will be started when after the request is sent. When the timer
expires, the In-Out exchange will be sent back with an error status and a
TimeoutException as the cause of the error.
The value represents the number of milliseconds to wait.
- Parameters:
timeout - the timeout to set
getTarget
public ExchangeTarget getTarget()
- Returns:
- the target
setTarget
public void setTarget(ExchangeTarget target)
- The target which will be used to send an In-Only or Robust-In-Only exchange to.
When receiving an In-Out exchange, the async bridge will create an In-Only request
and send it to the specified target. It then expects another In-Only exchange to
come back as the response, which will be set as the Out message on the In-Out exchange.
This property is mandatory and must be set to a valid target.
- Parameters:
target - the target to set
getRequestCorrId
public org.apache.servicemix.expression.Expression getRequestCorrId()
- Returns:
- the requestCorrId
setRequestCorrId
public void setRequestCorrId(org.apache.servicemix.expression.Expression requestCorrId)
- The expression used to compute the correlation id used to correlate the response and
the request. The default behavior is to use the exchange id of the incoming In-Out
exchange as the correlation id.
- Parameters:
requestCorrId - the requestCorrId to set- See Also:
setResponseCorrId(org.apache.servicemix.expression.Expression),
setResponseCorrIdProperty(String)
getResponseCorrIdProperty
public java.lang.String getResponseCorrIdProperty()
- Returns:
- the responseCorrIdProperty
setResponseCorrIdProperty
public void setResponseCorrIdProperty(java.lang.String responseCorrIdProperty)
- Name of the property used by default to compute the correlation id on the response
exchange.
- Parameters:
responseCorrIdProperty - the responseCorrIdProperty to set- See Also:
setRequestCorrId(org.apache.servicemix.expression.Expression),
setResponseCorrId(org.apache.servicemix.expression.Expression)
getResponseCorrId
public org.apache.servicemix.expression.Expression getResponseCorrId()
- Returns:
- the responseCorrId
setResponseCorrId
public void setResponseCorrId(org.apache.servicemix.expression.Expression responseCorrId)
- The expression used to compute the correlation id from the response exchange.
The value computed by this expression must match the one from the
setRequestCorrId(org.apache.servicemix.expression.Expression)
expression. The default value is null, but if no specific expression is configured,
an expression will be created which will extract the response correlation id from the
setResponseCorrIdProperty(String) property on the exchange.
- Parameters:
responseCorrId - the responseCorrId to set- See Also:
setResponseCorrIdProperty(String),
setRequestCorrId(org.apache.servicemix.expression.Expression)
isUseRobustInOnly
public boolean isUseRobustInOnly()
- Returns:
- the useRobustInOnly
setUseRobustInOnly
public void setUseRobustInOnly(boolean useRobustInOnly)
- Boolean flag to control if In-Only or Robust-In-Only exchange should be used
when sending the request. The default value is
false which means
that an In-Only exchange will be used. When using a Robust-In-Only exchange and
when a fault is received, this fault will be sent back to the consumer on the In-Out
exchange and the response exchange (if any) would be discarded.
For both In-Only and Robust-In-Only, if the request exchange comes back with an Error
status, this error will be conveyed back to the consumer in the same way.
- Parameters:
useRobustInOnly - the useRobustInOnly to set
start
public void start()
throws java.lang.Exception
- Specified by:
start in interface Endpoint- Overrides:
start in class EIPEndpoint
- Throws:
java.lang.Exception
processSync
protected void processSync(javax.jbi.messaging.MessageExchange exchange)
throws java.lang.Exception
- Specified by:
processSync in class EIPEndpoint
- Throws:
java.lang.Exception
processAsync
protected void processAsync(javax.jbi.messaging.MessageExchange exchange)
throws java.lang.Exception
- Specified by:
processAsync in class EIPEndpoint
- Throws:
java.lang.Exception
process
public void process(javax.jbi.messaging.MessageExchange exchange)
throws java.lang.Exception
- Specified by:
process in interface Endpoint- Overrides:
process in class EIPEndpoint
- Throws:
java.lang.Exception
onTimeout
protected void onTimeout(java.lang.String correlationId)
getTimeout
protected java.util.Date getTimeout(javax.jbi.messaging.MessageExchange exchange)
Copyright © 2005-2011 FuseSource. All Rights Reserved.