|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jms.support.JmsAccessor org.springframework.jms.support.destination.JmsDestinationAccessor org.springframework.jms.listener.AbstractJmsListeningContainer org.springframework.jms.listener.AbstractMessageListenerContainer org.springframework.jms.listener.serversession.ServerSessionMessageListenerContainer
public class ServerSessionMessageListenerContainer
Message listener container that builds on the ServerSessionPool
SPI, creating JMS ServerSession instances through a pluggable
ServerSessionFactory
.
NOTE: This class requires a JMS 1.1+ provider, because it builds on the
domain-independent API. Use the ServerSessionMessageListenerContainer102
subclass for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.
The default ServerSessionFactory is a SimpleServerSessionFactory
,
which will create a new ServerSession for each listener execution.
Consider specifying a CommonsPoolServerSessionFactory
to reuse JMS
Sessions and/or to limit the number of concurrent ServerSession executions.
See the AbstractMessageListenerContainer
javadoc for details
on acknowledge modes and other configuration options.
This is an 'advanced' (special-purpose) message listener container.
For a simpler message listener container, in particular when using
a JMS provider without ServerSessionPool support, consider using
SimpleMessageListenerContainer
.
For a general one-stop shop that is nevertheless very flexible, consider
DefaultMessageListenerContainer
.
SimpleMessageListenerContainer
,
DefaultMessageListenerContainer
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
---|
AbstractJmsListeningContainer.SharedConnectionNotInitializedException |
Field Summary |
---|
Fields inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
---|
lifecycleMonitor, sharedConnectionMonitor |
Fields inherited from class org.springframework.jms.support.JmsAccessor |
---|
logger |
Constructor Summary | |
---|---|
ServerSessionMessageListenerContainer()
|
Method Summary | |
---|---|
protected ConnectionConsumer |
createConsumer(Connection con,
Destination destination,
ServerSessionPool pool)
Create a JMS ConnectionConsumer for the given Connection. |
Session |
createListenerSession()
Create a JMS Session with the specified listener registered. |
protected ServerSessionPool |
createServerSessionPool()
Create a JMS ServerSessionPool for the specified message listener, via this container's ServerSessionFactory. |
protected void |
doInitialize()
Creates a JMS ServerSessionPool for the specified listener and registers it with a JMS ConnectionConsumer for the specified destination. |
protected void |
doShutdown()
Close the JMS ServerSessionPool for the specified message listener, via this container's ServerSessionFactory, and subsequently also this container's JMS ConnectionConsumer. |
void |
executeListenerSession(Session session)
Execute the given JMS Session, triggering invocation of its listener. |
protected ConnectionConsumer |
getConsumer()
Return the JMS ConnectionConsumer used by this message listener container. |
protected int |
getMaxMessagesPerTask()
Return the maximum number of messages to load into a JMS Session. |
protected ServerSessionFactory |
getServerSessionFactory()
Return the Spring ServerSessionFactory to use. |
void |
setMaxMessagesPerTask(int maxMessagesPerTask)
Set the maximum number of messages to load into a JMS Session. |
void |
setServerSessionFactory(ServerSessionFactory serverSessionFactory)
Set the Spring ServerSessionFactory to use. |
protected boolean |
sharedConnectionEnabled()
Always use a shared JMS Connection. |
Methods inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
---|
afterPropertiesSet, createSharedConnection, destroy, doRescheduleTask, doStart, doStop, establishSharedConnection, getBeanName, getClientId, getSharedConnection, initialize, isActive, isRunning, prepareSharedConnection, refreshSharedConnection, rescheduleTaskIfNecessary, setAutoStartup, setBeanName, setClientId, shutdown, start, startSharedConnection, stop, stopSharedConnection, waitWhileNotRunning |
Methods inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor |
---|
getDestinationResolver, isPubSubDomain, resolveDestinationName, setDestinationResolver, setPubSubDomain |
Methods inherited from class org.springframework.jms.support.JmsAccessor |
---|
convertJmsAccessException, createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName, setSessionTransacted |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServerSessionMessageListenerContainer()
Method Detail |
---|
public void setServerSessionFactory(ServerSessionFactory serverSessionFactory)
Default is a plain SimpleServerSessionFactory. Consider using a CommonsPoolServerSessionFactory to reuse JMS Sessions and/or to limit the number of concurrent ServerSession executions.
SimpleServerSessionFactory
,
CommonsPoolServerSessionFactory
protected ServerSessionFactory getServerSessionFactory()
public void setMaxMessagesPerTask(int maxMessagesPerTask)
See the corresponding JMS createConnectionConsumer
argument for details.
Connection.createConnectionConsumer(javax.jms.Destination, java.lang.String, javax.jms.ServerSessionPool, int)
protected int getMaxMessagesPerTask()
protected final boolean sharedConnectionEnabled()
sharedConnectionEnabled
in class AbstractJmsListeningContainer
AbstractJmsListeningContainer.getSharedConnection()
protected void doInitialize() throws JMSException
doInitialize
in class AbstractJmsListeningContainer
JMSException
- if registration failedcreateServerSessionPool()
,
createConsumer(javax.jms.Connection, javax.jms.Destination, javax.jms.ServerSessionPool)
protected ServerSessionPool createServerSessionPool() throws JMSException
This message listener container implements the ListenerSessionManager interface, hence can be passed to the ServerSessionFactory itself.
JMSException
- if creation of the ServerSessionPool failedsetServerSessionFactory(org.springframework.jms.listener.serversession.ServerSessionFactory)
,
ServerSessionFactory.getServerSession(ListenerSessionManager)
protected final ConnectionConsumer getConsumer()
protected void doShutdown() throws JMSException
This message listener container implements the ListenerSessionManager interface, hence can be passed to the ServerSessionFactory itself.
doShutdown
in class AbstractJmsListeningContainer
JMSException
- if shutdown failedsetServerSessionFactory(org.springframework.jms.listener.serversession.ServerSessionFactory)
,
ServerSessionFactory.getServerSession(ListenerSessionManager)
public Session createListenerSession() throws JMSException
executeListener
method.
Default implementation simply calls setMessageListener
on a newly created JMS Session, according to the JMS specification's
ServerSessionPool section.
createListenerSession
in interface ListenerSessionManager
JMSException
- if thrown by JMS API methodsAbstractMessageListenerContainer.executeListener(javax.jms.Session, javax.jms.Message)
public void executeListenerSession(Session session)
Default implementation simply calls run()
on the JMS Session, according to the JMS specification's
ServerSessionPool section.
executeListenerSession
in interface ListenerSessionManager
session
- the JMS Session to executeSession.run()
protected ConnectionConsumer createConsumer(Connection con, Destination destination, ServerSessionPool pool) throws JMSException
This implementation uses JMS 1.1 API.
con
- the JMS Connection to create a Session fordestination
- the JMS Destination to listen topool
- the ServerSessionpool to use
JMSException
- if thrown by JMS API methods
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |