public class ClientSessionFactoryImpl extends Object implements ClientSessionFactoryInternal, ClientConnectionLifeCycleListener
| Modifier and Type | Class and Description |
|---|---|
class |
ClientSessionFactoryImpl.CloseRunnable |
| Modifier and Type | Field and Description |
|---|---|
static Set<ClientSessionFactoryImpl.CloseRunnable> |
CLOSE_RUNNABLES |
Exception |
createTrace |
| Constructor and Description |
|---|
ClientSessionFactoryImpl(ServerLocatorInternal serverLocator,
TransportConfiguration connectorConfig,
long callTimeout,
long callFailoverTimeout,
long clientFailureCheckPeriod,
long connectionTTL,
long retryInterval,
double retryIntervalMultiplier,
long maxRetryInterval,
int reconnectAttempts,
Executor threadPool,
ScheduledExecutorService scheduledThreadPool,
List<Interceptor> incomingInterceptors,
List<Interceptor> outgoingInterceptors) |
| Modifier and Type | Method and Description |
|---|---|
ClientSessionFactoryImpl |
addFailoverListener(FailoverEventListener listener)
Adds a FailoverEventListener to the session which is notified if a failover event occurs on the session.
|
void |
addFailureListener(SessionFailureListener listener) |
void |
causeExit() |
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.
|
void |
connect(int initialConnectAttempts,
boolean failoverOnInitialConnection) |
void |
connectionCreated(ActiveMQComponent component,
Connection connection,
ClientProtocolManager protocol)
This method is used both by client connector creation and server connection creation through
acceptors.
|
void |
connectionDestroyed(Object connectionID)
Called when a connection is destroyed.
|
void |
connectionException(Object connectionID,
ActiveMQException me)
Called when an error occurs on the connection.
|
void |
connectionReadyForWrites(Object connectionID,
boolean ready) |
protected Connector |
createConnector(ConnectorFactory connectorFactory,
TransportConfiguration configuration) |
ClientSession |
createSession()
Creates a non-transacted session.
|
ClientSession |
createSession(boolean autoCommitSends,
boolean autoCommitAcks)
Creates a session.
|
ClientSession |
createSession(boolean xa,
boolean autoCommitSends,
boolean autoCommitAcks)
Creates a session.
|
ClientSession |
createSession(boolean xa,
boolean autoCommitSends,
boolean autoCommitAcks,
boolean preAcknowledge)
Creates a session.
|
ClientSession |
createSession(boolean autoCommitSends,
boolean autoCommitAcks,
int ackBatchSize)
Creates a session.
|
ClientSession |
createSession(String username,
String password,
boolean xa,
boolean autoCommitSends,
boolean autoCommitAcks,
boolean preAcknowledge,
int ackBatchSize)
Creates an authenticated session.
|
protected SessionContext |
createSessionChannel(String name,
String username,
String password,
boolean xa,
boolean autoCommitSends,
boolean autoCommitAcks,
boolean preAcknowledge) |
ClientSession |
createTransactedSession()
Creates a transacted session.
|
protected Connection |
createTransportConnection()
It will connect to either live or backup accordingly to the current configurations
it will also switch to backup case it can't connect to live and there's a backup configured
|
ClientSession |
createXASession()
Creates a session with XA transaction semantics.
|
void |
disableFinalizeCheck() |
protected RemotingConnection |
establishNewConnection() |
protected void |
finalize() |
Object |
getBackupConnector() |
ConfirmationWindowWarning |
getConfirmationWindowWarning() |
RemotingConnection |
getConnection()
Returns the code connection used by this session factory.
|
Object |
getConnector() |
TransportConfiguration |
getConnectorConfiguration()
Return the configuration used
|
String |
getLiveNodeId() |
int |
getReconnectAttempts() |
ServerLocator |
getServerLocator() |
protected ConnectorFactory |
instantiateConnectorFactory(String connectorFactoryClassName) |
boolean |
isClosed() |
Lock |
lockFailover() |
int |
numConnections() |
int |
numSessions() |
protected Connection |
openTransportConnection(Connector connector) |
boolean |
removeFailoverListener(FailoverEventListener listener)
Removes a FailoverEventListener to the session.
|
boolean |
removeFailureListener(SessionFailureListener listener) |
void |
removeSession(ClientSessionInternal session,
boolean failingOver) |
protected void |
schedulePing() |
void |
setBackupConnector(TransportConfiguration live,
TransportConfiguration backUp) |
void |
setReconnectAttempts(int attempts) |
void |
stopPingingAfterOne() |
boolean |
waitForTopology(long timeout,
TimeUnit unit) |
public final Exception createTrace
public static final Set<ClientSessionFactoryImpl.CloseRunnable> CLOSE_RUNNABLES
public ClientSessionFactoryImpl(ServerLocatorInternal serverLocator, TransportConfiguration connectorConfig, long callTimeout, long callFailoverTimeout, long clientFailureCheckPeriod, long connectionTTL, long retryInterval, double retryIntervalMultiplier, long maxRetryInterval, int reconnectAttempts, Executor threadPool, ScheduledExecutorService scheduledThreadPool, List<Interceptor> incomingInterceptors, List<Interceptor> outgoingInterceptors)
public void disableFinalizeCheck()
disableFinalizeCheck in interface ClientSessionFactoryInternalpublic Lock lockFailover()
lockFailover in interface ClientSessionFactoryInternalpublic void connect(int initialConnectAttempts,
boolean failoverOnInitialConnection)
throws ActiveMQException
connect in interface ClientSessionFactoryInternalActiveMQExceptionpublic TransportConfiguration getConnectorConfiguration()
ClientSessionFactorygetConnectorConfiguration in interface ClientSessionFactorypublic void setBackupConnector(TransportConfiguration live, TransportConfiguration backUp)
setBackupConnector in interface ClientSessionFactoryInternalpublic Object getBackupConnector()
getBackupConnector in interface ClientSessionFactoryInternalpublic ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize) throws ActiveMQException
ClientSessionFactoryIt 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.
createSession in interface ClientSessionFactoryusername - 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 messagesActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) throws ActiveMQException
ClientSessionFactorycreateSession in interface ClientSessionFactoryautoCommitSends - 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 acknowledgementsActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createXASession() throws ActiveMQException
ClientSessionFactorycreateXASession in interface ClientSessionFactoryActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createTransactedSession() throws ActiveMQException
ClientSessionFactoryIt is up to the client to commit when sending and acknowledging messages.
createTransactedSession in interface ClientSessionFactoryActiveMQException - if an exception occurs while creating the sessionClientSession.commit()public ClientSession createSession() throws ActiveMQException
ClientSessionFactorycreateSession in interface ClientSessionFactoryActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException
ClientSessionFactorycreateSession in interface ClientSessionFactoryautoCommitSends - true to automatically commit message sends, false to commit manuallyautoCommitAcks - true to automatically commit message acknowledgement, false to commit manuallyActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException
ClientSessionFactorycreateSession in interface ClientSessionFactoryxa - 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 manuallyActiveMQException - if an exception occurs while creating the sessionpublic ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException
ClientSessionFactoryIt 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.
createSession in interface ClientSessionFactoryxa - 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 messagesActiveMQException - if an exception occurs while creating the sessionpublic void connectionCreated(ActiveMQComponent component, Connection connection, ClientProtocolManager protocol)
BaseConnectionLifeCycleListenercomponent parameter is normally passed as
null.
Leaving this method here and adding a different one at
ServerConnectionLifeCycleListener is 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 is ConnectorFactory and the
usage of it.
connectionCreated in interface BaseConnectionLifeCycleListener<ClientProtocolManager>component - This will probably be an Acceptor and only used on the server side.connection - the connection that has been createdprotocol - the messaging protocol type this connection usespublic void connectionDestroyed(Object connectionID)
BaseConnectionLifeCycleListenerconnectionDestroyed in interface BaseConnectionLifeCycleListener<ClientProtocolManager>connectionID - the connection being destroyed.public void connectionException(Object connectionID, ActiveMQException me)
BaseConnectionLifeCycleListenerconnectionException in interface BaseConnectionLifeCycleListener<ClientProtocolManager>connectionID - the id of the connection.me - the exception.public void removeSession(ClientSessionInternal session, boolean failingOver)
removeSession in interface ClientSessionFactoryInternalpublic void connectionReadyForWrites(Object connectionID, boolean ready)
connectionReadyForWrites in interface BaseConnectionLifeCycleListener<ClientProtocolManager>public int numConnections()
numConnections in interface ClientSessionFactoryInternalpublic int numSessions()
numSessions in interface ClientSessionFactoryInternalpublic void addFailureListener(SessionFailureListener listener)
addFailureListener in interface ClientSessionFactoryInternalpublic boolean removeFailureListener(SessionFailureListener listener)
removeFailureListener in interface ClientSessionFactoryInternalpublic ClientSessionFactoryImpl addFailoverListener(FailoverEventListener listener)
ClientSessionFactoryaddFailoverListener in interface ClientSessionFactorylistener - the listener to addpublic boolean removeFailoverListener(FailoverEventListener listener)
ClientSessionFactoryremoveFailoverListener in interface ClientSessionFactorylistener - the listener to removetrue if the listener was removed, false elsepublic void causeExit()
causeExit in interface ClientSessionFactoryInternalpublic void close()
ClientSessionFactoryclose in interface AutoCloseableclose in interface ClientSessionFactorypublic void cleanup()
ClientSessionFactorycleanup in interface ClientSessionFactorypublic boolean waitForTopology(long timeout,
TimeUnit unit)
waitForTopology in interface ClientSessionFactoryInternalpublic boolean isClosed()
isClosed in interface ClientSessionFactorytrue if the factory is closed, false otherwise.public ServerLocator getServerLocator()
getServerLocator in interface ClientSessionFactorypublic void stopPingingAfterOne()
public RemotingConnection getConnection()
ClientSessionFactorygetConnection in interface ClientSessionFactoryprotected void schedulePing()
protected void finalize()
throws Throwable
protected ConnectorFactory instantiateConnectorFactory(String connectorFactoryClassName)
public void setReconnectAttempts(int attempts)
setReconnectAttempts in interface ClientSessionFactoryInternalpublic int getReconnectAttempts()
public Object getConnector()
getConnector in interface ClientSessionFactoryInternalpublic ConfirmationWindowWarning getConfirmationWindowWarning()
getConfirmationWindowWarning in interface ClientSessionFactoryInternalprotected Connection openTransportConnection(Connector connector)
protected Connector createConnector(ConnectorFactory connectorFactory, TransportConfiguration configuration)
protected Connection createTransportConnection()
protected RemotingConnection establishNewConnection()
protected SessionContext createSessionChannel(String name, String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException
ActiveMQExceptionpublic String getLiveNodeId()
getLiveNodeId in interface ClientSessionFactoryInternalCopyright © 2018 JBoss by Red Hat. All rights reserved.