org.apache.activemq.web
Class MessageServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.activemq.web.MessageServletSupport
org.apache.activemq.web.MessageServlet
- All Implemented Interfaces:
- Serializable, Servlet, ServletConfig
public class MessageServlet
- extends MessageServletSupport
A servlet for sending and receiving messages to/from JMS destinations using
HTTP POST for sending and HTTP GET for receiving.
You can specify the
destination and whether it is a topic or queue via configuration details on
the servlet or as request parameters. For reading messages you can
specify a readTimeout parameter to determine how long the servlet should
block for.
- See Also:
- Serialized Form
| Methods inherited from class org.apache.activemq.web.MessageServletSupport |
appendParametersToMessage, asBoolean, asBoolean, asDestination, asInt, asInteger, asLong, asLong, asString, getDestination, getDestination, getDestinationFromURI, getPostedMessageBody, getSelector, getSendPriority, getSendTimeToLive, init, isSendPersistent, isSync, isTopic |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MessageServlet
public MessageServlet()
init
public void init()
throws ServletException
- Overrides:
init in class GenericServlet
- Throws:
ServletException
doPost
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- Sends a message to a destination
- Overrides:
doPost in class HttpServlet
- Parameters:
request - response -
- Throws:
ServletException
IOException
doDelete
protected void doDelete(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- Supports a HTTP DELETE to be equivlanent of consuming a singe message
from a queue
- Overrides:
doDelete in class HttpServlet
- Throws:
ServletException
IOException
doGet
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- Supports a HTTP DELETE to be equivlanent of consuming a singe message
from a queue
- Overrides:
doGet in class HttpServlet
- Throws:
ServletException
IOException
doMessages
protected void doMessages(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- Reads a message from a destination up to some specific timeout period
- Parameters:
request - response -
- Throws:
ServletException
IOException
writeResponse
protected void writeResponse(HttpServletRequest request,
HttpServletResponse response,
Message message)
throws IOException,
JMSException
- Throws:
IOException
JMSException
writeMessageResponse
protected void writeMessageResponse(PrintWriter writer,
Message message)
throws JMSException,
IOException
- Throws:
JMSException
IOException
isXmlContent
protected boolean isXmlContent(Message message)
throws JMSException
- Throws:
JMSException
getWebClient
public WebClient getWebClient(HttpServletRequest request)
getContentType
protected String getContentType(HttpServletRequest request)
setResponseHeaders
protected void setResponseHeaders(HttpServletResponse response,
Message message)
throws JMSException
- Throws:
JMSException
getReadTimeout
protected long getReadTimeout(HttpServletRequest request)
- Returns:
- the timeout value for read requests which is always >= 0 and <=
maximumReadTimeout to avoid DoS attacks
Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.