org.mule.transport.http
Class HttpMessageProcessTemplate

java.lang.Object
  extended by org.mule.transport.AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
      extended by org.mule.transport.http.HttpMessageProcessTemplate
All Implemented Interfaces:
EndPhaseTemplate, FlowProcessingPhaseTemplate, MessageProcessContext, MessageProcessTemplate, RequestResponseFlowProcessingPhaseTemplate, ThrottlingPhaseTemplate, ValidationPhaseTemplate
Direct Known Subclasses:
HttpsMessageProcessTemplate

public class HttpMessageProcessTemplate
extends AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
implements RequestResponseFlowProcessingPhaseTemplate, ThrottlingPhaseTemplate, EndPhaseTemplate


Field Summary
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
           
 
Fields inherited from class org.mule.transport.AbstractTransportMessageProcessTemplate
logger
 
Constructor Summary
HttpMessageProcessTemplate(HttpMessageReceiver messageReceiver, HttpServerConnection httpServerConnection, WorkManager flowExecutionWorkManager)
           
 
Method Summary
 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()
           
 Latch getMessageProcessedLatch()
           
 void messageProcessingEnded()
          template method call when the message processing ends
protected  String processRelativePath(String contextPath, String path)
           
 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.
 boolean supportsAsynchronousProcessing()
           
protected  HttpResponse transformResponse(Object response)
           
 boolean validateMessage()
          Validates the message content.
 
Methods inherited from class org.mule.transport.AbstractTransportMessageProcessTemplate
afterFailureProcessingFlow, afterRouteEvent, afterSuccessfulProcessingFlow, createEventFromMuleMessage, getConnector, getFlowConstruct, getFlowExecutionWorkManager, getInboundEndpoint, getMessageReceiver, getMessageSource, getMuleContext, getMuleEvent, getOriginalMessage, getOutputStream, getTransactionConfig, propagateRootMessageIdProperty, routeEvent, warnIfMuleClientSendUsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.execution.FlowProcessingPhaseTemplate
afterFailureProcessingFlow, afterRouteEvent, afterSuccessfulProcessingFlow, getMuleEvent, getOriginalMessage, routeEvent
 

Field Detail

MESSAGE_DISCARD_STATUS_CODE

public static final int MESSAGE_DISCARD_STATUS_CODE

X_RATE_LIMIT_LIMIT_HEADER

public static final String X_RATE_LIMIT_LIMIT_HEADER
See Also:
Constant Field Values

X_RATE_LIMIT_REMAINING_HEADER

public static final String X_RATE_LIMIT_REMAINING_HEADER
See Also:
Constant Field Values

X_RATE_LIMIT_RESET_HEADER

public static final String X_RATE_LIMIT_RESET_HEADER
See Also:
Constant Field Values
Constructor Detail

HttpMessageProcessTemplate

public HttpMessageProcessTemplate(HttpMessageReceiver messageReceiver,
                                  HttpServerConnection httpServerConnection,
                                  WorkManager flowExecutionWorkManager)
Method Detail

sendResponseToClient

public void sendResponseToClient(MuleEvent responseMuleEvent)
                          throws MuleException
Description copied from interface: RequestResponseFlowProcessingPhaseTemplate
Template method to send a response after processing the message.

This method is executed within the flow so if it fails it will trigger the exception strategy.

Specified by:
sendResponseToClient in interface RequestResponseFlowProcessingPhaseTemplate
Parameters:
responseMuleEvent - the event with the content of the response to be sent.
Throws:
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.

sendFailureResponseToClient

public void sendFailureResponseToClient(MessagingException messagingException)
                                 throws MuleException
Specified by:
sendFailureResponseToClient in interface RequestResponseFlowProcessingPhaseTemplate
Parameters:
messagingException - exception thrown during the flow execution.
Throws:
MuleException - exception thrown when processing the message to send the response.

afterFailureProcessingFlow

public void afterFailureProcessingFlow(MuleException exception)
                                throws MuleException
Description copied from interface: FlowProcessingPhaseTemplate
Call when the processing of the message through the flow fails in an exception strategy

Specified by:
afterFailureProcessingFlow in interface FlowProcessingPhaseTemplate
Overrides:
afterFailureProcessingFlow in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Throws:
MuleException

beforeRouteEvent

public MuleEvent beforeRouteEvent(MuleEvent muleEvent)
                           throws MuleException
Description copied from interface: FlowProcessingPhaseTemplate
Pre processing of the MuleEvent to route

Specified by:
beforeRouteEvent in interface FlowProcessingPhaseTemplate
Overrides:
beforeRouteEvent in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Throws:
MuleException

transformResponse

protected HttpResponse transformResponse(Object response)
                                  throws MuleException
Throws:
MuleException

createMessageFromSource

protected MuleMessage createMessageFromSource(Object message)
                                       throws MuleException
Overrides:
createMessageFromSource in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Throws:
MuleException

processRelativePath

protected String processRelativePath(String contextPath,
                                     String path)

acquireMessage

public Object acquireMessage()
                      throws MuleException
Description copied from class: AbstractTransportMessageProcessTemplate
This method will only be called once for the MessageProcessContext

Specified by:
acquireMessage in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Returns:
the raw message from the MessageSource
Throws:
MuleException

validateMessage

public boolean validateMessage()
Description copied from interface: ValidationPhaseTemplate
Validates the message content. In case that the message is not valid then 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 called

Specified by:
validateMessage in interface ValidationPhaseTemplate
Overrides:
validateMessage in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Returns:
false if the message is invalid, true otherwise

discardInvalidMessage

public void discardInvalidMessage()
                           throws MuleException
Description copied from interface: ValidationPhaseTemplate
Discards the message because the validation failed

Specified by:
discardInvalidMessage in interface ValidationPhaseTemplate
Overrides:
discardInvalidMessage in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Throws:
MuleException

supportsAsynchronousProcessing

public boolean supportsAsynchronousProcessing()
Specified by:
supportsAsynchronousProcessing in interface MessageProcessContext
Overrides:
supportsAsynchronousProcessing in class AbstractTransportMessageProcessTemplate<HttpMessageReceiver,HttpConnector>
Returns:
true if the message can be processed in a different thread than the one it was acquired, false otherwise

doBad

protected HttpResponse doBad(RequestLine requestLine)
                      throws MuleException
Throws:
MuleException

getHttpServerConnection

protected HttpServerConnection getHttpServerConnection()

getMessageProcessedLatch

public Latch getMessageProcessedLatch()

discardMessageOnThrottlingExceeded

public void discardMessageOnThrottlingExceeded()
                                        throws MuleException
Description copied from interface: ThrottlingPhaseTemplate
Discards the message due to ThrottlingPolicy configured for the MessageSource is exceeded

Specified by:
discardMessageOnThrottlingExceeded in interface ThrottlingPhaseTemplate
Throws:
MuleException

setThrottlingPolicyStatistics

public void setThrottlingPolicyStatistics(long remainingRequestInCurrentPeriod,
                                          long maximumRequestAllowedPerPeriod,
                                          long timeUntilNextPeriodInMillis)
Description copied from interface: ThrottlingPhaseTemplate
Set up throttling policy state to be used by the MessageSource for debugging or information purpose. Not all throttling policy supports statistics so this method may not be called

Specified by:
setThrottlingPolicyStatistics in interface ThrottlingPhaseTemplate
Parameters:
remainingRequestInCurrentPeriod - the remaining allowed messages in the current period
maximumRequestAllowedPerPeriod - the maximum allowed messages in a period
timeUntilNextPeriodInMillis - time in milliseconds until the next period starts

messageProcessingEnded

public void messageProcessingEnded()
Description copied from interface: EndPhaseTemplate
template method call when the message processing ends

Specified by:
messageProcessingEnded in interface EndPhaseTemplate

awaitTermination

public void awaitTermination()
                      throws InterruptedException
Throws:
InterruptedException


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.