Interface ClientSessionFactory
-
- All Superinterfaces:
AutoCloseable
public interface ClientSessionFactory extends AutoCloseable
A ClientSessionFactory is the entry point to create and configure ActiveMQ Artemis resources to produce and consume messages.
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClientSessionFactoryaddFailoverListener(FailoverEventListener listener)Adds a FailoverEventListener to the session which is notified if a failover event occurs on the session.voidcleanup()Opposed to close, will call cleanup only on every created session and children objects.voidclose()Closes this factory and any session created by it.ClientSessioncreateSession()Creates a non-transacted session.ClientSessioncreateSession(boolean autoCommitSends, boolean autoCommitAcks)Creates a session.ClientSessioncreateSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks)Creates a session.ClientSessioncreateSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge)Creates a session.ClientSessioncreateSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize)Creates a session.ClientSessioncreateSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize)Creates an authenticated session.ClientSessioncreateSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize, String clientID)Creates an authenticated session.ClientSessioncreateTransactedSession()Creates a transacted session.ClientSessioncreateXASession()Creates a session with XA transaction semantics.RemotingConnectiongetConnection()Returns the code connection used by this session factory.TransportConfigurationgetConnectorConfiguration()Return the configuration usedServerLocatorgetServerLocator()booleanisClosed()booleanremoveFailoverListener(FailoverEventListener listener)Removes a FailoverEventListener to the session.
-
-
-
Method Detail
-
createXASession
ClientSession createXASession() throws ActiveMQException
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
ClientSession createTransactedSession() throws ActiveMQException
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:
ClientSession.commit()
-
createSession
ClientSession createSession() throws ActiveMQException
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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto 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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto 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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto 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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto commit manuallypreAcknowledge-trueto pre-acknowledge messages on the server,falseto 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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto commit manuallypreAcknowledge-trueto pre-acknowledge messages on the server,falseto 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-trueto automatically commit message sends,falseto commit manuallyautoCommitAcks-trueto automatically commit message acknowledgement,falseto commit manuallypreAcknowledge-trueto pre-acknowledge messages on the server,falseto 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:
closein interfaceAutoCloseable
-
isClosed
boolean isClosed()
- Returns:
trueif the factory is closed,falseotherwise.
-
addFailoverListener
ClientSessionFactory addFailoverListener(FailoverEventListener listener)
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
boolean removeFailoverListener(FailoverEventListener listener)
Removes a FailoverEventListener to the session.- Parameters:
listener- the listener to remove- Returns:
trueif the listener was removed,falseelse
-
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
-
getConnection
RemotingConnection getConnection()
Returns the code connection used by this session factory.- Returns:
- the core connection
-
getConnectorConfiguration
TransportConfiguration getConnectorConfiguration()
Return the configuration used- Returns:
-
-