Interface ClientSessionFactory
- All Superinterfaces:
AutoCloseable
It is possible to configure a factory using the setter methods only if no session has been created. Once a session is created, the configuration is fixed and any call to a setter method will throw an IllegalStateException.
-
Method Summary
Modifier and TypeMethodDescriptionaddFailoverListener
(FailoverEventListener listener) Adds a FailoverEventListener to the session which is notified if a failover event occurs on the session.void
cleanup()
Opposed to close, will call cleanup only on every created session and children objects.void
close()
Closes this factory and any session created by it.Creates a non-transacted session.createSession
(boolean autoCommitSends, boolean autoCommitAcks) Creates a session.createSession
(boolean xa, boolean autoCommitSends, boolean autoCommitAcks) Creates a session.createSession
(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) Creates a session.createSession
(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) Creates a session.createSession
(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize) Creates an authenticated session.createSession
(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize, String clientID) Creates an authenticated session.Creates a transacted session.Creates a session with XA transaction semantics.Returns the code connection used by this session factory.Returns the configuration used.Returns the server locator associated with this session factory.boolean
isClosed()
Returnstrue
if the factory is closed,false
otherwise.boolean
removeFailoverListener
(FailoverEventListener listener) Removes a FailoverEventListener to the session.
-
Method Details
-
createXASession
Creates a session with XA transaction semantics.- Returns:
- a ClientSession with XA transaction semantics
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createTransactedSession
Creates a transacted session.It is up to the client to commit when sending and acknowledging messages.
- Returns:
- a transacted ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session- See Also:
-
createSession
Creates a non-transacted session. Message sends and acknowledgements are automatically committed by the session. This does not mean that messages are automatically acknowledged, only that when messages are acknowledged, the session will automatically commit the transaction containing the acknowledgements.- Returns:
- a non-transacted ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException Creates a session.- Parameters:
autoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manually- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) throws ActiveMQException Creates a session.- Parameters:
autoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manuallyackBatchSize
- the batch size of the acknowledgements- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException Creates a session.- Parameters:
xa
- whether the session support XA transaction semantic or notautoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manually- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException Creates a session.It is possible to pre-acknowledge messages on the server so that the client can avoid additional network trip to the server to acknowledge messages. While this increase performance, this does not guarantee delivery (as messages can be lost after being pre-acknowledged on the server). Use with caution if your application design permits it.
- Parameters:
xa
- whether the session support XA transaction semantic or notautoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manuallypreAcknowledge
-true
to pre-acknowledge messages on the server,false
to let the client acknowledge the messages- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize) throws ActiveMQException Creates an authenticated session.It is possible to pre-acknowledge messages on the server so that the client can avoid additional network trip to the server to acknowledge messages. While this increase performance, this does not guarantee delivery (as messages can be lost after being pre-acknowledged on the server). Use with caution if your application design permits it.
- Parameters:
username
- the user namepassword
- the user passwordxa
- whether the session support XA transaction semantic or notautoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manuallypreAcknowledge
-true
to pre-acknowledge messages on the server,false
to let the client acknowledge the messages- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
createSession
ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize, String clientID) throws ActiveMQException Creates an authenticated session.It is possible to pre-acknowledge messages on the server so that the client can avoid additional network trip to the server to acknowledge messages. While this increase performance, this does not guarantee delivery (as messages can be lost after being pre-acknowledged on the server). Use with caution if your application design permits it.
- Parameters:
username
- the user namepassword
- the user passwordxa
- whether the session support XA transaction semantic or notautoCommitSends
-true
to automatically commit message sends,false
to commit manuallyautoCommitAcks
-true
to automatically commit message acknowledgement,false
to commit manuallypreAcknowledge
-true
to pre-acknowledge messages on the server,false
to let the client acknowledge the messagesclientID
- the session clientID- Returns:
- a ClientSession
- Throws:
ActiveMQException
- if an exception occurs while creating the session
-
close
void close()Closes this factory and any session created by it.- Specified by:
close
in interfaceAutoCloseable
-
isClosed
boolean isClosed()Returnstrue
if the factory is closed,false
otherwise.- Returns:
true
if the factory is closed,false
otherwise
-
addFailoverListener
Adds a FailoverEventListener to the session which is notified if a failover event occurs on the session.- Parameters:
listener
- the listener to add- Returns:
- this ClientSessionFactory
-
removeFailoverListener
Removes a FailoverEventListener to the session.- Parameters:
listener
- the listener to remove- Returns:
true
if the listener was removed,false
else
-
cleanup
void cleanup()Opposed to close, will call cleanup only on every created session and children objects. -
getServerLocator
ServerLocator getServerLocator()Returns the server locator associated with this session factory.- Returns:
- the server locator associated with this session factory
-
getConnection
RemotingConnection getConnection()Returns the code connection used by this session factory.- Returns:
- the code connection used by this session factory
-
getConnectorConfiguration
TransportConfiguration getConnectorConfiguration()Returns the configuration used.- Returns:
- the configuration used
-