Package org.apache.activemq.web
Class WebClient
java.lang.Object
org.apache.activemq.web.WebClient
- All Implemented Interfaces:
jakarta.servlet.http.HttpSessionActivationListener,jakarta.servlet.http.HttpSessionBindingListener,Externalizable,Serializable,EventListener
- Direct Known Subclasses:
AjaxWebClient
public class WebClient
extends Object
implements jakarta.servlet.http.HttpSessionActivationListener, jakarta.servlet.http.HttpSessionBindingListener, Externalizable
Represents a messaging client used from inside a web container typically
stored inside a HttpSession TODO controls to prevent DOS attacks with users
requesting many consumers TODO configure consumers with small prefetch.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcloseConsumer(jakarta.jms.Destination destination) voidprotected jakarta.jms.Sessionprotected static WebClientcreateWebClient(jakarta.servlet.http.HttpServletRequest request) jakarta.jms.Connectionjakarta.jms.MessageConsumergetConsumer(jakarta.jms.Destination destination, String selector) jakarta.jms.MessageConsumergetConsumer(jakarta.jms.Destination destination, String selector, boolean create) List<jakarta.jms.MessageConsumer>intjakarta.jms.MessageProducerjakarta.jms.Sessionstatic WebClientgetWebClient(jakarta.servlet.http.HttpServletRequest request) Helper method to get the client for the current session, lazily creating a client if there is none currentlystatic WebClientgetWebClient(jakarta.servlet.http.HttpSession session) protected static voidinitConnectionFactory(jakarta.servlet.ServletContext servletContext) static voidinitContext(jakarta.servlet.ServletContext context) booleanisClosed()voidvoidsend(jakarta.jms.Destination destination, jakarta.jms.Message message) voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, boolean persistent, int priority, long timeToLive) voidsessionDidActivate(jakarta.servlet.http.HttpSessionEvent event) voidsessionWillPassivate(jakarta.servlet.http.HttpSessionEvent event) voidsetDeliveryMode(int deliveryMode) voidsetPassword(String password) voidsetProducer(jakarta.jms.MessageProducer producer) voidsetUsername(String username) voidvalueBound(jakarta.servlet.http.HttpSessionBindingEvent event) voidvalueUnbound(jakarta.servlet.http.HttpSessionBindingEvent event) void
-
Field Details
-
WEB_CLIENT_ATTRIBUTE
- See Also:
-
CONNECTION_FACTORY_ATTRIBUTE
- See Also:
-
CONNECTION_FACTORY_PREFETCH_PARAM
- See Also:
-
CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM
- See Also:
-
BROKER_URL_INIT_PARAM
- See Also:
-
USERNAME_INIT_PARAM
- See Also:
-
PASSWORD_INIT_PARAM
- See Also:
-
SELECTOR_NAME
- See Also:
-
selectorName
-
-
Constructor Details
-
WebClient
public WebClient()
-
-
Method Details
-
getWebClient
Helper method to get the client for the current session, lazily creating a client if there is none currently- Parameters:
request- is the current HTTP request- Returns:
- the current client or a newly creates
-
getWebClient
- Returns:
- the web client for the current HTTP session or null if there is not a web client created yet
-
initContext
public static void initContext(jakarta.servlet.ServletContext context) -
getDeliveryMode
public int getDeliveryMode() -
setDeliveryMode
public void setDeliveryMode(int deliveryMode) -
getUsername
-
setUsername
-
getPassword
-
setPassword
-
closeConsumers
public void closeConsumers() -
close
public void close() -
isClosed
public boolean isClosed() -
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, boolean persistent, int priority, long timeToLive) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getSession
public jakarta.jms.Session getSession() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
getConnection
public jakarta.jms.Connection getConnection() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
initConnectionFactory
protected static void initConnectionFactory(jakarta.servlet.ServletContext servletContext) -
getProducer
public jakarta.jms.MessageProducer getProducer() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
setProducer
public void setProducer(jakarta.jms.MessageProducer producer) -
getConsumer
public jakarta.jms.MessageConsumer getConsumer(jakarta.jms.Destination destination, String selector) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getConsumer
public jakarta.jms.MessageConsumer getConsumer(jakarta.jms.Destination destination, String selector, boolean create) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
closeConsumer
public void closeConsumer(jakarta.jms.Destination destination) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getConsumers
-
createSession
protected jakarta.jms.Session createSession() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
getSemaphore
-
sessionWillPassivate
public void sessionWillPassivate(jakarta.servlet.http.HttpSessionEvent event) - Specified by:
sessionWillPassivatein interfacejakarta.servlet.http.HttpSessionActivationListener
-
sessionDidActivate
public void sessionDidActivate(jakarta.servlet.http.HttpSessionEvent event) - Specified by:
sessionDidActivatein interfacejakarta.servlet.http.HttpSessionActivationListener
-
valueBound
public void valueBound(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
valueBoundin interfacejakarta.servlet.http.HttpSessionBindingListener
-
valueUnbound
public void valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
valueUnboundin interfacejakarta.servlet.http.HttpSessionBindingListener
-
createWebClient
-