public class HttpMessageProcessorTemplate extends Object implements AsyncResponseFlowProcessingPhaseTemplate, ThrottlingPhaseTemplate
Modifier and Type | Field and Description |
---|---|
static String |
MESSAGE_DISCARD_MESSAGE_BODY |
static String |
MESSAGE_DISCARD_REASON_PHRASE |
static int |
MESSAGE_DISCARD_STATUS_CODE |
static String |
X_RATE_LIMIT_LIMIT_HEADER |
static String |
X_RATE_LIMIT_REMAINING_HEADER |
static String |
X_RATE_LIMIT_RESET_HEADER |
Constructor and Description |
---|
HttpMessageProcessorTemplate(MuleEvent sourceMuleEvent,
MessageProcessor messageProcessor,
HttpResponseReadyCallback responseReadyCallback,
HttpResponseBuilder responseBuilder,
HttpResponseBuilder errorResponseBuilder) |
Modifier and Type | Method and Description |
---|---|
void |
afterFailureProcessingFlow(Exception exception)
Call when the processing of the message through the flow fails in an exception strategy
|
protected HttpResponse |
buildErrorResponse() |
protected HttpResponse |
buildResponse(MuleEvent muleEvent,
HttpResponseBuilder responseBuilder,
ResponseCompletionCallback responseCompletationCallback) |
void |
discardMessageOnThrottlingExceeded()
Discards the message due to ThrottlingPolicy configured for the
MessageSource is exceeded |
protected HttpResponse |
doBuildResponse(MuleEvent muleEvent,
HttpResponseBuilder responseBuilder,
ResponseCompletionCallback responseCompletationCallback) |
MuleEvent |
getMuleEvent() |
MuleEvent |
routeEvent(MuleEvent muleEvent)
Routes the
MuleEvent through the processors chain |
void |
sendFailureResponseToClient(MessagingException messagingException,
ResponseCompletionCallback responseCompletationCallback) |
void |
sendResponseToClient(MuleEvent muleEvent,
ResponseCompletionCallback responseCompletationCallback)
Template method to send a response after processing the message.
|
void |
setThrottlingPolicyStatistics(long remainingRequestInCurrentPeriod,
long maximumRequestAllowedPerPeriod,
long timeUntilNextPeriodInMillis)
Set up throttling policy state to be used by the
MessageSource for debugging or
information purpose. |
public static final int MESSAGE_DISCARD_STATUS_CODE
public static final String MESSAGE_DISCARD_MESSAGE_BODY
public static final String MESSAGE_DISCARD_REASON_PHRASE
public static final String X_RATE_LIMIT_LIMIT_HEADER
public static final String X_RATE_LIMIT_REMAINING_HEADER
public static final String X_RATE_LIMIT_RESET_HEADER
public HttpMessageProcessorTemplate(MuleEvent sourceMuleEvent, MessageProcessor messageProcessor, HttpResponseReadyCallback responseReadyCallback, HttpResponseBuilder responseBuilder, HttpResponseBuilder errorResponseBuilder)
public MuleEvent getMuleEvent() throws MuleException
getMuleEvent
in interface AsyncResponseFlowProcessingPhaseTemplate
getMuleEvent
in interface ThrottlingPhaseTemplate
MuleEvent
created from the original messageMuleException
public MuleEvent routeEvent(MuleEvent muleEvent) throws MuleException
AsyncResponseFlowProcessingPhaseTemplate
MuleEvent
through the processors chainrouteEvent
in interface AsyncResponseFlowProcessingPhaseTemplate
muleEvent
- MuleEvent
created from the raw message of this contextMuleEvent
MuleException
public void afterFailureProcessingFlow(Exception exception)
AsyncResponseFlowProcessingPhaseTemplate
afterFailureProcessingFlow
in interface AsyncResponseFlowProcessingPhaseTemplate
public void sendResponseToClient(MuleEvent muleEvent, ResponseCompletionCallback responseCompletationCallback) throws MuleException
AsyncResponseFlowProcessingPhaseTemplate
sendResponseToClient
in interface AsyncResponseFlowProcessingPhaseTemplate
muleEvent
- the event with the content of the response to be sent.responseCompletationCallback
- callback to be used for notifying the result of the operationMuleException
- exception thrown when processing the message to send the response. If there's a failure when writing the response
using the underlying transport or connector then the exception to throw must be a ResponseDispatchException
.protected HttpResponse buildErrorResponse()
protected HttpResponse buildResponse(MuleEvent muleEvent, HttpResponseBuilder responseBuilder, ResponseCompletionCallback responseCompletationCallback)
protected HttpResponse doBuildResponse(MuleEvent muleEvent, HttpResponseBuilder responseBuilder, ResponseCompletionCallback responseCompletationCallback)
public void sendFailureResponseToClient(MessagingException messagingException, ResponseCompletionCallback responseCompletationCallback) throws MuleException
sendFailureResponseToClient
in interface AsyncResponseFlowProcessingPhaseTemplate
messagingException
- exception thrown during the flow execution.responseCompletationCallback
- callback to be used for notifying the result of the operationMuleException
- exception thrown when processing the message to send the response.public void discardMessageOnThrottlingExceeded() throws MuleException
ThrottlingPhaseTemplate
MessageSource
is exceededdiscardMessageOnThrottlingExceeded
in interface ThrottlingPhaseTemplate
MuleException
public void setThrottlingPolicyStatistics(long remainingRequestInCurrentPeriod, long maximumRequestAllowedPerPeriod, long timeUntilNextPeriodInMillis)
ThrottlingPhaseTemplate
MessageSource
for debugging or
information purpose.
Not all throttling policy supports statistics so this method may not be calledsetThrottlingPolicyStatistics
in interface ThrottlingPhaseTemplate
remainingRequestInCurrentPeriod
- the remaining allowed messages in the current periodmaximumRequestAllowedPerPeriod
- the maximum allowed messages in a periodtimeUntilNextPeriodInMillis
- time in milliseconds until the next period startsCopyright © 2003–2016 MuleSoft, Inc.. All rights reserved.