public interface ServerLocator extends AutoCloseable
If you are using straight TCP on the configuration, and if you configure your serverLocator to be HA, the locator will always get an updated list of members to the server, the server will send the updated list to the client.
If you use UDP or JGroups (exclusively JGropus or UDP), the initial discovery is done by the grouping finder, after the initial connection is made the server will always send updates to the client. But the listeners will listen for updates on grouping.
Modifier and Type | Method and Description |
---|---|
void |
addClusterTopologyListener(ClusterTopologyListener listener) |
void |
addIncomingInterceptor(Interceptor interceptor)
Adds an interceptor which will be executed after packets are received from the server.
|
void |
addInterceptor(Interceptor interceptor)
Deprecated.
As of HornetQ 2.3.0.Final, replaced by
addIncomingInterceptor(Interceptor) and
addOutgoingInterceptor(Interceptor) |
void |
addOutgoingInterceptor(Interceptor interceptor)
Adds an interceptor which will be executed before packets are sent to the server.
|
void |
close()
Closes this factory and release all its resources
|
ClientSessionFactory |
createSessionFactory()
Creates a ClientSessionFactory using whatever load balancing policy is in force
|
ClientSessionFactory |
createSessionFactory(String nodeID)
Creates a
ClientSessionFactory to a specific server. |
ClientSessionFactory |
createSessionFactory(TransportConfiguration transportConfiguration)
Creates a
ClientSessionFactory to a specific server. |
ClientSessionFactory |
createSessionFactory(TransportConfiguration transportConfiguration,
int reconnectAttempts,
boolean failoverOnInitialConnection)
Creates a
ClientSessionFactory to a specific server. |
void |
disableFinalizeCheck()
This method will disable any checks when a GarbageCollection happens
leaving connections open.
|
int |
getAckBatchSize()
Returns the acknowledgments batch size.
|
long |
getCallFailoverTimeout()
Returns the blocking calls failover timeout when the client is awaiting failover,
this is over and above the normal call timeout.
|
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.
|
DiscoveryGroupConfiguration |
getDiscoveryGroupConfiguration()
The discovery group configuration
|
String |
getGroupID()
Returns the group ID that will be eventually set on each message for the property
Message.HDR_GROUP_ID . |
int |
getInitialConnectAttempts() |
int |
getInitialMessagePacketSize()
Returns the initial size of messages created through this factory.
|
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.
|
TransportConfiguration[] |
getStaticTransportConfigurations()
Returns an array of TransportConfigurations representing the static list of live servers used
when creating this object
|
int |
getThreadPoolMaxSize()
Returns the maximum size of the thread pool.
|
Topology |
getTopology()
Exposes the Topology used by this ServerLocator.
|
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 acknowledgments 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 |
isClosed()
Returns true if close was already called
|
boolean |
isCompressLargeMessage()
Whether to compress 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
|
boolean |
isHA()
Whether this server receives topology notifications from the cluster as servers join or leave
the cluster.
|
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.
|
void |
removeClusterTopologyListener(ClusterTopologyListener listener) |
boolean |
removeIncomingInterceptor(Interceptor interceptor)
Removes an incoming interceptor.
|
boolean |
removeInterceptor(Interceptor interceptor)
Deprecated.
As of HornetQ 2.3.0.Final, replaced by
removeIncomingInterceptor(Interceptor) and
removeOutgoingInterceptor(Interceptor) |
boolean |
removeOutgoingInterceptor(Interceptor interceptor)
Removes an outgoing interceptor.
|
void |
setAckBatchSize(int ackBatchSize)
Sets the acknowledgments 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 acknowledgments 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 |
setCallFailoverTimeout(long callFailoverTimeout)
Sets the blocking call failover timeout.
|
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 |
setCompressLargeMessage(boolean compressLargeMessages)
Sets whether to compress or not large messages.
|
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 |
setFailoverOnInitialConnection(boolean failover)
Sets the value for FailoverOnInitialReconnection
|
void |
setGroupID(String groupID)
Sets the group ID that will be set on each message sent through this factory.
|
void |
setInitialConnectAttempts(int reconnectAttempts)
Sets the maximum number of attempts to establish an initial connection.
|
void |
setInitialMessagePacketSize(int size)
Sets the initial size of messages created through this factory.
|
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 |
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.
|
boolean isClosed()
true
if closed, false
otherwise.void disableFinalizeCheck()
Warning: You may leave resources unattended if you call this method and don't take care of cleaning the resources yourself.
ClientSessionFactory createSessionFactory() throws Exception
Exception
ClientSessionFactory createSessionFactory(String nodeID) throws Exception
ClientSessionFactory
to a specific server. The server must already be known
about by this ServerLocator. This method allows the user to make a connection to a specific
server bypassing any load balancing policy in forcenodeID
- null
if the node is not present on the
topologyException
- if a failure happened in creating the ClientSessionFactory or the
ServerLocator does not know about the passed in transportConfigurationClientSessionFactory createSessionFactory(TransportConfiguration transportConfiguration) throws Exception
ClientSessionFactory
to a specific server. The server must already be known
about by this ServerLocator. This method allows the user to make a connection to a specific
server bypassing any load balancing policy in forcetransportConfiguration
- ClientSessionFactory
instanceException
- if a failure happened in creating the ClientSessionFactory or the
ServerLocator does not know about the passed in transportConfigurationClientSessionFactory createSessionFactory(TransportConfiguration transportConfiguration, int reconnectAttempts, boolean failoverOnInitialConnection) throws Exception
ClientSessionFactory
to a specific server. The server must already be known
about by this ServerLocator. This method allows the user to make a connection to a specific
server bypassing any load balancing policy in forcetransportConfiguration
- reconnectAttempts
- number of attempts of reconnection to performfailoverOnInitialConnection
- ClientSessionFactory
instanceException
- if a failure happened in creating the ClientSessionFactory or the
ServerLocator does not know about the passed in transportConfigurationlong getClientFailureCheckPeriod()
Period is in milliseconds, default value is
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD
.
void setClientFailureCheckPeriod(long clientFailureCheckPeriod)
Value must be -1 (to disable) or greater than 0.
clientFailureCheckPeriod
- the period to check failureboolean isCacheLargeMessagesClient()
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
.
true
if consumers created through this factory will cache large messages
in temporary files, false
elsevoid setCacheLargeMessagesClient(boolean cached)
cached
- true
to cache large messages in temporary files, false
elselong getConnectionTTL()
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
.
void setConnectionTTL(long connectionTTL)
Value must be -1 (to disable) or greater or equals to 0.
connectionTTL
- period in millisecondslong getCallTimeout()
If client's blocking calls to the server take more than this timeout, the call will throw a
HornetQException
with the code HornetQExceptionType#CONNECTION_TIMEDOUT
. Value
is in milliseconds, default value is HornetQClient.DEFAULT_CALL_TIMEOUT
.
void setCallTimeout(long callTimeout)
Value must be greater or equals to 0
callTimeout
- blocking call timeout in millisecondslong getCallFailoverTimeout()
If client is in the process of failing over when a blocking call is called then the client will wait this long before actually trying the send.
void setCallFailoverTimeout(long callFailoverTimeout)
When the client is awaiting failover, this is over and above the normal call timeout.
Value must be greater or equals to -1, -1 means forever
callFailoverTimeout
- blocking call timeout in millisecondsint getMinLargeMessageSize()
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
.
void setMinLargeMessageSize(int minLargeMessageSize)
Value must be greater than 0.
minLargeMessageSize
- large message size threshold in bytesint getConsumerWindowSize()
Value is in bytes, default value is HornetQClient.DEFAULT_CONSUMER_WINDOW_SIZE
.
void setConsumerWindowSize(int consumerWindowSize)
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)
consumerWindowSize
- window size (in bytes) used for consumer flow controlint getConsumerMaxRate()
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
.
void setConsumerMaxRate(int consumerMaxRate)
Value must -1 (to disable) or a positive integer corresponding to the maximum desired message consumption rate specified in units of messages per second.
consumerMaxRate
- maximum rate of message consumption (in messages per seconds)int getConfirmationWindowSize()
Value is in bytes or -1 (to disable the window). Default value is
HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE
.
void setConfirmationWindowSize(int confirmationWindowSize)
Value must be -1 (to disable the window) or greater than 0.
confirmationWindowSize
- size of the confirmation window (in bytes)int getProducerWindowSize()
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
.
void setProducerWindowSize(int producerWindowSize)
Value must be -1 (to disable flow control) or greater than 0.
producerWindowSize
- window size (in bytest) for flow control of the producers created through this factory.int getProducerMaxRate()
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
.
void setProducerMaxRate(int producerMaxRate)
Value must -1 (to disable) or a positive integer corresponding to the maximum desired message production rate specified in units of messages per second.
producerMaxRate
- maximum rate of message production (in messages per seconds)boolean isBlockOnAcknowledge()
Default value is HornetQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE
.
void setBlockOnAcknowledge(boolean blockOnAcknowledge)
blockOnAcknowledge
- true
to block when sending message
acknowledgments or false
to send them
asynchronouslyboolean isBlockOnDurableSend()
Default value is HornetQClient.DEFAULT_BLOCK_ON_DURABLE_SEND
.
void setBlockOnDurableSend(boolean blockOnDurableSend)
blockOnDurableSend
- true
to block when sending durable messages or false
to send them asynchronouslyboolean isBlockOnNonDurableSend()
Default value is HornetQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND
.
void setBlockOnNonDurableSend(boolean blockOnNonDurableSend)
blockOnNonDurableSend
- true
to block when sending non-durable messages or false
to send them asynchronouslyboolean isAutoGroup()
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
.
void setAutoGroup(boolean autoGroup)
autoGroup
- true
to automatically assign a group ID to each messages sent through this factory, false
elseString getGroupID()
Message.HDR_GROUP_ID
.
Default value is is null
and no group ID will be set on the messages.
void setGroupID(String groupID)
groupID
- the group ID to useboolean isPreAcknowledge()
Default value is HornetQClient.DEFAULT_PRE_ACKNOWLEDGE
void setPreAcknowledge(boolean preAcknowledge)
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.preAcknowledge
- true
to enable pre-acknowledgment,
false
elseint getAckBatchSize()
Default value is HornetQClient.DEFAULT_ACK_BATCH_SIZE
.
void setAckBatchSize(int ackBatchSize)
Value must be equal or greater than 0.
ackBatchSize
- acknowledgments batch sizeTransportConfiguration[] getStaticTransportConfigurations()
TransportConfiguration
sDiscoveryGroupConfiguration getDiscoveryGroupConfiguration()
boolean isUseGlobalPools()
Default value is HornetQClient.DEFAULT_USE_GLOBAL_POOLS
.
true
if this factory uses global thread pools, false
elsevoid setUseGlobalPools(boolean useGlobalPools)
useGlobalPools
- true
to let this factory uses global thread pools, false
elseint getScheduledThreadPoolMaxSize()
Default value is HornetQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE
.
void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
This setting is relevant only if this factory does not use global pools. Value must be greater than 0.
scheduledThreadPoolMaxSize
- maximum size of the scheduled thread pool.int getThreadPoolMaxSize()
Default value is HornetQClient.DEFAULT_THREAD_POOL_MAX_SIZE
.
void setThreadPoolMaxSize(int threadPoolMaxSize)
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.
threadPoolMaxSize
- maximum size of the thread pool.long getRetryInterval()
Value is in milliseconds, default is HornetQClient.DEFAULT_RETRY_INTERVAL
.
void setRetryInterval(long retryInterval)
Value must be greater than 0.
retryInterval
- time (in milliseconds) to retry connections created by this factory after failuredouble getRetryIntervalMultiplier()
Default value is HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER
.
void setRetryIntervalMultiplier(double retryIntervalMultiplier)
Value must be positive.
retryIntervalMultiplier
- multiplier to apply to successive retry intervalslong getMaxRetryInterval()
Value is in milliseconds, default value is HornetQClient.DEFAULT_MAX_RETRY_INTERVAL
.
void setMaxRetryInterval(long maxRetryInterval)
Value must be greater than 0.
maxRetryInterval
- maximum retry interval to apply in the case a retry interval multiplier
has been specifiedint getReconnectAttempts()
Default value is HornetQClient.DEFAULT_RECONNECT_ATTEMPTS
.
void setReconnectAttempts(int reconnectAttempts)
Value must be -1 (to retry infinitely), 0 (to never retry connection) or greater than 0.
reconnectAttempts
- maximum number of attempts to retry connection in case of failurevoid setInitialConnectAttempts(int reconnectAttempts)
Value must be -1 (to retry infinitely), 0 (to never retry connection) or greater than 0.
reconnectAttempts
- maximum number of attempts for the initial connectionint getInitialConnectAttempts()
boolean isFailoverOnInitialConnection()
Default value is HornetQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION
.
void setFailoverOnInitialConnection(boolean failover)
failover
- String getConnectionLoadBalancingPolicyClassName()
Default value is "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy".
void setConnectionLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
Value must be the name of a class implementing ConnectionLoadBalancingPolicy
.
loadBalancingPolicyClassName
- class name of the connection load balancing policyint getInitialMessagePacketSize()
Value is in bytes, default value is HornetQClient.DEFAULT_INITIAL_MESSAGE_PACKET_SIZE
.
void setInitialMessagePacketSize(int size)
Value must be greater than 0.
size
- initial size of messages created through this factory.@Deprecated void addInterceptor(Interceptor interceptor)
addIncomingInterceptor(Interceptor)
and
addOutgoingInterceptor(Interceptor)
addIncomingInterceptor(Interceptor).
interceptor
- an Interceptorvoid addIncomingInterceptor(Interceptor interceptor)
interceptor
- an Interceptorvoid addOutgoingInterceptor(Interceptor interceptor)
interceptor
- an Interceptor@Deprecated boolean removeInterceptor(Interceptor interceptor)
removeIncomingInterceptor(Interceptor)
and
removeOutgoingInterceptor(Interceptor)
removeIncomingInterceptor(Interceptor).
interceptor
- interceptor to removetrue
if the interceptor is removed from this factory, false
elseboolean removeIncomingInterceptor(Interceptor interceptor)
interceptor
- interceptor to removetrue
if the incoming interceptor is removed from this factory, false
elseboolean removeOutgoingInterceptor(Interceptor interceptor)
interceptor
- interceptor to removetrue
if the outgoing interceptor is removed from this factory, false
elsevoid close()
close
in interface AutoCloseable
Topology getTopology()
boolean isHA()
true
if the locator receives topology updates from the clusterboolean isCompressLargeMessage()
void setCompressLargeMessage(boolean compressLargeMessages)
compressLargeMessages
- void addClusterTopologyListener(ClusterTopologyListener listener)
void removeClusterTopologyListener(ClusterTopologyListener listener)
Copyright © 2017 JBoss, a division of Red Hat. All rights reserved.