Class ClientSessionFactoryImpl
- All Implemented Interfaces:
AutoCloseable,ClientSessionFactory,ClientSessionFactoryInternal,BaseConnectionLifeCycleListener<ClientProtocolManager>,ClientConnectionLifeCycleListener
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<ClientSessionFactoryImpl.CloseRunnable>final Exception -
Constructor Summary
ConstructorsConstructorDescriptionClientSessionFactoryImpl(ServerLocatorInternal serverLocator, TransportConfiguration connectorConfig, ServerLocatorConfig locatorConfig, int reconnectAttempts, Executor threadPool, ScheduledExecutorService scheduledThreadPool, Executor flowControlThreadPool, List<Interceptor> incomingInterceptors, List<Interceptor> outgoingInterceptors) -
Method Summary
Modifier and TypeMethodDescriptionaddFailoverListener(FailoverEventListener listener) Adds a FailoverEventListener to the session which is notified if a failover event occurs on the session.voidaddFailureListener(SessionFailureListener listener) voidvoidcleanup()Opposed to close, will call cleanup only on every created session and children objects.voidclose()Closes this factory and any session created by it.voidconnect(int initialConnectAttempts) voidconnect(int initialConnectAttempts, boolean failoverOnInitialConnection) Deprecated.voidconnectionCreated(ActiveMQComponent component, Connection connection, ClientProtocolManager protocol) This method is used both by client connector creation and server connection creation through acceptors.voidconnectionDestroyed(Object connectionID, boolean failed) Called when a connection is destroyed.voidconnectionException(Object connectionID, ActiveMQException me) Called when an error occurs on the connection.voidconnectionReadyForWrites(Object connectionID, boolean ready) protected ConnectorcreateConnector(ConnectorFactory connectorFactory, TransportConfiguration configuration) 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.protected SessionContextcreateSessionChannel(String name, String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, String clientID) Creates a transacted session.protected ConnectionIt will connect to either primary or backup accordingly to the current configurations it will also switch to backup case it can't connect to primary and there's a backup configuredCreates a session with XA transaction semantics.protected RemotingConnectionvoidflushCloseExecutor(int time, TimeUnit unit) Returns the code connection used by this session factory.Returns the configuration used.intReturns the server locator associated with this session factory.protected ConnectorFactoryinstantiateConnectorFactory(String connectorFactoryClassName) booleanisClosed()Returnstrueif the factory is closed,falseotherwise.intintprotected ConnectionopenTransportConnection(Connector connector) booleanremoveFailoverListener(FailoverEventListener listener) Removes a FailoverEventListener to the session.booleanremoveFailureListener(SessionFailureListener listener) voidremoveSession(ClientSessionInternal session, boolean failingOver) protected voidvoidsetBackupConnector(TransportConfiguration primary, TransportConfiguration backUp) voidsetReconnectAttempts(int attempts) voidbooleanwaitForRetry(long interval) booleanwaitForTopology(long timeout, TimeUnit unit)
-
Field Details
-
createTrace
-
CLOSE_RUNNABLES
-
-
Constructor Details
-
ClientSessionFactoryImpl
public ClientSessionFactoryImpl(ServerLocatorInternal serverLocator, TransportConfiguration connectorConfig, ServerLocatorConfig locatorConfig, int reconnectAttempts, Executor threadPool, ScheduledExecutorService scheduledThreadPool, Executor flowControlThreadPool, List<Interceptor> incomingInterceptors, List<Interceptor> outgoingInterceptors)
-
-
Method Details
-
lockFailover
- Specified by:
lockFailoverin interfaceClientSessionFactoryInternal
-
connect
- Specified by:
connectin interfaceClientSessionFactoryInternal- Throws:
ActiveMQException
-
connect
@Deprecated public void connect(int initialConnectAttempts, boolean failoverOnInitialConnection) throws ActiveMQException Deprecated.- Specified by:
connectin interfaceClientSessionFactoryInternal- Throws:
ActiveMQException
-
getConnectorConfiguration
Description copied from interface:ClientSessionFactoryReturns the configuration used.- Specified by:
getConnectorConfigurationin interfaceClientSessionFactory- Returns:
- the configuration used
-
setBackupConnector
- Specified by:
setBackupConnectorin interfaceClientSessionFactoryInternal
-
getBackupConnector
- Specified by:
getBackupConnectorin interfaceClientSessionFactoryInternal
-
createSession
public ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize, String clientID) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates 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.
- Specified by:
createSessionin interfaceClientSessionFactory- 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
-
createSession
public ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates 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.
- Specified by:
createSessionin interfaceClientSessionFactory- 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
public ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates a session.- Specified by:
createSessionin interfaceClientSessionFactory- 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
-
createXASession
Description copied from interface:ClientSessionFactoryCreates a session with XA transaction semantics.- Specified by:
createXASessionin interfaceClientSessionFactory- Returns:
- a ClientSession with XA transaction semantics
- Throws:
ActiveMQException- if an exception occurs while creating the session
-
createTransactedSession
Description copied from interface:ClientSessionFactoryCreates a transacted session.It is up to the client to commit when sending and acknowledging messages.
- Specified by:
createTransactedSessionin interfaceClientSessionFactory- Returns:
- a transacted ClientSession
- Throws:
ActiveMQException- if an exception occurs while creating the session- See Also:
-
createSession
Description copied from interface:ClientSessionFactoryCreates 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.- Specified by:
createSessionin interfaceClientSessionFactory- Returns:
- a non-transacted ClientSession
- Throws:
ActiveMQException- if an exception occurs while creating the session
-
createSession
public ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates a session.- Specified by:
createSessionin interfaceClientSessionFactory- 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
public ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates a session.- Specified by:
createSessionin interfaceClientSessionFactory- 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
public ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException Description copied from interface:ClientSessionFactoryCreates 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.
- Specified by:
createSessionin interfaceClientSessionFactory- 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
-
connectionCreated
public void connectionCreated(ActiveMQComponent component, Connection connection, ClientProtocolManager protocol) Description copied from interface:BaseConnectionLifeCycleListenerThis method is used both by client connector creation and server connection creation through acceptors. On the client side thecomponentparameter is normally passed asnull.Leaving this method here and adding a different one at
ServerConnectionLifeCycleListeneris a compromise for a reasonable split between the activemq-server and activemq-client packages while avoiding to pull too much into activemq-core. The pivotal point keeping us from removing the method isConnectorFactoryand the usage of it.- Specified by:
connectionCreatedin interfaceBaseConnectionLifeCycleListener<ClientProtocolManager>- Parameters:
component- This will probably be anAcceptorand only used on the server side.connection- the connection that has been createdprotocol- the messaging protocol type this connection uses
-
connectionDestroyed
Description copied from interface:BaseConnectionLifeCycleListenerCalled when a connection is destroyed.- Specified by:
connectionDestroyedin interfaceBaseConnectionLifeCycleListener<ClientProtocolManager>- Parameters:
connectionID- the connection being destroyed.
-
connectionException
Description copied from interface:BaseConnectionLifeCycleListenerCalled when an error occurs on the connection.- Specified by:
connectionExceptionin interfaceBaseConnectionLifeCycleListener<ClientProtocolManager>- Parameters:
connectionID- the id of the connection.me- the exception.
-
removeSession
- Specified by:
removeSessionin interfaceClientSessionFactoryInternal
-
connectionReadyForWrites
- Specified by:
connectionReadyForWritesin interfaceBaseConnectionLifeCycleListener<ClientProtocolManager>
-
numConnections
public int numConnections()- Specified by:
numConnectionsin interfaceClientSessionFactoryInternal
-
numSessions
public int numSessions()- Specified by:
numSessionsin interfaceClientSessionFactoryInternal
-
addFailureListener
- Specified by:
addFailureListenerin interfaceClientSessionFactoryInternal
-
removeFailureListener
- Specified by:
removeFailureListenerin interfaceClientSessionFactoryInternal
-
addFailoverListener
Description copied from interface:ClientSessionFactoryAdds a FailoverEventListener to the session which is notified if a failover event occurs on the session.- Specified by:
addFailoverListenerin interfaceClientSessionFactory- Parameters:
listener- the listener to add- Returns:
- this ClientSessionFactory
-
removeFailoverListener
Description copied from interface:ClientSessionFactoryRemoves a FailoverEventListener to the session.- Specified by:
removeFailoverListenerin interfaceClientSessionFactory- Parameters:
listener- the listener to remove- Returns:
trueif the listener was removed,falseelse
-
causeExit
public void causeExit()- Specified by:
causeExitin interfaceClientSessionFactoryInternal
-
close
public void close()Description copied from interface:ClientSessionFactoryCloses this factory and any session created by it.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceClientSessionFactory
-
cleanup
public void cleanup()Description copied from interface:ClientSessionFactoryOpposed to close, will call cleanup only on every created session and children objects.- Specified by:
cleanupin interfaceClientSessionFactory
-
waitForTopology
- Specified by:
waitForTopologyin interfaceClientSessionFactoryInternal
-
isClosed
public boolean isClosed()Description copied from interface:ClientSessionFactoryReturnstrueif the factory is closed,falseotherwise.- Specified by:
isClosedin interfaceClientSessionFactory- Returns:
trueif the factory is closed,falseotherwise
-
getServerLocator
Description copied from interface:ClientSessionFactoryReturns the server locator associated with this session factory.- Specified by:
getServerLocatorin interfaceClientSessionFactory- Returns:
- the server locator associated with this session factory
-
stopPingingAfterOne
public void stopPingingAfterOne() -
waitForRetry
public boolean waitForRetry(long interval) - Specified by:
waitForRetryin interfaceClientSessionFactoryInternal
-
getConnection
Description copied from interface:ClientSessionFactoryReturns the code connection used by this session factory.- Specified by:
getConnectionin interfaceClientSessionFactory- Returns:
- the code connection used by this session factory
-
schedulePing
protected void schedulePing() -
instantiateConnectorFactory
-
setReconnectAttempts
public void setReconnectAttempts(int attempts) - Specified by:
setReconnectAttemptsin interfaceClientSessionFactoryInternal
-
getReconnectAttempts
public int getReconnectAttempts() -
getConnector
- Specified by:
getConnectorin interfaceClientSessionFactoryInternal
-
getConfirmationWindowWarning
- Specified by:
getConfirmationWindowWarningin interfaceClientSessionFactoryInternal
-
openTransportConnection
-
createConnector
protected Connector createConnector(ConnectorFactory connectorFactory, TransportConfiguration configuration) -
createTransportConnection
It will connect to either primary or backup accordingly to the current configurations it will also switch to backup case it can't connect to primary and there's a backup configured -
establishNewConnection
-
createSessionChannel
protected SessionContext createSessionChannel(String name, String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, String clientID) throws ActiveMQException - Throws:
ActiveMQException
-
getPrimaryNodeId
- Specified by:
getPrimaryNodeIdin interfaceClientSessionFactoryInternal
-
flushCloseExecutor
-