public class ClientSessionFactoryImpl extends Object implements ClientSessionFactoryInternal, ConnectionLifeCycleListener
ClientSessionFactory
Modifier and Type | Class and Description |
---|---|
class |
ClientSessionFactoryImpl.CloseRunnable |
Modifier and Type | Field and Description |
---|---|
static Set<ClientSessionFactoryImpl.CloseRunnable> |
CLOSE_RUNNABLES |
Exception |
traceException |
Modifier and Type | Method and Description |
---|---|
void |
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(HornetQComponent component,
Connection connection,
String 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,
HornetQException me)
Called when an error occurs on the connection.
|
void |
connectionReadyForWrites(Object connectionID,
boolean ready) |
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.
|
ClientSession |
createTransactedSession()
Creates a transacted session.
|
ClientSession |
createXASession()
Creates a session with XA transaction semantics.
|
void |
disableFinalizeCheck() |
protected void |
finalize() |
Object |
getBackupConnector() |
ConfirmationWindowWarning |
getConfirmationWindowWarning() |
CoreRemotingConnection |
getConnection()
Returns the code connection used by this session factory.
|
Object |
getConnector() |
TransportConfiguration |
getConnectorConfiguration() |
ServerLocator |
getServerLocator() |
boolean |
isClosed() |
int |
numConnections() |
int |
numSessions() |
boolean |
removeFailoverListener(FailoverEventListener listener)
Removes a FailoverEventListener to the session.
|
boolean |
removeFailureListener(SessionFailureListener listener) |
void |
removeSession(ClientSessionInternal session,
boolean failingOver) |
void |
sendNodeAnnounce(long currentEventID,
String nodeID,
String nodeName,
boolean isBackup,
TransportConfiguration config,
TransportConfiguration backupConfig) |
void |
setBackupConnector(TransportConfiguration live,
TransportConfiguration backUp) |
void |
setReconnectAttempts(int attempts) |
void |
stopPingingAfterOne() |
String |
toString() |
public final Exception traceException
public static final Set<ClientSessionFactoryImpl.CloseRunnable> CLOSE_RUNNABLES
public void disableFinalizeCheck()
disableFinalizeCheck
in interface ClientSessionFactoryInternal
public void connect(int initialConnectAttempts, boolean failoverOnInitialConnection) throws HornetQException
connect
in interface ClientSessionFactoryInternal
HornetQException
public TransportConfiguration getConnectorConfiguration()
getConnectorConfiguration
in interface ClientSessionFactoryInternal
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 HornetQException
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 messagesHornetQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks, int ackBatchSize) throws HornetQException
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 acknowledgementsHornetQException
- if an exception occurs while creating the sessionpublic ClientSession createXASession() throws HornetQException
ClientSessionFactory
createXASession
in interface ClientSessionFactory
HornetQException
- if an exception occurs while creating the sessionpublic ClientSession createTransactedSession() throws HornetQException
ClientSessionFactory
It is up to the client to commit when sending and acknowledging messages.
createTransactedSession
in interface ClientSessionFactory
HornetQException
- if an exception occurs while creating the sessionClientSession.commit()
public ClientSession createSession() throws HornetQException
ClientSessionFactory
createSession
in interface ClientSessionFactory
HornetQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean autoCommitSends, boolean autoCommitAcks) throws HornetQException
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 manuallyHornetQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws HornetQException
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 manuallyHornetQException
- if an exception occurs while creating the sessionpublic ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws HornetQException
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 messagesHornetQException
- if an exception occurs while creating the sessionpublic void connectionCreated(HornetQComponent component, Connection connection, String protocol)
ConnectionLifeCycleListener
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
hornetq-server and hornetq-client packages while avoiding to pull too much into hornetq-core.
The pivotal point keeping us from removing the method is ConnectorFactory
and the
usage of it.
connectionCreated
in interface ConnectionLifeCycleListener
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)
ConnectionLifeCycleListener
connectionDestroyed
in interface ConnectionLifeCycleListener
connectionID
- the connection being destroyed.public void connectionException(Object connectionID, HornetQException me)
ConnectionLifeCycleListener
connectionException
in interface ConnectionLifeCycleListener
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 ConnectionLifeCycleListener
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 void 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 isClosed()
isClosed
in interface ClientSessionFactory
true
if the factory is closed, false
otherwise.public ServerLocator getServerLocator()
getServerLocator
in interface ClientSessionFactory
public void stopPingingAfterOne()
public CoreRemotingConnection getConnection()
ClientSessionFactory
getConnection
in interface ClientSessionFactory
public void sendNodeAnnounce(long currentEventID, String nodeID, String nodeName, boolean isBackup, TransportConfiguration config, TransportConfiguration backupConfig)
sendNodeAnnounce
in interface ClientSessionFactoryInternal
protected void finalize() throws Throwable
public void setReconnectAttempts(int attempts)
setReconnectAttempts
in interface ClientSessionFactoryInternal
public Object getConnector()
getConnector
in interface ClientSessionFactoryInternal
public ConfirmationWindowWarning getConfirmationWindowWarning()
getConfirmationWindowWarning
in interface ClientSessionFactoryInternal
Copyright © 2016 JBoss, a division of Red Hat. All rights reserved.