public class MessageContext extends Object implements XMessageContext
XMessageContext API| Constructor and Description |
|---|
MessageContext(XMessage message) |
| Modifier and Type | Method and Description |
|---|---|
<P> void |
addContextProperty(String key,
P value)
Add a message property - i.e.
|
void |
addThrowable(Throwable t)
Add a
Throwable to the throwable stack of the message context |
void |
attachForRelease(AutoCloseable closeable)
Attach an instance of
AutoCloseable to be closed at the message context release stage |
XMessageContext |
cloneMessageContextWithFullMessage(ExchangePattern exchangePattern,
CompletionType completionType)
Creates a copyOf of this message context with the enclosed
XMessage instance and its payload. |
XMessageContext |
cloneMessageContextWithoutMessage(ExchangePattern exchangePattern,
CompletionType completionType)
Creates a copyOf of this message context without the enclosed
XMessage instance. |
XMessageContext |
cloneMessageContextWithoutPayload(ExchangePattern exchangePattern,
CompletionType completionType)
Creates a copyOf of this message context with the enclosed
XMessage instance. |
void |
completeMessageFlowSuccessfully()
This method should be invoked to indicate that the message flow related to this message context is completed
successfully
|
void |
completeMessageFlowWithException(Throwable throwable)
This method should be invoked to indicate that the message flow related to this message context is completed
with a failure
|
Optional<Throwable> |
getAndRemoveLastThrowable()
Retrieves the last
Throwable associated with this message context and removes it from the stack of
occurred throwables. |
CompletableFuture<XMessageContext> |
getAsyncResponseCompletionFuture()
Returns the asynchronous response future object
|
UUID |
getContextId() |
Map<String,Object> |
getContextProperties()
Return current message properties as an unmodifiable map
|
<P> Optional<P> |
getContextProperty(String key,
Class<P> cls)
Get the message property associated with the specified key as a typed object of type P
|
Optional<XScopeContext> |
getCurrentScopeContext() |
CompletableFuture<XMessage> |
getEgressFuture() |
ExchangePattern |
getExchangePattern() |
XFlowEventNotificationContext |
getFlowEventNotificationContext()
Retrieves the
XFlowEventNotificationContext associated with this context |
Optional<XIntegrationFlowTracer> |
getIntegrationFlowTracer() |
Optional<Throwable> |
getLastThrowable()
Retrieves the last
Throwable associated with this message context. |
XMessage |
getMessage() |
XMessageView |
getMessageView(int maxPayloadSizeKbs) |
XPlatform |
getPlatform() |
String |
getReceivedConnectorId()
Retrieves the ID of the
XIngressConnectorElement through which this
message context is received |
CompletableFuture<XMessageContext> |
getResponseFuture() |
List<XScopeContext> |
getScopeContextList() |
<T> Optional<T> |
getScopeVariable(String varKey,
Class<T> type,
boolean propagateToParent)
Retrieves the scope variable with the given key
|
Optional<String> |
getStringContextProperty(String key)
Get the String message property associated with the specified key
|
TransactionContext |
getTransactionContext() |
boolean |
hasContextProperty(String key)
Checks whether the given property is present in the message properties map
|
boolean |
isFailoverEnabled() |
boolean |
isMessageContextCompleted()
Whether this message context has been completed processing
|
boolean |
isMessageFlowCompleted()
Whether the message flow (to which this message context belongs) has been completed
|
boolean |
isResponseSubmitted() |
boolean |
isTimedOut()
Checks whether this message context is flagged as timed-out
|
void |
onCompletionOfAllSubBranches(BiConsumer<XMessageContext,Throwable> function) |
void |
onCompletionOfThisBranch(BiConsumer<XMessageContext,Throwable> function) |
void |
releaseResources()
Releases resources used by the message context at the end of it's life
|
void |
removeContextProperty(String key)
Remove the message property associated with the specified key
|
void |
removeCurrentScopeContext() |
void |
removeScopeVariable(String varKey,
boolean removeFromAllScopes)
Removes the scope variable with the given key
|
XMessage |
resetEnclosedMessage()
|
void |
sendResponse(int code,
boolean completeFlow) |
void |
sendResponse(int code,
XMessage responseMessage,
boolean completeFlow) |
void |
setAsTimedOut()
Flags this message context as timed-out.
|
void |
setAsyncResponseCompletionFuture(CompletableFuture<XMessageContext> asyncResponseCompletionFuture)
Sets a
CompletableFuture for message context as the asynchronous response future. |
void |
setCurrentScopeContext(XScopeContext scopeContext) |
void |
setEgressFuture(CompletableFuture<XMessage> egressFuture) |
void |
setExchangePattern(ExchangePattern exchangePattern) |
void |
setFailoverEnabled(boolean failoverEnabled) |
void |
setFlowCompletionFuture(CompletableFuture<XMessageContext> flowCompletionFuture) |
void |
setFlowEventNotificationContext(XFlowEventNotificationContext flowEventNotificationContext)
Sets the given
XFlowEventNotificationContext to this context |
void |
setMessage(XMessage message) |
void |
setPlatform(XPlatform platform) |
void |
setReceivedConnectorId(String receivedConnectorId)
Sets the ID of the
XIngressConnectorElement through which this message
context is received |
void |
setResponseFuture(CompletableFuture<XMessageContext> responseFuture) |
<T> void |
setScopeVariable(String varKey,
T varValue)
Adds a new variable to the current scope with the given key and value
|
void |
setTransactionContext(TransactionContext transactionContext) |
public MessageContext(XMessage message)
public UUID getContextId()
getContextId in interface XMessageContextpublic XMessage getMessage()
getMessage in interface XMessageContextpublic ExchangePattern getExchangePattern()
getExchangePattern in interface XMessageContextpublic void setMessage(XMessage message)
setMessage in interface XMessageContextpublic void setExchangePattern(ExchangePattern exchangePattern)
setExchangePattern in interface XMessageContextpublic void sendResponse(int code,
XMessage responseMessage,
boolean completeFlow)
sendResponse in interface XMessageContextpublic void sendResponse(int code,
boolean completeFlow)
sendResponse in interface XMessageContextpublic void setEgressFuture(CompletableFuture<XMessage> egressFuture)
setEgressFuture in interface XMessageContextpublic CompletableFuture<XMessage> getEgressFuture()
getEgressFuture in interface XMessageContextpublic XPlatform getPlatform()
getPlatform in interface XMessageContextpublic Optional<XIntegrationFlowTracer> getIntegrationFlowTracer()
getIntegrationFlowTracer in interface XMessageContextpublic XMessageView getMessageView(int maxPayloadSizeKbs)
getMessageView in interface XMessageContextpublic void setCurrentScopeContext(XScopeContext scopeContext)
setCurrentScopeContext in interface XMessageContextpublic Optional<XScopeContext> getCurrentScopeContext()
getCurrentScopeContext in interface XMessageContextpublic List<XScopeContext> getScopeContextList()
getScopeContextList in interface XMessageContextpublic void removeCurrentScopeContext()
removeCurrentScopeContext in interface XMessageContextpublic TransactionContext getTransactionContext()
getTransactionContext in interface XMessageContextpublic void setTransactionContext(TransactionContext transactionContext)
setTransactionContext in interface XMessageContextpublic CompletableFuture<XMessageContext> getResponseFuture()
public void setResponseFuture(CompletableFuture<XMessageContext> responseFuture)
setResponseFuture in interface XMessageContextpublic void setFlowCompletionFuture(CompletableFuture<XMessageContext> flowCompletionFuture)
public boolean isResponseSubmitted()
isResponseSubmitted in interface XMessageContextpublic void onCompletionOfThisBranch(BiConsumer<XMessageContext,Throwable> function)
onCompletionOfThisBranch in interface XMessageContextpublic void onCompletionOfAllSubBranches(BiConsumer<XMessageContext,Throwable> function)
onCompletionOfAllSubBranches in interface XMessageContextpublic boolean isFailoverEnabled()
isFailoverEnabled in interface XMessageContextpublic void setFailoverEnabled(boolean failoverEnabled)
setFailoverEnabled in interface XMessageContextpublic void setPlatform(XPlatform platform)
setPlatform in interface XMessageContextpublic XMessageContext cloneMessageContextWithFullMessage(ExchangePattern exchangePattern, CompletionType completionType)
XMessageContextXMessage instance and its payload.cloneMessageContextWithFullMessage in interface XMessageContextexchangePattern - ExchangePattern to be set for the new message context. If this is null, the
exchange pattern of the original context will be inheritedcompletionType - CompletionType to be used for this cloningpublic XMessageContext cloneMessageContextWithoutPayload(ExchangePattern exchangePattern, CompletionType completionType)
XMessageContextXMessage instance. But the payload of that
XMessage will not be cloned.cloneMessageContextWithoutPayload in interface XMessageContextexchangePattern - ExchangePattern to be set for the new message context. If this is null, the
exchange pattern of the original context will be inheritedcompletionType - CompletionType to be used for this cloningpublic XMessageContext cloneMessageContextWithoutMessage(ExchangePattern exchangePattern, CompletionType completionType)
XMessageContextXMessage instance.
A call to this method may follow invoking of XMessageContext.resetEnclosedMessage() method to assign a new instance of
XMessage as the context's messagecloneMessageContextWithoutMessage in interface XMessageContextexchangePattern - ExchangePattern to be set for the new message context. If this is null, the
exchange pattern of the original context will be inheritedcompletionType - CompletionType to be used for this cloningXMessageContext.resetEnclosedMessage()public void setAsyncResponseCompletionFuture(CompletableFuture<XMessageContext> asyncResponseCompletionFuture)
XMessageContextCompletableFuture for message context as the asynchronous response future. An asyncResponseCompletionFuture
can be used to mark the completion of a response when the response future (which is set using
XMessageContext.setResponseFuture(CompletableFuture)) is completed at the start point of the asynchronous response process.setAsyncResponseCompletionFuture in interface XMessageContextasyncResponseCompletionFuture - asynchronous response futurepublic CompletableFuture<XMessageContext> getAsyncResponseCompletionFuture()
XMessageContextgetAsyncResponseCompletionFuture in interface XMessageContextnull else.public void releaseResources()
XMessageContextreleaseResources in interface XMessageContextpublic <T> void setScopeVariable(String varKey, T varValue)
XMessageContextsetScopeVariable in interface XMessageContextT - type of the variable valuevarKey - String key of the variablevarValue - value of the variablepublic <T> Optional<T> getScopeVariable(String varKey, Class<T> type, boolean propagateToParent)
XMessageContextgetScopeVariable in interface XMessageContextT - type of the variablevarKey - key of the variabletype - expected type of the variablepropagateToParent - whether to propagate the search for the parent scopes, if a variable with the given key
is not found in the current scopeOptional of type T containing the variable if a variable with the given key is found and
value for that key is not null, Optional.EMPTY otherwisepublic void removeScopeVariable(String varKey, boolean removeFromAllScopes)
XMessageContextremoveScopeVariable in interface XMessageContextvarKey - key of the variableremoveFromAllScopes - whether to remove the variables with the given key from all scopespublic void completeMessageFlowSuccessfully()
XMessageContextcompleteMessageFlowSuccessfully in interface XMessageContextpublic void completeMessageFlowWithException(Throwable throwable)
XMessageContextcompleteMessageFlowWithException in interface XMessageContextthrowable - Throwable related to the failure of this message flowpublic XFlowEventNotificationContext getFlowEventNotificationContext()
XMessageContextXFlowEventNotificationContext associated with this contextgetFlowEventNotificationContext in interface XMessageContextXFlowEventNotificationContextpublic void setFlowEventNotificationContext(XFlowEventNotificationContext flowEventNotificationContext)
XMessageContextXFlowEventNotificationContext to this contextsetFlowEventNotificationContext in interface XMessageContextflowEventNotificationContext - XFlowEventNotificationContext instance to be setpublic boolean isTimedOut()
XMessageContextisTimedOut in interface XMessageContextpublic void setAsTimedOut()
XMessageContextsetAsTimedOut in interface XMessageContextpublic <P> void addContextProperty(String key, P value)
XMessageContextaddContextProperty in interface XMessageContextP - the type of the property value to be addedkey - property keyvalue - property valuepublic <P> Optional<P> getContextProperty(String key, Class<P> cls)
XMessageContextgetContextProperty in interface XMessageContextP - the type of the propertykey - the property keycls - the class of the property typepublic Optional<String> getStringContextProperty(String key)
XMessageContextgetStringContextProperty in interface XMessageContextkey - property keypublic void removeContextProperty(String key)
XMessageContextremoveContextProperty in interface XMessageContextkey - property keypublic boolean hasContextProperty(String key)
XMessageContexthasContextProperty in interface XMessageContextkey - the key to be checked for existencepublic Map<String,Object> getContextProperties()
XMessageContextgetContextProperties in interface XMessageContextpublic void setReceivedConnectorId(String receivedConnectorId)
XMessageContextXIngressConnectorElement through which this message
context is receivedsetReceivedConnectorId in interface XMessageContextreceivedConnectorId - ID of the received ingress connectorpublic String getReceivedConnectorId()
XMessageContextXIngressConnectorElement through which this
message context is receivedgetReceivedConnectorId in interface XMessageContextpublic void addThrowable(Throwable t)
XMessageContextThrowable to the throwable stack of the message contextaddThrowable in interface XMessageContextt - instance of Throwablepublic Optional<Throwable> getLastThrowable()
XMessageContextThrowable associated with this message context.
But it should be noted that this method will not remove the throwable from the stack of occurred throwables. To
remove the throwable after the retrieval, XMessageContext.getAndRemoveLastThrowable() method should be used.
getLastThrowable in interface XMessageContextOptional containing the last occurred Throwable if exists, or Optional.EMPTY
otherwisepublic Optional<Throwable> getAndRemoveLastThrowable()
XMessageContextThrowable associated with this message context and removes it from the stack of
occurred throwables.
To keep the last throwable on the stack of occurred throwables even after the retrieval,
XMessageContext.getLastThrowable() method should be used.
getAndRemoveLastThrowable in interface XMessageContextOptional containing the last occurred Throwable if exists, or Optional.EMPTY
otherwisepublic void attachForRelease(AutoCloseable closeable)
XMessageContextAutoCloseable to be closed at the message context release stageattachForRelease in interface XMessageContextcloseable - instance of AutoCloseable to be closedpublic boolean isMessageContextCompleted()
XMessageContextisMessageContextCompleted in interface XMessageContexttrue if completed, false otherwisepublic boolean isMessageFlowCompleted()
XMessageContextisMessageFlowCompleted in interface XMessageContexttrue if completed, false otherwisepublic XMessage resetEnclosedMessage()
XMessageContextresetEnclosedMessage in interface XMessageContextCopyright © 2016–2019 AdroitLogic. All rights reserved.