public interface Client extends TopicClient
A client connects to a Diffusion Server and subscribes to one or more topics which can be provided by more than one Publisher.
Modifier and Type | Method and Description |
---|---|
boolean |
abort()
Sends an abort notification to the Client and then closes the connection.
|
void |
addQueueMessageFilter(String topic,
MessageFilter filter)
Adds a Message Filter to be applied to Messages being queued for the
Client.
|
boolean |
canConnect(ConnectionValidationPolicyConfig policy)
Performs tests to check to see if the client is valid for the
specified policy
|
boolean |
canSubscribe(SubscriptionValidationPolicyConfig policy,
Topic topic)
Indicates whether he client is allowed to subscribe to a given topic
according to a given subscription validation policy.
|
List<Topic> |
fetch(TopicSet topicSet,
List<String> headers)
Causes a forced fetch of one or more Topics for the Client.
|
ClientCloseReason |
getCloseReason()
If the client is not connected then this will return the reason that it
was closed.
|
long |
getConflationCount(boolean reset)
Returns the number of conflations that have occurred for the connection.
|
List<ConnectionValidationPolicyConfig> |
getConnectionValidationPolicies()
Get the list of connection validation policies that are configured for
the connector of this client.
|
String |
getConnectorName()
Get the connector name
|
int |
getCurrentQueueSize()
Returns the current outbound queue size.
|
GeoIPData |
getGeoIPData()
getGeoIPData
|
int |
getLargestQueueSize()
Returns the largest size the queue has reached.
|
long |
getLastMessageReceivedTimeMillis()
Returns the time that the last message was received from the client.
|
long |
getLastMessageSentTimeMillis()
Returns the time that last message was sent to the client.
|
int |
getLocalPortNumber()
Get the Local Port number
|
int |
getLowerQueueNotificationThreshold()
Returns the lower queue notification threshold operating for the
connection.
|
int |
getMaximumQueueSize()
Returns the maximum queue size.
|
int |
getNumberOfMessagesReceived()
Deprecated.
Use
getStatistics() |
int |
getNumberOfMessagesSent()
Deprecated.
Use
getStatistics() |
String |
getRemoteAddress()
Returns the remote address of the client.
|
long |
getStartTimeMillis()
Returns the time that the client started in milliseconds.
|
ClientStatistics |
getStatistics()
Return the statistics for this client.
|
Subscription |
getSubscription(Topic topic)
Returns details of a Client's subscription to a given Topic.
|
ClientThrottler |
getThrottler()
Returns the current Client Throttler.
|
int |
getUpperQueueNotificationThreshold()
Returns the upper queue notification threshold operating for the
connection.
|
String |
getUptime()
Returns the time that the client has been connected as a displayable
string.
|
long |
getUptimeMillis()
Returns the time that the client has been connected in milliseconds.
|
WhoIsDetails |
getWhoIsDetails()
Returns the WhoIs details of the client as determined by the WhoIs
service.
|
boolean |
isConflating()
Indicates whether the outbound message queue is currently conflating
messages.
|
boolean |
isResolved()
Indicates whether WhoIsDetails have been resolved.
|
boolean |
isStatisticsEnabled()
Indicates whether Statistics reporting for this Client
is enabled or not.
|
boolean |
isThrottled()
Indicates whether the Client currently has a throttler configured.
|
boolean |
removeQueueMessageFilter(MessageFilter filter)
Removes a Queue Message Filter.
|
boolean |
removeThrottler()
Remove any current Throttler.
|
boolean |
send(TopicMessage message,
MessagePriority priority)
Send a message to the client, specifying delivery priority.
|
boolean |
sendFetchReply(TopicMessage message,
MessagePriority priority,
List<String> headers)
Deprecated.
since 5.6. Currently a classic client can issue a fetch request
to a stateless topic, or even a topic that does not exist.
This method enables a publisher to return a reply. At future
releases this capability will be removed.
|
void |
setConflation(boolean conflate)
Sets message conflation on or off for the outbound message queue.
|
void |
setCredentials(Credentials credentials)
Deprecated.
This method exists only to support the
AuthorisationHandler.canConnect() and
AuthorisationHandler.credentialsSupplied methods,
both of which are deprecated in favor of authentication
handlers. It will be removed in a future release. |
void |
setMaximumQueueSize(int maximumQueueSize)
Sets the maximum queue size for the client.
|
void |
setQueueNotificationThresholds(int lower,
int upper)
Sets queue notification thresholds.
|
void |
startStatistics()
Starts the collection of this Client's statistics.
|
void |
stopStatistics()
Stops the collection of this Client's statistics.
|
ClientThrottler |
throttle(ClientThrottlerType type,
int limit)
Throttle the Client's queue.
|
acknowledge, attach, attachment, getCredentials, getReference, getTopics, isSubscribed, removeFromClientGroups, selectsTopic, send, sendFetchReply, setReference, subscribe, subscribe, subscribe, subscribe, unsubscribe, unsubscribe
close, getClientID, getConnectionType, getLastInteraction, getProtocolVersion, isConnected, isSecure, ping
getClientID, getMessageSourceType
long getStartTimeMillis()
long getUptimeMillis()
String getUptime()
Utils.formatElapsedTime(long)
.@Deprecated int getNumberOfMessagesSent()
getStatistics()
-1
if client statistics recording is disabledlong getLastMessageSentTimeMillis()
@Deprecated int getNumberOfMessagesReceived()
getStatistics()
-1
if client statistics recording is disabledlong getLastMessageReceivedTimeMillis()
ClientStatistics getStatistics()
The returned ClientStatistics
will become stale if statistics
recording is disabled (for example, if stopStatistics()
is
called). If client statistics recording is disabled when this method is
called, the ClientStatistics
will return -1
for each
statistic value.
String getRemoteAddress()
WhoIsDetails getWhoIsDetails()
The WhoIs service obtains host and geographic information as well as WhoIs database information about the client.
When a client is connected it requests the WhoIs details from the WhoIs
service but as sometimes a lookup takes some time then it may not be
immediately available. Publishers are notified when this information is
available for a client via the
ClientListener.clientResolved(Client)
method. Alternatively the
isResolved()
can be used to check if the details are available.
GeoIPData getGeoIPData()
Returns an instance of GeoIPData
.
boolean isResolved()
getWhoIsDetails()
.ClientCloseReason getCloseReason()
Subscription getSubscription(Topic topic)
topic
- the topic.int getCurrentQueueSize()
int getLargestQueueSize()
void setMaximumQueueSize(int maximumQueueSize)
maximumQueueSize
- the new maximum queue sizeIllegalArgumentException
- if maximumQueueSize is less than 1int getMaximumQueueSize()
void setConflation(boolean conflate)
Message conflation avoids duplicate message being sent but has a
processing cost. For conflation to work topics need to have
Conflation Policies
set.
conflate
- true sets conflation on, false turns it off.boolean isConflating()
Conflation may be on by default or may have been set using
setConflation(boolean)
.
long getConflationCount(boolean reset)
reset
- true causes the count for the connection to be reset to 0.int getLowerQueueNotificationThreshold()
int getUpperQueueNotificationThreshold()
void setQueueNotificationThresholds(int lower, int upper) throws MessageException
The upper threshold is a percentage of the maximum queue size at which a notification should occur when a message is added to the queue causing its size to reach the threshold. If this is -1 then no upper threshold notification is used.
The lower threshold is a percentage of the maximum queue size at which a notification should occur when a message is removed from the queue causing the queue size to reach the threshold if (and only if) the upper threshold has been breached. If this is -1 then no lower threshold notification would occur.
lower
- a value between 0 and 99, or -1 to indicate no lower
threshold notification is required. This value would be ignored if upper
was set to -1.upper
- a value between 1 and 100, or -1 to indicate no upper
threshold notification is required.MessageException
- if the threshold values are invalidClientThrottler throttle(ClientThrottlerType type, int limit)
Throttling a queue causes a message limit to be imposed which restricts messages sent to the Client.
If the client is already throttled then this has the effect of removing the existing Throttler and creating a new one.
type
- indicates the type of throttling required.limit
- indicates the throttling limit. The meaning of this limit
depends upon the throttling type
.ClientThrottler getThrottler()
throttled
.boolean isThrottled()
throttled
boolean removeThrottler()
If the Client is currently throttled
then this will cause throttling to stop.
@Deprecated void setCredentials(Credentials credentials)
AuthorisationHandler.canConnect()
and
AuthorisationHandler.credentialsSupplied
methods,
both of which are deprecated in favor of authentication
handlers. It will be removed in a future release.credentials
- the Client credentials.boolean abort()
This differs from ClientConnection.close()
in that the Client is notified that it
has been aborted and should not try to reconnect.
boolean send(TopicMessage message, MessagePriority priority) throws APIException
In all other respects this method behaves like
TopicClient.send(TopicMessage)
.
message
- the message to send.priority
- the delivery priorityAPIException
- if unable to send the message.@Deprecated boolean sendFetchReply(TopicMessage message, MessagePriority priority, List<String> headers) throws APIException
This method is not supported for Unified API clients. Messages sent to a Unified API client using this method will be discarded.
message
- the message to send.priority
- the delivery priorityheaders
- a list of headers to add to the reply message being sent.
These would typically be the headers sent with the fetch request.APIException
- if unable to send the message.int getLocalPortNumber()
Get the local port number of the client, this will then detail which connector the client connected to.
String getConnectorName()
Get the name of the connector that this client connected to.
void addQueueMessageFilter(String topic, MessageFilter filter) throws TopicInvalidException
The filter will be applied to all delta messages for the specified Topic (or Topics if a selector pattern is used) as they are queued for the Client. This will happen for all Messages published or sent to the Client.
Such a filter may be used to filter out certain Messages or even to change the content of the Message being queued (by returning a different Message from that input).
Filters are selected in the order that they are set so if more than one filter specified using a pattern would apply to a single Topic then the first one that matches would be used.
topic
- a Topic name or TopicSelector
pattern.filter
- the filter to applyTopicInvalidException
- if the specified topic is not a valid
Topic name or selector pattern.boolean removeQueueMessageFilter(MessageFilter filter)
Such a filter will have been set using
addQueueMessageFilter(String, MessageFilter)
.
Where a single filter has been set for more than one Topic or selector pattern then all instances of it will be removed.
filter
- the filter to removeList<Topic> fetch(TopicSet topicSet, List<String> headers) throws APIException
This has the same effect as if the Client had itself requested the fetch. Fetch reply messages for each selected Topic will be sent out to the Client. This can be done even for Topics that the Client is not subscribed to.
topicSet
- the set of Topics to fetch - topic selectors can be used.headers
- any correlation headers to add - this can be null if no
extra headers are required but if supplied then these headers will be
added after any headers on the current Topic Load state.APIException
- if fetch failed.boolean canSubscribe(SubscriptionValidationPolicyConfig policy, Topic topic)
policy
- the policy configurationtopic
- the topicboolean canConnect(ConnectionValidationPolicyConfig policy)
policy
- the policy configurationList<ConnectionValidationPolicyConfig> getConnectionValidationPolicies()
void startStatistics()
If Statistics reporting is enabled, this will start the collection of statistics specific to this Client's if they are not already running.
void stopStatistics()
If statistics collection for this Client has been enabled, this will discard the statistics and stop further values from being recorded.
boolean isStatisticsEnabled()
By default this will be false, unless '
Copyright © 2016 Push Technology Ltd. All Rights Reserved.