public class HttpMessageProcessTemplate extends AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector> implements RequestResponseFlowProcessingPhaseTemplate, ThrottlingPhaseTemplate, EndPhaseTemplate
Modifier and Type | Field and Description |
---|---|
static int |
MESSAGE_DISCARD_STATUS_CODE |
static String |
MESSAGE_THROTTLED_REASON_PHRASE |
static String |
X_RATE_LIMIT_LIMIT_HEADER |
static String |
X_RATE_LIMIT_REMAINING_HEADER |
static String |
X_RATE_LIMIT_RESET_HEADER |
logger
Constructor and Description |
---|
HttpMessageProcessTemplate(HttpMessageReceiver messageReceiver,
HttpServerConnection httpServerConnection) |
Modifier and Type | Method and Description |
---|---|
Object |
acquireMessage()
This method will only be called once for the
MessageProcessContext |
void |
afterFailureProcessingFlow(MuleException exception)
Call when the processing of the message through the flow fails in an exception strategy
|
void |
awaitTermination() |
MuleEvent |
beforeRouteEvent(MuleEvent muleEvent)
Pre processing of the
MuleEvent to route |
protected MuleMessage |
createMessageFromSource(Object message) |
void |
discardInvalidMessage()
Discards the message because the validation failed
|
void |
discardMessageOnThrottlingExceeded()
Discards the message due to ThrottlingPolicy configured for the
MessageSource is exceeded |
protected HttpResponse |
doBad(RequestLine requestLine) |
protected HttpServerConnection |
getHttpServerConnection() |
void |
messageProcessingEnded()
template method call when the message processing ends
|
protected String |
processRelativePath(String contextPath,
String path) |
protected void |
processRemoteAddresses(MuleMessage muleMessage)
For a given MuleMessage will set the
MULE_REMOTE_CLIENT_ADDRESS property taking into consideration
if the header X-Forwarded-For is present in the request or not. |
void |
sendFailureResponseToClient(MessagingException messagingException) |
void |
sendResponseToClient(MuleEvent responseMuleEvent)
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. |
protected HttpResponse |
transformResponse(Object response) |
boolean |
validateMessage()
Validates the message content.
|
afterFailureProcessingFlow, afterRouteEvent, afterSuccessfulProcessingFlow, createEventFromMuleMessage, getConnector, getFlowConstruct, getInboundEndpoint, getMessageReceiver, getMuleContext, getMuleEvent, getOriginalMessage, getOutputStream, propagateRootMessageIdProperty, routeEvent, warnIfMuleClientSendUsed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterFailureProcessingFlow, afterRouteEvent, afterSuccessfulProcessingFlow, getMuleEvent, getOriginalMessage, routeEvent
getMuleEvent
public static final int MESSAGE_DISCARD_STATUS_CODE
public static final String MESSAGE_THROTTLED_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 HttpMessageProcessTemplate(HttpMessageReceiver messageReceiver, HttpServerConnection httpServerConnection)
public void sendResponseToClient(MuleEvent responseMuleEvent) throws MuleException
RequestResponseFlowProcessingPhaseTemplate
sendResponseToClient
in interface RequestResponseFlowProcessingPhaseTemplate
responseMuleEvent
- the event with the content of the response to be sent.MuleException
- 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
.public void sendFailureResponseToClient(MessagingException messagingException) throws MuleException
sendFailureResponseToClient
in interface RequestResponseFlowProcessingPhaseTemplate
messagingException
- exception thrown during the flow execution.MuleException
- exception thrown when processing the message to send the response.public void afterFailureProcessingFlow(MuleException exception) throws MuleException
FlowProcessingPhaseTemplate
afterFailureProcessingFlow
in interface FlowProcessingPhaseTemplate
afterFailureProcessingFlow
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
MuleException
public MuleEvent beforeRouteEvent(MuleEvent muleEvent) throws MuleException
FlowProcessingPhaseTemplate
MuleEvent
to routebeforeRouteEvent
in interface FlowProcessingPhaseTemplate
beforeRouteEvent
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
MuleException
protected HttpResponse transformResponse(Object response) throws MuleException
MuleException
protected MuleMessage createMessageFromSource(Object message) throws MuleException
createMessageFromSource
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
MuleException
protected void processRemoteAddresses(MuleMessage muleMessage)
MULE_REMOTE_CLIENT_ADDRESS
property taking into consideration
if the header X-Forwarded-For
is present in the request or not. In case it is, this method will
also set the MULE_PROXY_ADDRESS
property. If a proxy address is not passed in
X-Forwarded-For
, the connection address will be set as MULE_PROXY_ADDRESS
.muleMessage
- MuleMessage to be enrichedpublic Object acquireMessage() throws MuleException
AbstractTransportMessageProcessTemplate
MessageProcessContext
acquireMessage
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
MessageSource
MuleException
public boolean validateMessage()
ValidationPhaseTemplate
ValidationPhaseTemplate.discardInvalidMessage()
will be executed so the implementation can save the reason why the message is invalid
to report why the message has been discarded when ValidationPhaseTemplate.discardInvalidMessage()
is calledvalidateMessage
in interface ValidationPhaseTemplate
validateMessage
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
public void discardInvalidMessage() throws MuleException
ValidationPhaseTemplate
discardInvalidMessage
in interface ValidationPhaseTemplate
discardInvalidMessage
in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
MuleException
protected HttpResponse doBad(RequestLine requestLine) throws MuleException
MuleException
protected HttpServerConnection getHttpServerConnection()
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 startspublic void messageProcessingEnded()
EndPhaseTemplate
messageProcessingEnded
in interface EndPhaseTemplate
public void awaitTermination() throws InterruptedException
InterruptedException
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.