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 ClientSessionFactoryInternal
public Lock lockFailover()
lockFailover
in interface ClientSessionFactoryInternal
public void connect(int initialConnectAttempts, boolean failoverOnInitialConnection) throws ActiveMQException
connect
in interface ClientSessionFactoryInternal
ActiveMQException
public TransportConfiguration getConnectorConfiguration()
ClientSessionFactory
getConnectorConfiguration
in interface ClientSessionFactory
public void setBackupConnector(TransportConfiguration live, TransportConfiguration backUp)
setBackupConnector
in interface ClientSessionFactoryInternal
public Object getBackupConnector()
getBackupConnector
in interface ClientSessionFactoryInternal
public ClientSession createSession(String username, String password, boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, int ackBatchSize) throws ActiveMQException
ClientSessionFactory
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.
createSession
in interface ClientSessionFactory
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 messagesActiveMQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) throws ActiveMQException
ClientSessionFactory
createSession
in interface ClientSessionFactory
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 acknowledgementsActiveMQException
- if an exception occurs while creating the sessionpublic ClientSession createXASession() throws ActiveMQException
ClientSessionFactory
createXASession
in interface ClientSessionFactory
ActiveMQException
- if an exception occurs while creating the sessionpublic ClientSession createTransactedSession() throws ActiveMQException
ClientSessionFactory
It is up to the client to commit when sending and acknowledging messages.
createTransactedSession
in interface ClientSessionFactory
ActiveMQException
- if an exception occurs while creating the sessionClientSession.commit()
public ClientSession createSession() throws ActiveMQException
ClientSessionFactory
createSession
in interface ClientSessionFactory
ActiveMQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks) throws ActiveMQException
ClientSessionFactory
createSession
in interface ClientSessionFactory
autoCommitSends
- 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
ClientSessionFactory
createSession
in interface ClientSessionFactory
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 manuallyActiveMQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws ActiveMQException
ClientSessionFactory
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.
createSession
in interface ClientSessionFactory
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 messagesActiveMQException
- if an exception occurs while creating the sessionpublic void connectionCreated(ActiveMQComponent component, Connection connection, ClientProtocolManager protocol)
BaseConnectionLifeCycleListener
component
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)
BaseConnectionLifeCycleListener
connectionDestroyed
in interface BaseConnectionLifeCycleListener<ClientProtocolManager>
connectionID
- the connection being destroyed.public void connectionException(Object connectionID, ActiveMQException me)
BaseConnectionLifeCycleListener
connectionException
in interface BaseConnectionLifeCycleListener<ClientProtocolManager>
connectionID
- the id of the connection.me
- the exception.public void removeSession(ClientSessionInternal session, boolean failingOver)
removeSession
in interface ClientSessionFactoryInternal
public void connectionReadyForWrites(Object connectionID, boolean ready)
connectionReadyForWrites
in interface BaseConnectionLifeCycleListener<ClientProtocolManager>
public int numConnections()
numConnections
in interface ClientSessionFactoryInternal
public int numSessions()
numSessions
in interface ClientSessionFactoryInternal
public void addFailureListener(SessionFailureListener listener)
addFailureListener
in interface ClientSessionFactoryInternal
public boolean removeFailureListener(SessionFailureListener listener)
removeFailureListener
in interface ClientSessionFactoryInternal
public ClientSessionFactoryImpl addFailoverListener(FailoverEventListener listener)
ClientSessionFactory
addFailoverListener
in interface ClientSessionFactory
listener
- the listener to addpublic boolean removeFailoverListener(FailoverEventListener listener)
ClientSessionFactory
removeFailoverListener
in interface ClientSessionFactory
listener
- the listener to removetrue
if the listener was removed, false
elsepublic void causeExit()
causeExit
in interface ClientSessionFactoryInternal
public void close()
ClientSessionFactory
close
in interface AutoCloseable
close
in interface ClientSessionFactory
public void cleanup()
ClientSessionFactory
cleanup
in interface ClientSessionFactory
public boolean waitForTopology(long timeout, TimeUnit unit)
waitForTopology
in interface ClientSessionFactoryInternal
public boolean isClosed()
isClosed
in interface ClientSessionFactory
true
if the factory is closed, false
otherwise.public ServerLocator getServerLocator()
getServerLocator
in interface ClientSessionFactory
public void stopPingingAfterOne()
public RemotingConnection getConnection()
ClientSessionFactory
getConnection
in interface ClientSessionFactory
protected void schedulePing()
protected void finalize() throws Throwable
protected ConnectorFactory instantiateConnectorFactory(String connectorFactoryClassName)
public void setReconnectAttempts(int attempts)
setReconnectAttempts
in interface ClientSessionFactoryInternal
public int getReconnectAttempts()
public Object getConnector()
getConnector
in interface ClientSessionFactoryInternal
public ConfirmationWindowWarning getConfirmationWindowWarning()
getConfirmationWindowWarning
in interface ClientSessionFactoryInternal
protected 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
ActiveMQException
public String getLiveNodeId()
getLiveNodeId
in interface ClientSessionFactoryInternal
Copyright © 2019 JBoss by Red Hat. All rights reserved.