|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.crankuptheamps.client.Client
public class Client
The base AMPS client object used in AMPS applications. Each client object manages a single connection to AMPS. Each AMPS connection has a name, a specific transport (such as tcp), a protocol (used for framing messages to AMPS), and a message type (such as FIX or JSON).
The client object creates and manages background threads. The object provides both a synchronous interface for processing messages on the calling thread and an asynchronous interface suitable for populating a queue to be processed by worker threads.
The Client provides named convenience methods for many AMPS commands.
These methods provide control over commonly used parameters and support
most programs. For full control over AMPS, you build a
Command
object and use
execute(com.crankuptheamps.client.Command)
or executeAsync(com.crankuptheamps.client.Command, com.crankuptheamps.client.MessageHandler)
to run the command.
AMPS uses the client name to detect duplicate messages, so the name of each instance of the client application should be unique.
An example of a simple Java program publishing the JSON message
{ "message" : "Hello, World!"}
is listed below.
public static void main(String[] args) {
Client client = new Client("ConsolePublisher");
try
{
client.connect("tcp://127.0.0.1:9007/amps");
System.out.println("connected..");
client.logon();
client.publish("messages", "{\"message\" : \"Hello, World!\"}");
System.exit(0);
}
catch (AMPSException e)
{
System.err.println(e.getLocalizedMessage());
e.printStackTrace(System.err);
}
}
Nested Class Summary | |
---|---|
static class |
Client.Bookmarks
Functions that take a bookmark (String) such as bookmarkSubscribe(com.crankuptheamps.client.MessageHandler, java.lang.String, java.lang.String, com.crankuptheamps.client.CommandId, java.lang.String, java.lang.String, long) can be passed a literal bookmark ID,
or one of these special values. |
static class |
Client.Version
|
Field Summary | |
---|---|
protected ExceptionListener |
exceptionListener
|
static int |
MIN_MULTI_BOOKMARK_VERSION
|
static int |
MIN_PERSISTED_BOOKMARK_VERSION
|
Constructor Summary | |
---|---|
Client(String name)
Creates a client. |
|
Client(String name,
int version)
Creates a client. |
|
Client(String name,
Transport transport)
Creates a client with a transport. |
|
Client(String name,
Transport transport,
int version)
Creates a client with a transport |
Method Summary | |
---|---|
void |
addConnectionStateListener(ConnectionStateListener listener_)
Adds a ConnectionStateListener instance that will be invoked when this client connects or disconnects. |
Message |
allocateMessage()
Creates a new Message appropriate for this client. |
CommandId |
bookmarkDeltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
CommandId subId,
String bookmark,
String options,
long timeout)
Places a bookmark delta subscription with AMPS. |
CommandId |
bookmarkSubscribe(MessageHandler messageHandler,
String topic,
String filter,
CommandId subId,
String bookmark,
String options,
long timeout)
Places a bookmark subscription with AMPS. |
protected void |
broadcastConnectionStateChanged(int newState_)
|
void |
close()
Disconnect from the AMPS server. |
void |
connect(String uri)
Connects to the AMPS instance through the provided URI. |
void |
deltaPublish(byte[] topic,
int topicOffset,
int topicLength,
byte[] data,
int dataOffset,
int dataLength)
Delta publish a message to an AMPS topic. |
void |
deltaPublish(byte[] topic,
int topicOffset,
int topicLength,
byte[] data,
int dataOffset,
int dataLength,
int expiration)
Delta publish a message to an AMPS topic. |
void |
deltaPublish(String topic,
String data)
Delta publish a message to an AMPS topic. |
void |
deltaPublish(String topic,
String data,
int expiration)
Delta publish a message to an AMPS topic. |
CommandId |
deltaSubscribe(MessageHandler messageHandler,
String topic,
long timeout)
Places a delta subscription with AMPS. |
CommandId |
deltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
long timeout)
Places a delta subscription with AMPS. |
CommandId |
deltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
String options,
long timeout)
Places a delta subscription with AMPS. |
CommandId |
deltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
String options,
long timeout,
String subId)
Places a delta subscription with AMPS. |
void |
disconnect()
Disconnect from the AMPS server. |
MessageStream |
execute(Command command)
Execute the provided command and return messages received in response in a MessageStream . |
CommandId |
executeAsync(Command command,
MessageHandler handler)
Execute the provided command on a background thread and provide messages received in response to the handler provided. |
long |
flush()
Clear the queued messages which may be waiting in the transport |
long |
flush(long timeout)
Clear the queued messages which may be waiting in the transport |
BookmarkStore |
getBookmarkStore()
Returns the underlying bookmark store for this client. |
ConnectionInfo |
getConnectionInfo()
Assembles a new ConnectionInfo with the state of this client and associated classes. |
ClientDisconnectHandler |
getDisconnectHandler()
Returns the current ClientDisconnectHandler set on self. |
String |
getName()
Return the name of the Client. |
Store |
getPublishStore()
Returns the underlying publish store for this client. |
int |
getServerVersion()
Return the server version retrieved during logon. |
SubscriptionManager |
getSubscriptionManager()
Returns the SubscriptionManager instance used for recording active subscriptions. |
Transport |
getTransport()
Return the underlying transport. |
URI |
getURI()
Return the URI the Client is connected to. |
String |
getVersion()
Return the build number for the client that is stored in the Manifes.mf of the jar file. |
static int |
getVersionAsInt(String version)
Return the numeric value for the given version string with the pattern: Major.Minor.Maintenance.Hotfix The version uses 2 digits each for major minor maintenance and hotfix i.e., 3.8.1.5 will return 3080105 Version strings passed in can be shortened to not include all levels so 3.8 will return 3080000. |
CommandId |
logon()
Logs into AMPS with the parameters provided in the connect method. |
CommandId |
logon(long timeout)
Logs into AMPS with the parameters provided in the connect method. |
CommandId |
logon(long timeout,
Authenticator authenticator)
Logs into AMPS with the parameters provided in the connect method. |
long |
publish(byte[] topic,
int topicOffset,
int topicLength,
byte[] data,
int dataOffset,
int dataLength)
Publish a message to an AMPS topic. |
long |
publish(byte[] topic,
int topicOffset,
int topicLength,
byte[] data,
int dataOffset,
int dataLength,
int expiration)
Publish a message to an AMPS topic. |
long |
publish(String topic,
String data)
Publish a message to an AMPS topic. |
long |
publish(String topic,
String data,
int expiration)
Publish a message to an AMPS topic. |
void |
publishFlush()
Clear the queued messages which may be waiting in the transport, publish store or in the AMPS publish queue. |
void |
publishFlush(long timeout)
Return when all published messages have been confirmed to have made it through the publish queue inside the AMPS instnace. |
void |
removeConnectionStateListener(ConnectionStateListener listener_)
Removes a ConnectionStateListener from being invoked when this client connects or disconnects. |
void |
send(Message message)
Send a Message to AMPS via the Transport used in the Client. |
CommandId |
send(MessageHandler messageHandler,
Message message,
long timeout)
Send a Message to AMPS and register the messageHandler for any messages
resulting from the command execution. |
void |
setBookmarkStore(BookmarkStore val)
Sets the underlying bookmark store, which is used to track which messages the client has received and which messages have been processed by the program. |
void |
setDisconnectHandler(ClientDisconnectHandler disconnectHandler_)
Sets the ClientDisconnectHandler . |
void |
setDuplicateMessageHandler(MessageHandler messageHandler)
Sets the MessageHandler instance used for duplicate messages. |
void |
setExceptionListener(ExceptionListener exceptionListener)
Sets the ExceptionListener instance used for communicating absorbed exceptions. |
void |
setFailedWriteHandler(FailedWriteHandler handler_)
Sets the FailedWriteHandler instance used to report on failed
messages that have been written. |
void |
setHeartbeat(int intervalSeconds_)
Requests a server heartbeat, and configures the client to close the connection if a heartbeat (or other activity) is not seen on the connection after two heartbeat intervals. |
void |
setHeartbeat(int intervalSeconds_,
int timeoutSeconds_)
Requests a server heartbeat, and configures the client to close the connection if a heartbeat (or other activity) is not seen on the connection. |
void |
setLastChanceMessageHandler(MessageHandler messageHandler)
Sets the MessageHandler instance used when no other handler matches. |
void |
setPublishStore(Store store)
Sets the underlying publish store, which is used to store published messages until the AMPS instance has acknowledged those messages. |
void |
setSubscriptionManager(SubscriptionManager subscriptionManager)
Sets the SubscriptionManager instance used for recording active subscriptions. |
void |
setUnhandledMessageHandler(MessageHandler messageHandler)
Deprecated. Use setLastChanceMessageHandler instead. |
CommandId |
sow(MessageHandler messageHandler,
String topic,
int batchSize,
long timeout)
Executes a SOW query. |
CommandId |
sow(MessageHandler messageHandler,
String topic,
long timeout)
Executes a SOW query. |
CommandId |
sow(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
long timeout)
Executes a SOW query. |
CommandId |
sow(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
String options,
long timeout)
Executes a SOW query. |
CommandId |
sow(MessageHandler messageHandler,
String topic,
String filter,
String orderBy,
String bookmark,
int batchSize,
int topN,
String options,
long timeout)
Executes a SOW query. |
MessageStream |
sow(String topic)
Synchronously execute a SOW query. |
MessageStream |
sow(String topic,
String filter)
Synchronously execute a SOW query. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
int batchSize,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
boolean oofEnabled,
boolean sendEmpties,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
boolean oofEnabled,
boolean sendEmpties,
String options,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndDeltaSubscribe(MessageHandler messageHandler,
String topic,
String filter,
String orderBy,
int batchSize,
int topN,
String options,
long timeout)
Executes a SOW query and places a delta subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
int batchSize,
long timeout)
Executes a SOW query and places a subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
long timeout)
Executes a SOW query and places a subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
boolean oofEnabled,
long timeout)
Executes a SOW query and places a subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
long timeout)
Executes a SOW query and places a subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
String filter,
int batchSize,
String options,
long timeout)
Executes a SOW query and places a subscription. |
CommandId |
sowAndSubscribe(MessageHandler messageHandler,
String topic,
String filter,
String orderBy,
String bookmark,
int batchSize,
int topN,
String options,
long timeout)
Executes a SOW query and places a subscription. |
MessageStream |
sowAndSubscribe(String topic)
Executes a SOW query and places a subscription. |
MessageStream |
sowAndSubscribe(String topic,
String filter)
Executes a SOW query and places a subscription. |
CommandId |
sowDelete(MessageHandler messageHandler,
String topic,
String filter,
long timeout)
Executes a SOW delete with filter. |
CommandId |
sowDelete(MessageHandler messageHandler,
String topic,
String filter,
String options,
long timeout)
Executes a SOW delete with filter. |
Message |
sowDelete(String topic,
String filter,
long timeout)
Executes a SOW delete with filter. |
CommandId |
sowDeleteByData(MessageHandler messageHandler,
String topic,
String data,
long timeout)
Executes a SOW delete by data. |
CommandId |
sowDeleteByKeys(MessageHandler messageHandler,
String topic,
String keys,
long timeout)
Executes a SOW delete using the SowKey assigned by AMPS to specify the messages to delete. |
void |
startTimer()
Sends a start timer command to AMPS, which can be later stopped with a stop timer command. |
CommandId |
stopTimer(MessageHandler handler_)
Sends a stop timer command to AMPS |
CommandId |
subscribe(MessageHandler messageHandler,
String topic,
long timeout)
Places a subscription with AMPS. |
CommandId |
subscribe(MessageHandler messageHandler,
String topic,
String filter,
long timeout)
Places a subscription with AMPS. |
CommandId |
subscribe(MessageHandler messageHandler,
String topic,
String filter,
String options,
long timeout)
Places a subscription with AMPS. |
CommandId |
subscribe(MessageHandler messageHandler,
String topic,
String filter,
String options,
long timeout,
String subId)
Places a subscription with AMPS. |
MessageStream |
subscribe(String topic)
Places a subscription with AMPS. |
MessageStream |
subscribe(String topic,
String filter)
Places a subscription with AMPS. |
void |
unsubscribe()
Remove all of the client's subscriptions from AMPS. |
void |
unsubscribe(CommandId subscriptionId)
Remove a subscription from AMPS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ExceptionListener exceptionListener
public static final int MIN_PERSISTED_BOOKMARK_VERSION
public static final int MIN_MULTI_BOOKMARK_VERSION
Constructor Detail |
---|
public Client(String name)
name
- Name for the client. This name is used for duplicate
message detection and should be unique.public Client(String name, int version)
name
- Name for the client. This name is used for duplicate
message detection and should be unique.version
- Server version connecting topublic Client(String name, Transport transport)
name
- Name for the client. This name is used for duplicate
message detection and should be unique.transport
- Transport to use for this clientpublic Client(String name, Transport transport, int version)
name
- Name for the client. This name is used for duplicate
message detection and should be unique.transport
- Transport to use with the clientversion
- Server version connecting toMethod Detail |
---|
public String getName()
public URI getURI()
public int getServerVersion()
public static int getVersionAsInt(String version) throws CommandException
version
- The version string to convert.
CommandException
- The string doesn't represent a valid version.public Transport getTransport()
public void setBookmarkStore(BookmarkStore val)
val
- The new bookmark store.public BookmarkStore getBookmarkStore()
public void setPublishStore(Store store)
store
- The new publish store.public Store getPublishStore()
public void connect(String uri) throws ConnectionException
String
with the format:
transport://host:port/protocol
Notice that the protocol can be independent of the message type. 60East
recommends using the amps
protocol, although some
installations use one of the legacy protocols such as fix
,
nvfix
or xml
. Contact your server
administrator for the correct URI for the instance.
uri
- The URI string to connect to
ConnectionRefusedException
- The connection could not be established
AlreadyConnectedException
- The connection is already connected
InvalidURIException
- The specified URI is invalid
ProtocolException
- The protocol is invalid
TransportTypeException
- The transport type is invalid
ConnectionException
public void setDisconnectHandler(ClientDisconnectHandler disconnectHandler_)
ClientDisconnectHandler
. In the event that the Client is
disconnected from AMPS, the invoke
method from the
ClientDisconnectHandler will be invoked.
disconnectHandler_
- The disconnect handlerpublic ClientDisconnectHandler getDisconnectHandler()
ClientDisconnectHandler
set on self.
public void setUnhandledMessageHandler(MessageHandler messageHandler)
setLastChanceMessageHandler
instead.
MessageHandler
instance used when no other handler matches.
messageHandler
- The message handler used when no other handler matches.public void setLastChanceMessageHandler(MessageHandler messageHandler)
MessageHandler
instance used when no other handler matches.
messageHandler
- The message handler used when no other handler matches.public void setExceptionListener(ExceptionListener exceptionListener)
ExceptionListener
instance used for communicating absorbed exceptions.
exceptionListener
- The exception listener instance to invoke for exceptions.public void setSubscriptionManager(SubscriptionManager subscriptionManager)
SubscriptionManager
instance used for recording active subscriptions.
subscriptionManager
- The subscription manager invoked when the subscriptions change.public SubscriptionManager getSubscriptionManager()
SubscriptionManager
instance used for recording active subscriptions.
public void setDuplicateMessageHandler(MessageHandler messageHandler)
MessageHandler
instance used for duplicate messages.
messageHandler
- The message handler to invoke for duplicate messagespublic void setFailedWriteHandler(FailedWriteHandler handler_)
FailedWriteHandler
instance used to report on failed
messages that have been written.
handler_
- The handler to invoke for published duplicates.public void addConnectionStateListener(ConnectionStateListener listener_)
ConnectionStateListener
instance that will be invoked when this client connects or disconnects.
listener_
- The instance to invoke.public void removeConnectionStateListener(ConnectionStateListener listener_)
ConnectionStateListener
from being invoked when this client connects or disconnects.
listener_
- The instance to remove.protected void broadcastConnectionStateChanged(int newState_)
public void disconnect()
public void close()
close
in interface Closeable
public Message allocateMessage()
Message
appropriate for this client. This function should be
called rarely, since it does allocate a handful of small objects. Users sensitive
to garbage collection delays should cache the message object for later usage.
Message
instancepublic void send(Message message) throws DisconnectedException
Message
to AMPS via the Transport
used in the Client.
This method is provided for special cases. In general, you can get the
same results with additional error checking by using a Command
object with the execute or executeAsync methods.
message
- The message to send
DisconnectedException
- The connection was disconnected at time of sendpublic CommandId send(MessageHandler messageHandler, Message message, long timeout) throws AMPSException
Message
to AMPS and register the messageHandler for any messages
resulting from the command execution.
This method is provided for special cases. In general, you can get the
same results with additional error checking by using a Command
object with the execute or executeAsync methods.
messageHandler
- The message handler that'll receive messages for this commandmessage
- The message to sendtimeout
- The number of milliseconds to wait for command acknowledgment
AMPSException
- An exception occured while sending or waiting for a response to this Message.public MessageStream execute(Command command) throws AMPSException
MessageStream
.
This method creates a message based on the provided Command
,
sends the message to AMPS, and receives the results. AMPS sends the
message and receives the results on a background thread. That thread
populates the MessageStream returned by this method.
command
- The Command object containing the command to send to AMPS
AMPSException
public CommandId executeAsync(Command command, MessageHandler handler) throws AMPSException
Command
,
sends the message to AMPS, and invokes the provided
MessageHandler
to process messages returned in response
to the command. AMPS sends the message and receives the results
on a background thread. The MessageHandler runs on the background thread.
command
- The Command object containing the command to send to AMPShandler
- The MessageHandler to invoke to process messages received
AMPSException
public void setHeartbeat(int intervalSeconds_, int timeoutSeconds_) throws DisconnectedException
intervalSeconds_
- The time (seconds) between beats from the server.timeoutSeconds_
- The time (seconds) to allow silence on the connection before assuming it is dead.
DisconnectedException
- The client became disconnected while attempting to send the heartbeat request.public void setHeartbeat(int intervalSeconds_) throws DisconnectedException
intervalSeconds_
- The time (seconds) between beats from the server.
DisconnectedException
- The client became disconnected while attempting to send the heartbeat request.public long publish(byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength) throws AMPSException
topic
- the topic to publish totopicOffset
- the offset in topic where the topic beginstopicLength
- the length of the topic in the topic arraydata
- the data to publishdataOffset
- the offset in data where data beginsdataLength
- the length of the data
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public long publish(String topic, String data) throws AMPSException
topic
- Topic to publish the data todata
- Data to publish to the topic
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public long publish(byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength, int expiration) throws AMPSException
topic
- the topic to publish totopicOffset
- the offset in topic where the topic beginstopicLength
- the length of the topic in the topic arraydata
- the data to publishdataOffset
- the offset in data where data beginsdataLength
- the length of the dataexpiration
- the number of seconds until the message expires
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public long publish(String topic, String data, int expiration) throws AMPSException
topic
- Topic to publish the data todata
- Data to publish to the topicexpiration
- the number of seconds until the message expires
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public void deltaPublish(byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength) throws AMPSException
topic
- Topic to publish the data totopicOffset
- offset into topic array where the topic name beginstopicLength
- length of topic arraydata
- Data to publish to the topicdataOffset
- offset into data array where the data beginsdataLength
- length of data array
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public void deltaPublish(String topic, String data) throws AMPSException
topic
- Topic to publish the data todata
- Data to publish to the topic
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public void deltaPublish(byte[] topic, int topicOffset, int topicLength, byte[] data, int dataOffset, int dataLength, int expiration) throws AMPSException
topic
- Topic to publish the data totopicOffset
- offset into topic array where the topic name beginstopicLength
- length of topic arraydata
- Data to publish to the topicdataOffset
- offset into data array where the data beginsdataLength
- length of data arrayexpiration
- the number of seconds until the message expires
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public void deltaPublish(String topic, String data, int expiration) throws AMPSException
topic
- Topic to publish the data todata
- Data to publish to the topicexpiration
- the number of seconds until the message expires
DisconnectedException
- The client was disconnected at time of publish
StoreException
- An error occurred writing to the local HA store.
AMPSException
public void startTimer() throws AMPSException
ConnectionException
- A connection error occurred while sending.
AMPSException
public CommandId stopTimer(MessageHandler handler_) throws AMPSException
ConnectionException
- A connection error occured while sending.
AMPSException
public CommandId logon(long timeout) throws ConnectionException
timeout
- The number of milliseconds to wait for the command to exceute.
ConnectionException
- A connection error occured while logging on.
StoreException
- An error occured on the local HA store.public CommandId logon(long timeout, Authenticator authenticator) throws ConnectionException
timeout
- The number of milliseconds to wait for the command to executeauthenticator
- The custom authenticator object to authenticate against
TimedOutException
- The command execution exceeded the timeout value
DisconnectedException
- The operation failed because the connection was invalid
StoreException
- An error occured with the HA PublishStore.
ConnectionException
public CommandId logon() throws ConnectionException
TimedOutException
- The command execution exceeded the timeout value
DisconnectedException
- The operation failed because the connection was invalid
StoreException
- An error occured writing to the local HA store.
ConnectionException
public CommandId bookmarkSubscribe(MessageHandler messageHandler, String topic, String filter, CommandId subId, String bookmark, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filtersubId
- The subscription ID. You may optionally provide a subscribtion ID
to ease recovery scenarios, instead of having the system automatically
generate one for you. When used with the 'replace' option, this
is the subscription to be replaced. With a bookmark store,
this is the subscription ID used for recovery. So, when
using a persistent bookmark store, provide an explicit
subscription ID that is consistent across application restarts.bookmark
- The timestamp or bookmark location at which to start the subscription. This parameter can be the bookmark assigned by AMPS to a message, one of the special values in Client.Bookmarks
, or a string of the format YYYYmmddTHHMMSS, as described in the AMPS User's guide.options
- A Message.Options
value indicating desired options for this
subscription. Use Message.Options.None if no options are desired.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId bookmarkDeltaSubscribe(MessageHandler messageHandler, String topic, String filter, CommandId subId, String bookmark, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filtersubId
- The subscription ID. You may wish to supply your own subscription ID
to ease recovery scenarios, instead of having the system generate one for you.bookmark
- The timestamp or bookmark location at which to start the subscription. This parameter can be the bookmark assigned by AMPS to a message, one of the special values in Client.Bookmarks
, or a string of the format YYYYmmddTHHMMSS, as described in the AMPS User's guide.options
- A Message.Options
value indicating desired options for this
subscription. Use Message.Options.None if no options are desired.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId subscribe(MessageHandler messageHandler, String topic, String filter, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filtertimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId subscribe(MessageHandler messageHandler, String topic, String filter, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filteroptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId subscribe(MessageHandler messageHandler, String topic, String filter, String options, long timeout, String subId) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filteroptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)subId
- The subscription id to use for the subscription.
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public MessageStream subscribe(String topic) throws AMPSException
topic
- The topic to subscribe to
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public MessageStream subscribe(String topic, String filter) throws AMPSException
topic
- The topic to subscribe tofilter
- The filter
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId subscribe(MessageHandler messageHandler, String topic, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe totimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId deltaSubscribe(MessageHandler messageHandler, String topic, String filter, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filteroptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId deltaSubscribe(MessageHandler messageHandler, String topic, String filter, String options, long timeout, String subId) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filteroptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)subId
- The subscription id to use for the subscription.
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId deltaSubscribe(MessageHandler messageHandler, String topic, String filter, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filtertimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId deltaSubscribe(MessageHandler messageHandler, String topic, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe totimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public void unsubscribe(CommandId subscriptionId) throws DisconnectedException
subscriptionId
- The subscription identifier to remove
DisconnectedException
- The client was disconnected at the time of executionpublic void unsubscribe() throws DisconnectedException
DisconnectedException
- The client was disconnected at the time of executionpublic MessageStream sow(String topic, String filter) throws AMPSException
topic
- The topic to queryfilter
- The filter
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public MessageStream sow(String topic) throws AMPSException
topic
- The topic to query
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sow(MessageHandler messageHandler, String topic, String filter, String orderBy, String bookmark, int batchSize, int topN, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterorderBy
- The ordering propertybookmark
- The timestamp or bookmark location for a historical query. This parameter can be the bookmark assigned by AMPS to a message, one of the special values in Client.Bookmarks
, or a string of the format YYYYmmddTHHMMSS, as described in the AMPS User's guide.batchSize
- The batching parameter to use for the resultstopN
- The maximum number of records the server will return (default is all that match)timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sow(MessageHandler messageHandler, String topic, String filter, int batchSize, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sow(MessageHandler messageHandler, String topic, String filter, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sow(MessageHandler messageHandler, String topic, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tobatchSize
- The batching parameter to use for the resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sow(MessageHandler messageHandler, String topic, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe totimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public MessageStream sowAndSubscribe(String topic, String filter) throws AMPSException
topic
- The topic to subscribe tofilter
- The filter
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public MessageStream sowAndSubscribe(String topic) throws AMPSException
topic
- The topic to subscribe to
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, String filter, String orderBy, String bookmark, int batchSize, int topN, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterorderBy
- The ordering propertybookmark
- The timestamp or bookmark location for a historical query. This parameter can be the bookmark assigned by AMPS to a message, one of the special values in Client.Bookmarks
, or a string of the format YYYYmmddTHHMMSS, as described in the AMPS User's guide.batchSize
- The batching parameter to use for the SOW query resultstopN
- The maximum number of records the server will return (default is all that match)options
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultsoptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, boolean oofEnabled, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultsoofEnabled
- Specifies whether or not Out-of-Focus processing is enabledtimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tobatchSize
- The batching parameter to use for the SOW query resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndSubscribe(MessageHandler messageHandler, String topic, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe totimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, String filter, String orderBy, int batchSize, int topN, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterorderBy
- The ordering propertybatchSize
- The batching parameter to use for the SOW query resultstopN
- The maximum number of records the server will return (default is all that match)options
- A value from Message.Options indicating additional processing optionstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, boolean oofEnabled, boolean sendEmpties, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultsoofEnabled
- Specifies whether or not Out-of-Focus processing is enabledsendEmpties
- Specifies whether or not unchanged records are received on the delta subscriptionoptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, boolean oofEnabled, boolean sendEmpties, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultsoofEnabled
- Specifies whether or not Out-of-Focus processing is enabledsendEmpties
- Specifies whether or not unchanged records are received on the delta subscriptiontimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, String filter, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tofilter
- The filterbatchSize
- The batching parameter to use for the SOW query resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, int batchSize, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe tobatchSize
- The batching parameter to use for the SOW query resultstimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowAndDeltaSubscribe(MessageHandler messageHandler, String topic, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with matching messagestopic
- The topic to subscribe totimeout
- The maximum time to wait for the subscription to be placed (milliseconds)
SubscriptionAlreadyExistsException
- A subscription with this identifier is already registered
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowDelete(MessageHandler messageHandler, String topic, String filter, String options, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with stats and completed acknowledgementstopic
- The topic to subscribe tofilter
- The filteroptions
- A value from Message.Options indicating additional processing options.timeout
- The maximum time to wait for the SOW delete to be started to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowDelete(MessageHandler messageHandler, String topic, String filter, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with stats and completed acknowledgementstopic
- The topic to subscribe tofilter
- The filtertimeout
- The maximum time to wait for the SOW delete to be started to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public Message sowDelete(String topic, String filter, long timeout) throws AMPSException
topic
- The topic to subscribe tofilter
- The filtertimeout
- The maximum time to wait for the SOW delete to be started to be placed (milliseconds)
BadFilterException
- The provided filter is invalid
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowDeleteByKeys(MessageHandler messageHandler, String topic, String keys, long timeout) throws AMPSException
// DeleteMessageHandler receives a message containing
// the results of the delete.
DeleteMessageHandler dmh = new DeleteMessageHandler();
client.sowDeleteByKeys(dmh, message.getTopic(), message.getSowKey(), 1000);
messageHandler
- The message handler to invoke with stats and completed acknowledgementstopic
- The topic to execute the SOW delete againstkeys
- A comma separated list of SOW keys to be deletedtimeout
- The maximum time to wait for the SOW delete to be be placed (milliseconds)
BadRegexTopicException
- The topic specified was an invalid regular expression
TimedOutException
- The operation took longer than the timeout to execute
DisconnectedException
- The client wasn't connected when the operation was executed
AMPSException
public CommandId sowDeleteByData(MessageHandler messageHandler, String topic, String data, long timeout) throws AMPSException
messageHandler
- The message handler to invoke with stats and completed acknowledgementstopic
- The topic to execute the SOW delete againstdata
- The message to match and delete in the SOW cachetimeout
- The maximum time to wait for the SOW delete to be be placed (milliseconds)
AMPSException
- An error occurred while waiting for this command to be processed.public void publishFlush() throws DisconnectedException, TimedOutException
DisconnectedException
TimedOutException
public void publishFlush(long timeout) throws DisconnectedException, TimedOutException
timeout
- Number of milliseconds to wait for flush
DisconnectedException
TimedOutException
public long flush() throws DisconnectedException
DisconnectedException
public long flush(long timeout) throws DisconnectedException
timeout
- Number of milliseconds to wait for flush
DisconnectedException
public String getVersion()
public ConnectionInfo getConnectionInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |