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 TypeMethodDescriptionvoid
close()
void
closeConsumer
(jakarta.jms.Destination destination) void
protected jakarta.jms.Session
protected static WebClient
createWebClient
(jakarta.servlet.http.HttpServletRequest request) jakarta.jms.Connection
jakarta.jms.MessageConsumer
getConsumer
(jakarta.jms.Destination destination, String selector) jakarta.jms.MessageConsumer
getConsumer
(jakarta.jms.Destination destination, String selector, boolean create) List<jakarta.jms.MessageConsumer>
int
jakarta.jms.MessageProducer
jakarta.jms.Session
static WebClient
getWebClient
(jakarta.servlet.http.HttpServletRequest request) Helper method to get the client for the current session, lazily creating a client if there is none currentlystatic WebClient
getWebClient
(jakarta.servlet.http.HttpSession session) protected static void
initConnectionFactory
(jakarta.servlet.ServletContext servletContext) static void
initContext
(jakarta.servlet.ServletContext context) boolean
isClosed()
void
void
send
(jakarta.jms.Destination destination, jakarta.jms.Message message) void
send
(jakarta.jms.Destination destination, jakarta.jms.Message message, boolean persistent, int priority, long timeToLive) void
sessionDidActivate
(jakarta.servlet.http.HttpSessionEvent event) void
sessionWillPassivate
(jakarta.servlet.http.HttpSessionEvent event) void
setDeliveryMode
(int deliveryMode) void
setPassword
(String password) void
setProducer
(jakarta.jms.MessageProducer producer) void
setUsername
(String username) void
valueBound
(jakarta.servlet.http.HttpSessionBindingEvent event) void
valueUnbound
(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:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
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:
sessionWillPassivate
in interfacejakarta.servlet.http.HttpSessionActivationListener
-
sessionDidActivate
public void sessionDidActivate(jakarta.servlet.http.HttpSessionEvent event) - Specified by:
sessionDidActivate
in interfacejakarta.servlet.http.HttpSessionActivationListener
-
valueBound
public void valueBound(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
valueBound
in interfacejakarta.servlet.http.HttpSessionBindingListener
-
valueUnbound
public void valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent event) - Specified by:
valueUnbound
in interfacejakarta.servlet.http.HttpSessionBindingListener
-
createWebClient
-