public class Command
extends java.lang.Object
Client
execute() method or asynchronously via the executeAsync()
methods.
Command is designed to be used as a "builder" enabling AMPS commands
to be built easily, for example:
Client client = new Client(...); for(Message m : client.execute(new Command("sow").setTopic("topic"))) { ... }Notice that the
Message
class can represent both command messages
to AMPS and response messages from AMPS. In contrast, Command represents
only commands to AMPS, so the class includes only properties that
are valid on outgoing commands.Constructor and Description |
---|
Command()
Create a new Command with no command type or arguments set.
|
Command(int command) |
Command(java.lang.String command)
Create a new `Command` object with the specified command code.
|
Modifier and Type | Method and Description |
---|---|
Command |
addAckType(int ackType)
Adds an additional ackType to the ackTypes already set
for this Command.
|
int |
getAckType()
Get the ackType for this command.
|
int |
getBatchSize()
Get the batchSize set on this command.
|
java.lang.String |
getBookmark()
Get the bookmark for this command.
|
long |
getClientSequenceNumber()
Get the client sequence number set on this command.
|
int |
getCommand()
Retrieves the command type associated with this `Command` object.
|
CommandId |
getCommandId()
Gets the automatically generated command ID associated with this command.
|
java.lang.String |
getCorrelationId()
Gets the correlation Id set with this command.
|
java.lang.String |
getData()
Get the data set on this command.
|
int |
getExpiration()
Get the expiration set on this command.
|
java.lang.String |
getFilter()
Get the filter for this command.
|
java.lang.String |
getOptions()
Get the options for this command.
|
java.lang.String |
getOrderBy()
Get the orderBy clause for this command.
|
CommandId |
getQueryId()
Retrieve the query identifier associated with the 'Command' object.
|
java.lang.String |
getSowKey()
Retrieves the State of the World (SOW) key associated with this instance.
|
java.lang.String |
getSOWKey()
Deprecated.
Use getSowKey() instead.
|
java.lang.String |
getSowKeys()
Returns the SOW keys on this command.
|
java.lang.String |
getSOWKeys()
Deprecated.
Use getSowKeys() instead
|
CommandId |
getSubId()
Get the subId set on this command.
|
long |
getTimeout()
Gets the timeout set on this command.
|
java.lang.String |
getTopic()
Get the topic set on this command.
|
int |
getTopN()
Get the topN value for this command.
|
boolean |
hasExpiration()
Returns true if this command has an expiration set.
|
boolean |
isSow()
Checks if the current command represents a State of the World (SOW)
operation.
|
boolean |
isSubscribe()
Checks if the current command represents a subscription.
|
boolean |
needsSequenceNumber()
Checks whether a sequence number is needed for this message based on the
message command.
|
protected CommandId |
prepare(Client client_)
Binds self to a given client, preparing a message from that client to be
sent.
|
Command |
reset(int command)
Resets this 'Command' object with a new Command type and re-initializes all
other fields altering its purpose.
|
Command |
reset(java.lang.String command)
Resets the current 'Command' object with a new command type specified as
a string value and re-initializes all associated fields.
|
Command |
setAckType(int ackType)
Set the ackType for this command.
|
Command |
setBatchSize(int batchSize)
Set the batchSize for this command.
|
Command |
setBookmark(java.lang.String bookmark)
Set the bookmark for this command.
|
Command |
setClientSequenceNumber(long seqNumber)
Sets the client sequence number for this command.
|
Command |
setCommand(int command)
Set the command type for this 'Command' object.
|
Command |
setCommandId(CommandId commandId)
Sets a unique command identifier 'CommandId' for this `Command` object.
|
Command |
setCorrelationId(java.lang.String correlationId_)
Sets the correlation Id for this command.
|
Command |
setData(byte[] data,
int offset,
int length)
Set the raw data for this command.
|
Command |
setData(CompositeMessageBuilder builder)
Set the data for this command.
|
Command |
setData(java.lang.String data)
Set the data for this command.
|
Command |
setExpiration(int expiration)
Set the expiration for this command.
|
Command |
setFilter(java.lang.String filter)
Set the filter for this command.
|
Command |
setOptions(java.lang.String options)
Set the options for this command.
|
Command |
setOrderBy(java.lang.String orderBy)
Set the orderBy clause for this command.
|
Command |
setQueryId(CommandId queryId)
Set a custom QueryId for this Command.
|
Command |
setSowKey(java.lang.String sowKey)
The SowKey for a command is only used to publish to a SOW topic and if
the user wants to restrict the command to a set of messages identified
by key, SowKeys is used instead.
|
Command |
setSOWKey(java.lang.String sowKey)
Deprecated.
Use setSowKey() instead.
|
Command |
setSowKeys(java.lang.String sowKeys)
Sets the SowKeys for this command.
|
Command |
setSOWKeys(java.lang.String sowKeys)
Deprecated.
Use setSowKeys() instead.
|
Command |
setSubId(CommandId subId)
Set the subId for this command.
|
Command |
setSubId(java.lang.String subId)
Sets the subId for this command using a string representation.
|
Command |
setTimeout(long timeout)
Set the timeout for this command (in milliseconds).
|
Command |
setTopic(byte[] topic,
int offset,
int length)
Set the topic for this command from raw bytes, offset, and length.
|
Command |
setTopic(java.lang.String topic)
Set the topic for this command.
|
Command |
setTopN(int topN)
Sets the top_n header for this command.
|
void |
unsetExpiration()
Clears any expiration value set on self.
|
public Command()
public Command(java.lang.String command)
command
- A Message.Command
value indicating the AMPS command.public Command(int command)
@Deprecated public java.lang.String getSOWKey()
public java.lang.String getSowKey()
@Deprecated public Command setSOWKey(java.lang.String sowKey)
Message.getSowKey()
method
on a message.sowKey
- the sow key to setpublic Command setSowKey(java.lang.String sowKey)
Message.getSowKey()
method on a message.sowKey
- the sow key to setsetSowKeys(String)
,
getSowKeys()
public java.lang.String getSowKeys()
@Deprecated public java.lang.String getSOWKeys()
public Command setSowKeys(java.lang.String sowKeys)
Message.getSowKey()
method on a message. This method specifies
that the command is only intended to apply to the keys provided.You
cannot perform bulk updates by including multiple SOW keys in a single
publish operation. It also works to limit queiries.sowKeys
- the sow keys to set@Deprecated public Command setSOWKeys(java.lang.String sowKeys)
Message.getSowKey()
method on a message.sowKeys
- the sow keys to setpublic final boolean isSubscribe()
true
if this command is a subscription command,
otherwise false
.public final boolean isSow()
true
if this command queries a SOW, otherwise
false
.public boolean needsSequenceNumber()
true
if this command can be associated with a client
sequence number, false
otherwise.public Command reset(int command)
command
- A Message.Command
value indicating the AMPS command.public Command reset(java.lang.String command)
command
- A string representing the new command type.public CommandId getCommandId()
public Command setCommandId(CommandId commandId)
commandId
- A unique command identifier to be associated with this
`Command`.public CommandId getQueryId()
public Command setQueryId(CommandId queryId)
queryId
- A unique query identifier to be associated with this
`Command`.public int getCommand()
public Command setCommand(int command)
command
- An integer representing the command type to be associated with
this `Command`.public java.lang.String getTopic()
public Command setTopic(java.lang.String topic)
topic
- the topic to setpublic Command setTopic(byte[] topic, int offset, int length)
topic
- The raw bytes to be used for the topic.offset
- The offset into topic where the topic data beginslength
- The length of the topic.public java.lang.String getFilter()
public Command setFilter(java.lang.String filter)
filter
- The filter to set.public java.lang.String getOrderBy()
public Command setOrderBy(java.lang.String orderBy)
orderBy
- The orderBy to set.public CommandId getSubId()
public Command setSubId(CommandId subId)
subId
- The subId to set.public Command setSubId(java.lang.String subId)
subId
- The subId to set.public java.lang.String getBookmark()
public Command setBookmark(java.lang.String bookmark)
bookmark
- the bookmark to setpublic java.lang.String getOptions()
public Command setOptions(java.lang.String options)
options
- the options to setpublic int getAckType()
public Command setAckType(int ackType)
ackType
- The ackType to set.public Command addAckType(int ackType)
ackType
- the ackType to addpublic java.lang.String getData()
public Command setData(java.lang.String data)
data
- The data to set.public Command setData(byte[] data, int offset, int length)
data
- The raw bytes to be used for the data.offset
- The offset into data where the data begins.length
- The length of the data.public Command setData(CompositeMessageBuilder builder)
builder
- a CompositeMessageBuilder
to set self's data from.public long getTimeout()
public Command setTimeout(long timeout)
timeout
- The timeout to set.public int getTopN()
public Command setTopN(int topN)
topN
- The topN to set.public int getBatchSize()
public Command setBatchSize(int batchSize)
batchSize
- The batchSize to set.public int getExpiration()
hasExpiration()
to check if an
expiration is set.public boolean hasExpiration()
public Command setExpiration(int expiration)
expiration
- The expiration to set.public void unsetExpiration()
protected CommandId prepare(Client client_) throws AMPSException
client_
- The client to bind against.AMPSException
- Thrown when preparing the command fails.public Command setClientSequenceNumber(long seqNumber)
seqNumber
- Sequence number for this command.public long getClientSequenceNumber()
public Command setCorrelationId(java.lang.String correlationId_)
correlationId_
- The CorrelationId is a user provided string included in
the log message for a logon.
AMPS does not interpret or use this string for any
other purpose.public java.lang.String getCorrelationId()