public class MessageContext extends Object implements XMessageContext
XMessageContext
APIConstructor 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 |
attachForRelease(AutoCloseable closeable) |
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
|
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() |
XMessage |
getMessage() |
XMessageView |
getMessageView(int maxPayloadSizeKbs) |
XPlatform |
getPlatform() |
String |
getReceivedConnectorId() |
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() |
boolean |
isMessageFlowCompleted() |
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
|
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) |
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 XMessageContext
public XMessage getMessage()
getMessage
in interface XMessageContext
public ExchangePattern getExchangePattern()
getExchangePattern
in interface XMessageContext
public void setMessage(XMessage message)
setMessage
in interface XMessageContext
public void setExchangePattern(ExchangePattern exchangePattern)
setExchangePattern
in interface XMessageContext
public void sendResponse(int code, XMessage responseMessage, boolean completeFlow)
sendResponse
in interface XMessageContext
public void sendResponse(int code, boolean completeFlow)
sendResponse
in interface XMessageContext
public void setEgressFuture(CompletableFuture<XMessage> egressFuture)
setEgressFuture
in interface XMessageContext
public CompletableFuture<XMessage> getEgressFuture()
getEgressFuture
in interface XMessageContext
public XPlatform getPlatform()
getPlatform
in interface XMessageContext
public Optional<XIntegrationFlowTracer> getIntegrationFlowTracer()
getIntegrationFlowTracer
in interface XMessageContext
public XMessageView getMessageView(int maxPayloadSizeKbs)
getMessageView
in interface XMessageContext
public void setCurrentScopeContext(XScopeContext scopeContext)
setCurrentScopeContext
in interface XMessageContext
public Optional<XScopeContext> getCurrentScopeContext()
getCurrentScopeContext
in interface XMessageContext
public List<XScopeContext> getScopeContextList()
getScopeContextList
in interface XMessageContext
public void removeCurrentScopeContext()
removeCurrentScopeContext
in interface XMessageContext
public TransactionContext getTransactionContext()
getTransactionContext
in interface XMessageContext
public void setTransactionContext(TransactionContext transactionContext)
setTransactionContext
in interface XMessageContext
public CompletableFuture<XMessageContext> getResponseFuture()
public void setResponseFuture(CompletableFuture<XMessageContext> responseFuture)
setResponseFuture
in interface XMessageContext
public void setFlowCompletionFuture(CompletableFuture<XMessageContext> flowCompletionFuture)
public boolean isResponseSubmitted()
isResponseSubmitted
in interface XMessageContext
public void onCompletionOfThisBranch(BiConsumer<XMessageContext,Throwable> function)
onCompletionOfThisBranch
in interface XMessageContext
public void onCompletionOfAllSubBranches(BiConsumer<XMessageContext,Throwable> function)
onCompletionOfAllSubBranches
in interface XMessageContext
public boolean isFailoverEnabled()
isFailoverEnabled
in interface XMessageContext
public void setFailoverEnabled(boolean failoverEnabled)
setFailoverEnabled
in interface XMessageContext
public void setPlatform(XPlatform platform)
setPlatform
in interface XMessageContext
public XMessageContext cloneMessageContextWithFullMessage(ExchangePattern exchangePattern, CompletionType completionType)
XMessageContext
XMessage
instance and its payload.cloneMessageContextWithFullMessage
in interface XMessageContext
exchangePattern
- 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)
XMessageContext
XMessage
instance. But the payload of that
XMessage
will not be cloned.cloneMessageContextWithoutPayload
in interface XMessageContext
exchangePattern
- 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)
XMessageContext
XMessage
instancecloneMessageContextWithoutMessage
in interface XMessageContext
exchangePattern
- 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 void setAsyncResponseCompletionFuture(CompletableFuture<XMessageContext> asyncResponseCompletionFuture)
XMessageContext
CompletableFuture
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 XMessageContext
asyncResponseCompletionFuture
- asynchronous response futurepublic CompletableFuture<XMessageContext> getAsyncResponseCompletionFuture()
XMessageContext
getAsyncResponseCompletionFuture
in interface XMessageContext
null
else.public void releaseResources()
XMessageContext
releaseResources
in interface XMessageContext
public <T> void setScopeVariable(String varKey, T varValue)
XMessageContext
setScopeVariable
in interface XMessageContext
T
- 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)
XMessageContext
getScopeVariable
in interface XMessageContext
T
- 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,
Optional.EMPTY
otherwisepublic void removeScopeVariable(String varKey, boolean removeFromAllScopes)
XMessageContext
removeScopeVariable
in interface XMessageContext
varKey
- key of the variableremoveFromAllScopes
- whether to remove the variables with the given key from all scopespublic void completeMessageFlowSuccessfully()
XMessageContext
completeMessageFlowSuccessfully
in interface XMessageContext
public void completeMessageFlowWithException(Throwable throwable)
XMessageContext
completeMessageFlowWithException
in interface XMessageContext
throwable
- Throwable
related to the failure of this message flowpublic XFlowEventNotificationContext getFlowEventNotificationContext()
XMessageContext
XFlowEventNotificationContext
associated with this contextgetFlowEventNotificationContext
in interface XMessageContext
XFlowEventNotificationContext
public void setFlowEventNotificationContext(XFlowEventNotificationContext flowEventNotificationContext)
XMessageContext
XFlowEventNotificationContext
to this contextsetFlowEventNotificationContext
in interface XMessageContext
flowEventNotificationContext
- XFlowEventNotificationContext
instance to be setpublic boolean isTimedOut()
XMessageContext
isTimedOut
in interface XMessageContext
public void setAsTimedOut()
XMessageContext
setAsTimedOut
in interface XMessageContext
public <P> void addContextProperty(String key, P value)
XMessageContext
addContextProperty
in interface XMessageContext
P
- the type of the property value to be addedkey
- property keyvalue
- property valuepublic <P> Optional<P> getContextProperty(String key, Class<P> cls)
XMessageContext
getContextProperty
in interface XMessageContext
P
- the type of the propertykey
- the property keycls
- the class of the property typepublic Optional<String> getStringContextProperty(String key)
XMessageContext
getStringContextProperty
in interface XMessageContext
key
- property keypublic void removeContextProperty(String key)
XMessageContext
removeContextProperty
in interface XMessageContext
key
- property keypublic boolean hasContextProperty(String key)
XMessageContext
hasContextProperty
in interface XMessageContext
key
- the key to be checked for existencepublic Map<String,Object> getContextProperties()
XMessageContext
getContextProperties
in interface XMessageContext
public void setReceivedConnectorId(String receivedConnectorId)
setReceivedConnectorId
in interface XMessageContext
public String getReceivedConnectorId()
getReceivedConnectorId
in interface XMessageContext
public void attachForRelease(AutoCloseable closeable)
attachForRelease
in interface XMessageContext
public boolean isMessageContextCompleted()
isMessageContextCompleted
in interface XMessageContext
public boolean isMessageFlowCompleted()
isMessageFlowCompleted
in interface XMessageContext
Copyright © 2016–2019 AdroitLogic. All rights reserved.