org.hornetq.api.core.client
Interface ClientSessionFactory


public interface ClientSessionFactory

A ClientSessionFactory is the entry point to create and configure HornetQ 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 a IllegalStateException.

Author:
Tim Fox

Method Summary
 void addInterceptor(Interceptor interceptor)
          Adds an interceptor which will be executed after packets are received from the server.
 void close()
          Closes this factory and release all its resources
 ClientSessionFactory copy()
          Creates a copy of this factory.
 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.
 int getAckBatchSize()
          Returns the acknowledgements batch size.
 long getCallTimeout()
          Returns the blocking calls timeout.
 long getClientFailureCheckPeriod()
          Returns the period used to check if a client has failed to receive pings from the server.
 int getConfirmationWindowSize()
          Returns the size for the confirmation window of clients using this factory.
 String getConnectionLoadBalancingPolicyClassName()
          Returns the class name of the connection load balancing policy.
 long getConnectionTTL()
          Returns the connection time-to-live.
 int getConsumerMaxRate()
          Returns the maximum rate of message consumption for consumers created through this factory.
 int getConsumerWindowSize()
          Returns the window size for flow control of the consumers created through this factory.
 String getDiscoveryAddress()
          Returns the address to listen to discover which connectors this factory can use.
 long getDiscoveryInitialWaitTimeout()
          Returns the initial wait timeout if this factory is configured to use discovery.
 int getDiscoveryPort()
          Returns the port to listen to discover which connectors this factory can use.
 long getDiscoveryRefreshTimeout()
          Returns the refresh timeout for discovered HornetQ servers.
 String getGroupID()
          Returns the group ID that will be eventually set on each message for the property Message.HDR_GROUP_ID.
 int getInitialMessagePacketSize()
          Returns the initial size of messages created through this factory.
 String getLocalBindAddress()
          Returns the local bind address to which the multicast socket is bound for discovery.
 long getMaxRetryInterval()
          Returns the maximum retry interval (in the case a retry interval multiplier has been specified).
 int getMinLargeMessageSize()
          Returns the large message size threshold.
 int getProducerMaxRate()
          Returns the maximum rate of message production for producers created through this factory.
 int getProducerWindowSize()
          Returns the window size for flow control of the producers created through this factory.
 int getReconnectAttempts()
          Returns the maximum number of attempts to retry connection in case of failure.
 long getRetryInterval()
          Returns the time to retry connections created by this factory after failure.
 double getRetryIntervalMultiplier()
          Returns the multiplier to apply to successive retry intervals.
 int getScheduledThreadPoolMaxSize()
          Returns the maximum size of the scheduled thread pool.
 List<Pair<TransportConfiguration,TransportConfiguration>> getStaticConnectors()
          Returns the list of live - backup connectors pairs configured that sessions created by this factory will use to connect to HornetQ servers or null if the factory is using discovery group.
 int getThreadPoolMaxSize()
          Returns the maximum size of the thread pool.
 boolean isAutoGroup()
          Returns whether producers created through this factory will automatically assign a group ID to the messages they sent.
 boolean isBlockOnAcknowledge()
          Returns whether consumers created through this factory will block while sending message acknowledgements or do it asynchronously.
 boolean isBlockOnDurableSend()
          Returns whether producers created through this factory will block while sending durable messages or do it asynchronously.
 boolean isBlockOnNonDurableSend()
          Returns whether producers created through this factory will block while sending non-durable messages or do it asynchronously.
 boolean isCacheLargeMessagesClient()
          When true, consumers created through this factory will create temporary files to cache large messages.
 boolean isFailoverOnInitialConnection()
          Returns true if the client will automatically attempt to connect to the backup server if the initial connection to the live server fails Default value is HornetQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION.
 boolean isFailoverOnServerShutdown()
          Returns whether connections created by this factory must failover in case the server they are connected to has normally shut down.
 boolean isPreAcknowledge()
          Returns whether messages will pre-acknowledged on the server before they are sent to the consumers or not.
 boolean isUseGlobalPools()
          Returns whether this factory will use global thread pools (shared among all the factories in the same JVM) or its own pools.
 boolean removeInterceptor(Interceptor interceptor)
          Removes an interceptor.
 void setAckBatchSize(int ackBatchSize)
          Sets the acknowledgements batch size.
 void setAutoGroup(boolean autoGroup)
          Sets whether producers created through this factory will automatically assign a group ID to the messages they sent.
 void setBlockOnAcknowledge(boolean blockOnAcknowledge)
          Sets whether consumers created through this factory will block while sending message acknowledgements or do it asynchronously.
 void setBlockOnDurableSend(boolean blockOnDurableSend)
          Sets whether producers created through this factory will block while sending durable messages or do it asynchronously.
 void setBlockOnNonDurableSend(boolean blockOnNonDurableSend)
          Sets whether producers created through this factory will block while sending non-durable messages or do it asynchronously.
 void setCacheLargeMessagesClient(boolean cached)
          Sets whether large messages received by consumers created through this factory will be cached in temporary files or not.
 void setCallTimeout(long callTimeout)
          Sets the blocking call timeout.
 void setClientFailureCheckPeriod(long clientFailureCheckPeriod)
          Sets the period (in milliseconds) used to check if a client has failed to receive pings from the server.
 void setConfirmationWindowSize(int confirmationWindowSize)
          Sets the size for the confirmation window buffer of clients using this factory.
 void setConnectionLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
          Sets the class name of the connection load balancing policy.
 void setConnectionTTL(long connectionTTL)
          Sets this factory's connections time-to-live.
 void setConsumerMaxRate(int consumerMaxRate)
          Sets the maximum rate of message consumption for consumers created through this factory.
 void setConsumerWindowSize(int consumerWindowSize)
          Sets the window size for flow control of the consumers created through this factory.
 void setDiscoveryAddress(String discoveryAddress)
          Sets the address to listen to discover which connectors this factory can use.
 void setDiscoveryInitialWaitTimeout(long initialWaitTimeout)
          Sets the initial wait timeout if this factory is configured to use discovery.
 void setDiscoveryPort(int discoveryPort)
          Sets the port to listen to discover which connectors this factory can use.
 void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout)
          Sets the refresh timeout for discovered HornetQ servers.
 void setFailoverOnInitialConnection(boolean failover)
          Sets the value for FailoverOnInitialReconnection
 void setFailoverOnServerShutdown(boolean failoverOnServerShutdown)
          Sets whether connections created by this factory must failover in case the server they are connected to has normally shut down
 void setGroupID(String groupID)
          Sets the group ID that will be set on each message sent through this factory.
 void setInitialMessagePacketSize(int size)
          Sets the initial size of messages created through this factory.
 void setLocalBindAddress(String localBindAddress)
          Sets the local bind address to which the multicast socket is bound for discovery.
 void setMaxRetryInterval(long maxRetryInterval)
          Sets the maximum retry interval.
 void setMinLargeMessageSize(int minLargeMessageSize)
          Sets the large message size threshold.
 void setPreAcknowledge(boolean preAcknowledge)
          Sets to true to pre-acknowledge consumed messages on the server before they are sent to consumers, else set to false to let clients acknowledge the message they consume.
 void setProducerMaxRate(int producerMaxRate)
          Sets the maximum rate of message production for producers created through this factory.
 void setProducerWindowSize(int producerWindowSize)
          Returns the window size for flow control of the producers created through this factory.
 void setReconnectAttempts(int reconnectAttempts)
          Sets the maximum number of attempts to retry connection in case of failure.
 void setRetryInterval(long retryInterval)
          Sets the time to retry connections created by this factory after failure.
 void setRetryIntervalMultiplier(double retryIntervalMultiplier)
          Sets the multiplier to apply to successive retry intervals.
 void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
          Sets the maximum size of the scheduled thread pool.
 void setStaticConnectors(List<Pair<TransportConfiguration,TransportConfiguration>> staticConnectors)
          Sets the static list of live - backup connectors pairs that sessions created by this factory will use to connect to HornetQ servers.
 void setThreadPoolMaxSize(int threadPoolMaxSize)
          Sets the maximum size of the thread pool.
 void setUseGlobalPools(boolean useGlobalPools)
          Sets whether this factory will use global thread pools (shared among all the factories in the same JVM) or its own pools.
 

Method Detail

createXASession

ClientSession createXASession()
                              throws HornetQException
Creates a session with XA transaction semantics.

Returns:
a ClientSession with XA transaction semantics
Throws:
HornetQException - if an exception occurs while creating the session

createTransactedSession

ClientSession createTransactedSession()
                                      throws HornetQException
Creates a transacted session. It is up to the client to commit when sending and acknowledging messages.

Returns:
a transacted ClientSession
Throws:
HornetQException - if an exception occurs while creating the session
See Also:
ClientSession.commit()

createSession

ClientSession createSession()
                            throws HornetQException
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:
HornetQException - if an exception occurs while creating the session

createSession

ClientSession createSession(boolean autoCommitSends,
                            boolean autoCommitAcks)
                            throws HornetQException
Creates a session.

Parameters:
autoCommitSends - true to automatically commit message sends, false to commit manually
autoCommitAcks - true to automatically commit message acknowledgement, false to commit manually
Returns:
a ClientSession
Throws:
HornetQException - if an exception occurs while creating the session

createSession

ClientSession createSession(boolean autoCommitSends,
                            boolean autoCommitAcks,
                            int ackBatchSize)
                            throws HornetQException
Creates a session.

Parameters:
autoCommitSends - true to automatically commit message sends, false to commit manually
autoCommitAcks - true to automatically commit message acknowledgement, false to commit manually
ackBatchSize - the batch size of the acknowledgements
Returns:
a ClientSession
Throws:
HornetQException - if an exception occurs while creating the session

createSession

ClientSession createSession(boolean xa,
                            boolean autoCommitSends,
                            boolean autoCommitAcks)
                            throws HornetQException
Creates a session.

Parameters:
xa - whether the session support XA transaction semantic or not
autoCommitSends - true to automatically commit message sends, false to commit manually
autoCommitAcks - true to automatically commit message acknowledgement, false to commit manually
Returns:
a ClientSession
Throws:
HornetQException - if an exception occurs while creating the session

createSession

ClientSession createSession(boolean xa,
                            boolean autoCommitSends,
                            boolean autoCommitAcks,
                            boolean preAcknowledge)
                            throws HornetQException
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 not
autoCommitSends - true to automatically commit message sends, false to commit manually
autoCommitAcks - true to automatically commit message acknowledgement, false to commit manually
preAcknowledge - true to pre-acknowledge messages on the server, false to let the client acknowledge the messages
Returns:
a ClientSession
Throws:
HornetQException - 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 HornetQException
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 name
password - the user password
xa - whether the session support XA transaction semantic or not
autoCommitSends - true to automatically commit message sends, false to commit manually
autoCommitAcks - true to automatically commit message acknowledgement, false to commit manually
preAcknowledge - true to pre-acknowledge messages on the server, false to let the client acknowledge the messages
Returns:
a ClientSession
Throws:
HornetQException - if an exception occurs while creating the session

getStaticConnectors

List<Pair<TransportConfiguration,TransportConfiguration>> getStaticConnectors()
Returns the list of live - backup connectors pairs configured that sessions created by this factory will use to connect to HornetQ servers or null if the factory is using discovery group. The backup configuration (returned by Pair.b) can be null if there is no backup for the corresponding live configuration (returned by Pair.a)

Returns:
a list of pair of TransportConfiguration corresponding to the live - backup nodes

setStaticConnectors

void setStaticConnectors(List<Pair<TransportConfiguration,TransportConfiguration>> staticConnectors)
Sets the static list of live - backup connectors pairs that sessions created by this factory will use to connect to HornetQ servers. The backup configuration (returned by Pair.b) can be null if there is no backup for the corresponding live configuration (returned by Pair.a)

Parameters:
staticConnectors - a list of pair of TransportConfiguration corresponding to the live - backup nodes

getClientFailureCheckPeriod

long getClientFailureCheckPeriod()
Returns the period used to check if a client has failed to receive pings from the server. Period is in milliseconds, default value is HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD.

Returns:
the period used to check if a client has failed to receive pings from the server

setClientFailureCheckPeriod

void setClientFailureCheckPeriod(long clientFailureCheckPeriod)
Sets the period (in milliseconds) used to check if a client has failed to receive pings from the server. Value must be -1 (to disable) or greater than 0.

Parameters:
clientFailureCheckPeriod - the period to check failure

isCacheLargeMessagesClient

boolean isCacheLargeMessagesClient()
When true, consumers created through this factory will create temporary files to cache large messages. There is 1 temporary file created for each large message. Default value is HornetQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT.

Returns:
true if consumers created through this factory will cache large messages in temporary files, false else

setCacheLargeMessagesClient

void setCacheLargeMessagesClient(boolean cached)
Sets whether large messages received by consumers created through this factory will be cached in temporary files or not.

Parameters:
cached - true to cache large messages in temporary files, false else

getConnectionTTL

long getConnectionTTL()
Returns the connection time-to-live. This TTL determines how long the server will keep a connection alive in the absence of any data arriving from the client. Value is in milliseconds, default value is HornetQClient.DEFAULT_CONNECTION_TTL.

Returns:
the connection time-to-live in milliseconds

setConnectionTTL

void setConnectionTTL(long connectionTTL)
Sets this factory's connections time-to-live. Value must be -1 (to disable) or greater or equals to 0.

Parameters:
connectionTTL - period in milliseconds

getCallTimeout

long getCallTimeout()
Returns the blocking calls timeout. If client's blocking calls to the server take more than this timeout, the call will throw a HornetQException with the code HornetQException.CONNECTION_TIMEDOUT. Value is in milliseconds, default value is HornetQClient.DEFAULT_CALL_TIMEOUT.

Returns:
the blocking calls timeout

setCallTimeout

void setCallTimeout(long callTimeout)
Sets the blocking call timeout. Value must be greater or equals to 0

Parameters:
callTimeout - blocking call timeout in milliseconds

getMinLargeMessageSize

int getMinLargeMessageSize()
Returns the large message size threshold. Messages whose size is if greater than this value will be handled as large messages. Value is in bytes, default value is HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE.

Returns:
the message size threshold to treat messages as large messages.

setMinLargeMessageSize

void setMinLargeMessageSize(int minLargeMessageSize)
Sets the large message size threshold. Value must be greater than 0.

Parameters:
minLargeMessageSize - large message size threshold in bytes

getConsumerWindowSize

int getConsumerWindowSize()
Returns the window size for flow control of the consumers created through this factory. Value is in bytes, default value is HornetQClient.DEFAULT_CONSUMER_WINDOW_SIZE.

Returns:
the window size used for consumer flow control

setConsumerWindowSize

void setConsumerWindowSize(int consumerWindowSize)
Sets the window size for flow control of the consumers created through this factory. Value must be -1 (to disable flow control), 0 (to not buffer any messages) or greater than 0 (to set the maximum size of the buffer)

Parameters:
consumerWindowSize - window size (in bytes) used for consumer flow control

getConsumerMaxRate

int getConsumerMaxRate()
Returns the maximum rate of message consumption for consumers created through this factory. This value controls the rate at which a consumer can consume messages. A consumer will never consume messages at a rate faster than the rate specified. Value is -1 (to disable) or a positive integer corresponding to the maximum desired message consumption rate specified in units of messages per second. Default value is HornetQClient.DEFAULT_CONSUMER_MAX_RATE.

Returns:
the consumer max rate

setConsumerMaxRate

void setConsumerMaxRate(int consumerMaxRate)
Sets the maximum rate of message consumption for consumers created through this factory. Value must -1 (to disable) or a positive integer corresponding to the maximum desired message consumption rate specified in units of messages per second.

Parameters:
consumerMaxRate - maximum rate of message consumption (in messages per seconds)

getConfirmationWindowSize

int getConfirmationWindowSize()
Returns the size for the confirmation window of clients using this factory. Value is in bytes or -1 (to disable the window). Default value is HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE.

Returns:
the size for the confirmation window of clients using this factory

setConfirmationWindowSize

void setConfirmationWindowSize(int confirmationWindowSize)
Sets the size for the confirmation window buffer of clients using this factory. Value must be -1 (to disable the window) or greater than 0.

Parameters:
confirmationWindowSize - size of the confirmation window (in bytes)

getProducerWindowSize

int getProducerWindowSize()
Returns the window size for flow control of the producers created through this factory. Value must be -1 (to disable flow control) or greater than 0 to determine the maximum amount of bytes at any give time (to prevent overloading the connection). Default value is HornetQClient.DEFAULT_PRODUCER_WINDOW_SIZE.

Returns:
the window size for flow control of the producers created through this factory.

setProducerWindowSize

void setProducerWindowSize(int producerWindowSize)
Returns the window size for flow control of the producers created through this factory. Value must be -1 (to disable flow control) or greater than 0.

Parameters:
producerWindowSize - window size (in bytest) for flow control of the producers created through this factory.

getProducerMaxRate

int getProducerMaxRate()
Returns the maximum rate of message production for producers created through this factory. This value controls the rate at which a producer can produce messages. A producer will never produce messages at a rate faster than the rate specified. Value is -1 (to disable) or a positive integer corresponding to the maximum desired message production rate specified in units of messages per second. Default value is HornetQClient.DEFAULT_PRODUCER_MAX_RATE.

Returns:
maximum rate of message production (in messages per seconds)

setProducerMaxRate

void setProducerMaxRate(int producerMaxRate)
Sets the maximum rate of message production for producers created through this factory. Value must -1 (to disable) or a positive integer corresponding to the maximum desired message production rate specified in units of messages per second.

Parameters:
producerMaxRate - maximum rate of message production (in messages per seconds)

isBlockOnAcknowledge

boolean isBlockOnAcknowledge()
Returns whether consumers created through this factory will block while sending message acknowledgements or do it asynchronously. Default value is HornetQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE.

Returns:
whether consumers will block while sending message acknowledgements or do it asynchronously

setBlockOnAcknowledge

void setBlockOnAcknowledge(boolean blockOnAcknowledge)
Sets whether consumers created through this factory will block while sending message acknowledgements or do it asynchronously.

Parameters:
blockOnAcknowledge - true to block when sending message acknowledgements or false to send them asynchronously

isBlockOnDurableSend

boolean isBlockOnDurableSend()
Returns whether producers created through this factory will block while sending durable messages or do it asynchronously.
If the session is configured to send durable message asynchronously, the client can set a SendAcknowledgementHandler on the ClientSession to be notified once the message has been handled by the server. Default value is HornetQClient.DEFAULT_BLOCK_ON_DURABLE_SEND.

Returns:
whether producers will block while sending persistent messages or do it asynchronously

setBlockOnDurableSend

void setBlockOnDurableSend(boolean blockOnDurableSend)
Sets whether producers created through this factory will block while sending durable messages or do it asynchronously.

Parameters:
blockOnDurableSend - true to block when sending durable messages or false to send them asynchronously

isBlockOnNonDurableSend

boolean isBlockOnNonDurableSend()
Returns whether producers created through this factory will block while sending non-durable messages or do it asynchronously.
If the session is configured to send non-durable message asynchronously, the client can set a SendAcknowledgementHandler on the ClientSession to be notified once the message has been handled by the server. Default value is HornetQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND.

Returns:
whether producers will block while sending non-durable messages or do it asynchronously

setBlockOnNonDurableSend

void setBlockOnNonDurableSend(boolean blockOnNonDurableSend)
Sets whether producers created through this factory will block while sending non-durable messages or do it asynchronously.

Parameters:
blockOnNonDurableSend - true to block when sending non-durable messages or false to send them asynchronously

isAutoGroup

boolean isAutoGroup()
Returns whether producers created through this factory will automatically assign a group ID to the messages they sent. if true, a random unique group ID is created and set on each message for the property Message.HDR_GROUP_ID. Default value is HornetQClient.DEFAULT_AUTO_GROUP.

Returns:
whether producers will automatically assign a group ID to their messages

setAutoGroup

void setAutoGroup(boolean autoGroup)
Sets whether producers created through this factory will automatically assign a group ID to the messages they sent.

Parameters:
autoGroup - true to automatically assign a group ID to each messages sent through this factory, false else

getGroupID

String getGroupID()
Returns the group ID that will be eventually set on each message for the property Message.HDR_GROUP_ID. Default value is is null and no group ID will be set on the messages.

Returns:
the group ID that will be eventually set on each message

setGroupID

void setGroupID(String groupID)
Sets the group ID that will be set on each message sent through this factory.

Parameters:
groupID - the group ID to use

isPreAcknowledge

boolean isPreAcknowledge()
Returns whether messages will pre-acknowledged on the server before they are sent to the consumers or not. Default value is HornetQClient.DEFAULT_PRE_ACKNOWLEDGE


setPreAcknowledge

void setPreAcknowledge(boolean preAcknowledge)
Sets to true to pre-acknowledge consumed messages on the server before they are sent to consumers, else set to false to let clients acknowledge the message they consume.

Parameters:
preAcknowledge - true to enable pre-acknowledgement, false else

getAckBatchSize

int getAckBatchSize()
Returns the acknowledgements batch size. Default value is HornetQClient.DEFAULT_ACK_BATCH_SIZE.

Returns:
the acknowledgements batch size

setAckBatchSize

void setAckBatchSize(int ackBatchSize)
Sets the acknowledgements batch size. Value must be equal or greater than 0.

Parameters:
ackBatchSize - acknowledgements batch size

getLocalBindAddress

String getLocalBindAddress()
Returns the local bind address to which the multicast socket is bound for discovery. This is null if the multicast socket is not bound, or no discovery is being used

Returns:
the local bind address to which the multicast socket is bound for discovery

setLocalBindAddress

void setLocalBindAddress(String localBindAddress)
Sets the local bind address to which the multicast socket is bound for discovery.

Parameters:
localBindAddress - the local bind address

getDiscoveryAddress

String getDiscoveryAddress()
Returns the address to listen to discover which connectors this factory can use. The discovery address must be set to enable this factory to discover HornetQ servers.

Returns:
the address to listen to discover which connectors this factory can use

setDiscoveryAddress

void setDiscoveryAddress(String discoveryAddress)
Sets the address to listen to discover which connectors this factory can use.

Parameters:
discoveryAddress - address to listen to discover which connectors this factory can use

getDiscoveryPort

int getDiscoveryPort()
Returns the port to listen to discover which connectors this factory can use. The discovery port must be set to enable this factory to discover HornetQ servers.

Returns:
the port to listen to discover which connectors this factory can use

setDiscoveryPort

void setDiscoveryPort(int discoveryPort)
Sets the port to listen to discover which connectors this factory can use.

Parameters:
discoveryPort - port to listen to discover which connectors this factory can use

getDiscoveryRefreshTimeout

long getDiscoveryRefreshTimeout()
Returns the refresh timeout for discovered HornetQ servers. If this factory uses discovery to find HornetQ servers, the list of discovered servers will be refreshed according to this timeout. Value is in milliseconds, default value is HornetQClient.DEFAULT_DISCOVERY_REFRESH_TIMEOUT.

Returns:
the refresh timeout for discovered HornetQ servers

setDiscoveryRefreshTimeout

void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout)
Sets the refresh timeout for discovered HornetQ servers. Value must be greater than 0.

Parameters:
discoveryRefreshTimeout - refresh timeout (in milliseconds) for discovered HornetQ servers

getDiscoveryInitialWaitTimeout

long getDiscoveryInitialWaitTimeout()
Returns the initial wait timeout if this factory is configured to use discovery. Value is in milliseconds, default value is HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT.

Returns:
the initial wait timeout if this factory is configured to use discovery

setDiscoveryInitialWaitTimeout

void setDiscoveryInitialWaitTimeout(long initialWaitTimeout)
Sets the initial wait timeout if this factory is configured to use discovery. Value is in milliseconds and must be greater than 0.

Parameters:
initialWaitTimeout - initial wait timeout when using discovery

isUseGlobalPools

boolean isUseGlobalPools()
Returns whether this factory will use global thread pools (shared among all the factories in the same JVM) or its own pools. Default value is HornetQClient.DEFAULT_USE_GLOBAL_POOLS.

Returns:
true if this factory uses global thread pools, false else

setUseGlobalPools

void setUseGlobalPools(boolean useGlobalPools)
Sets whether this factory will use global thread pools (shared among all the factories in the same JVM) or its own pools.

Parameters:
useGlobalPools - true to let this factory uses global thread pools, false else

getScheduledThreadPoolMaxSize

int getScheduledThreadPoolMaxSize()
Returns the maximum size of the scheduled thread pool. Default value is HornetQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE.

Returns:
the maximum size of the scheduled thread pool.

setScheduledThreadPoolMaxSize

void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
Sets the maximum size of the scheduled thread pool. This setting is relevant only if this factory does not use global pools. Value must be greater than 0.

Parameters:
scheduledThreadPoolMaxSize - maximum size of the scheduled thread pool.

getThreadPoolMaxSize

int getThreadPoolMaxSize()
Returns the maximum size of the thread pool. Default value is HornetQClient.DEFAULT_THREAD_POOL_MAX_SIZE.

Returns:
the maximum size of the thread pool.

setThreadPoolMaxSize

void setThreadPoolMaxSize(int threadPoolMaxSize)
Sets the maximum size of the thread pool. This setting is relevant only if this factory does not use global pools. Value must be -1 (for unlimited thread pool) or greater than 0.

Parameters:
threadPoolMaxSize - maximum size of the thread pool.

getRetryInterval

long getRetryInterval()
Returns the time to retry connections created by this factory after failure. Value is in milliseconds, default is HornetQClient.DEFAULT_RETRY_INTERVAL.

Returns:
the time to retry connections created by this factory after failure

setRetryInterval

void setRetryInterval(long retryInterval)
Sets the time to retry connections created by this factory after failure. Value must be greater than 0.

Parameters:
retryInterval - time (in milliseconds) to retry connections created by this factory after failure

getRetryIntervalMultiplier

double getRetryIntervalMultiplier()
Returns the multiplier to apply to successive retry intervals. Default value is HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER.

Returns:
the multiplier to apply to successive retry intervals

setRetryIntervalMultiplier

void setRetryIntervalMultiplier(double retryIntervalMultiplier)
Sets the multiplier to apply to successive retry intervals. Value must be positive.

Parameters:
retryIntervalMultiplier - multiplier to apply to successive retry intervals

getMaxRetryInterval

long getMaxRetryInterval()
Returns the maximum retry interval (in the case a retry interval multiplier has been specified). Value is in milliseconds, default value is HornetQClient.DEFAULT_MAX_RETRY_INTERVAL.

Returns:
the maximum retry interval

setMaxRetryInterval

void setMaxRetryInterval(long maxRetryInterval)
Sets the maximum retry interval. Value must be greater than 0.

Parameters:
maxRetryInterval - maximum retry interval to apply in the case a retry interval multiplier has been specified

getReconnectAttempts

int getReconnectAttempts()
Returns the maximum number of attempts to retry connection in case of failure. Default value is HornetQClient.DEFAULT_RECONNECT_ATTEMPTS.

Returns:
the maximum number of attempts to retry connection in case of failure.

setReconnectAttempts

void setReconnectAttempts(int reconnectAttempts)
Sets the maximum number of attempts to retry connection in case of failure. Value must be -1 (to retry infinitely), 0 (to never retry connection) or greater than 0.

Parameters:
reconnectAttempts - maximum number of attempts to retry connection in case of failure

isFailoverOnInitialConnection

boolean isFailoverOnInitialConnection()
Returns true if the client will automatically attempt to connect to the backup server if the initial connection to the live server fails Default value is HornetQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION.


setFailoverOnInitialConnection

void setFailoverOnInitialConnection(boolean failover)
Sets the value for FailoverOnInitialReconnection

Parameters:
failover -

isFailoverOnServerShutdown

boolean isFailoverOnServerShutdown()
Returns whether connections created by this factory must failover in case the server they are connected to has normally shut down. Default value is HornetQClient.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN.

Returns:
true if connections must failover if the server has normally shut down, else false

setFailoverOnServerShutdown

void setFailoverOnServerShutdown(boolean failoverOnServerShutdown)
Sets whether connections created by this factory must failover in case the server they are connected to has normally shut down

Parameters:
failoverOnServerShutdown - true if connections must failover if the server has normally shut down, false else

getConnectionLoadBalancingPolicyClassName

String getConnectionLoadBalancingPolicyClassName()
Returns the class name of the connection load balancing policy. Default value is "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy".

Returns:
the class name of the connection load balancing policy

setConnectionLoadBalancingPolicyClassName

void setConnectionLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
Sets the class name of the connection load balancing policy. Value must be the name of a class implementing ConnectionLoadBalancingPolicy.

Parameters:
loadBalancingPolicyClassName - class name of the connection load balancing policy

getInitialMessagePacketSize

int getInitialMessagePacketSize()
Returns the initial size of messages created through this factory. Value is in bytes, default value is HornetQClient.DEFAULT_INITIAL_MESSAGE_PACKET_SIZE.

Returns:
the initial size of messages created through this factory

setInitialMessagePacketSize

void setInitialMessagePacketSize(int size)
Sets the initial size of messages created through this factory. Value must be greater than 0.

Parameters:
size - initial size of messages created through this factory.

addInterceptor

void addInterceptor(Interceptor interceptor)
Adds an interceptor which will be executed after packets are received from the server.

Parameters:
interceptor - an Interceptor

removeInterceptor

boolean removeInterceptor(Interceptor interceptor)
Removes an interceptor.

Parameters:
interceptor - interceptor to remove
Returns:
true if the interceptor is removed from this factory, false else

close

void close()
Closes this factory and release all its resources


copy

ClientSessionFactory copy()
Creates a copy of this factory.

Returns:
a copy of this factory with the same parameters values


Copyright © 2009 Red Hat Inc. All Rights Reserved.