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)
Create a Command with the Command field set.
|
Command(java.lang.String command)
Create a Command with the Command field set.
|
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()
Return the command type for this command.
|
CommandId |
getCommandId() |
java.lang.String |
getCorrelationId()
Returns the correlation Id set on 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()
Get the queryId for this command.
|
java.lang.String |
getSowKey()
Returns the SOW key on this command.
|
java.lang.String |
getSOWKey()
Deprecated.
Use getSowKey() instead.
|
java.lang.String |
getSowKeys()
Returns the SOW key on this command.
|
java.lang.String |
getSOWKeys()
Deprecated.
Use getSowKeys() instead
|
CommandId |
getSubId()
Get the subId set on this command.
|
long |
getTimeout()
Get 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()
Returns true if this command queries a SOW.
|
boolean |
isSubscribe()
Returns true if this command creates a subscription.
|
boolean |
needsSequenceNumber()
Returns true if this command can be associated with a client sequence number.
|
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 with a new Command type and re-initializes all other fields.
|
Command |
reset(java.lang.String command)
Resets this command with a new Command type and re-initializes all other 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.
|
Command |
setCommandId(CommandId commandId)
Set the commandId for this command.
|
Command |
setCorrelationId(java.lang.String correlationId_)
Sets the correlation Id for this command.
|
Command |
setData(byte[] data,
int offset,
int length)
Set the 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 the queryId for this command.
|
Command |
setSowKey(java.lang.String sowKey)
The SowKey for a command is used to publish to a SOW topic with
explicit keys set by the user rather than AMPS.
|
Command |
setSOWKey(java.lang.String sowKey)
Deprecated.
Use setSowKey() instead.
|
Command |
setSowKeys(java.lang.String sowKeys)
The SowKeys for a command are a comma-separated list
of the keys that AMPS assigns to SOW messages.
|
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)
Set the subId for this command.
|
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.
|
Command |
setTopic(java.lang.String topic)
Set the topic for this command.
|
Command |
setTopN(int topN)
Set the topN value for this command.
|
void |
unsetExpiration()
Clears any expiration value set on self.
|
public Command()
public Command(int command)
command
- A Message.Command
value indicating the AMPS command.public Command(java.lang.String command)
command
- A string indicating the AMPS 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 setpublic java.lang.String getSowKeys()
@Deprecated public java.lang.String getSOWKeys()
public Command setSowKeys(java.lang.String sowKeys)
Message.getSowKey()
method
on a message.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()
public final boolean isSow()
public boolean needsSequenceNumber()
public Command reset(int command)
command
- A Message.Command
value indicating the AMPS command.public Command reset(java.lang.String command)
command
- A string value indicating the AMPS command.public CommandId getCommandId()
public Command setCommandId(CommandId commandId)
commandId
- the commandId to setpublic CommandId getQueryId()
public Command setQueryId(CommandId queryId)
queryId
- the queryId to setpublic int getCommand()
public Command setCommand(int command)
command
- the command to setpublic 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 setpublic java.lang.String getOrderBy()
public Command setOrderBy(java.lang.String orderBy)
orderBy
- the orderBy to setpublic CommandId getSubId()
public Command setSubId(CommandId subId)
subId
- the subId to setpublic Command setSubId(java.lang.String subId)
subId
- the subId to setpublic 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 setpublic Command addAckType(int ackType)
ackType
- the ackType to addpublic java.lang.String getData()
public Command setData(java.lang.String data)
data
- the data to setpublic 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 setpublic int getTopN()
public Command setTopN(int topN)
topN
- the topN to setpublic int getBatchSize()
public Command setBatchSize(int batchSize)
batchSize
- the batchSize to setpublic int getExpiration()
hasExpiration()
to check if an
expiration is set.public boolean hasExpiration()
public Command setExpiration(int expiration)
expiration
- the expiration to setpublic void unsetExpiration()
protected CommandId prepare(Client client_) throws AMPSException
client_
- The client to bind againstAMPSException
- Thrown when preparing the command fails.public Command setClientSequenceNumber(long seqNumber)
seqNumber
- Sequence number for this commandpublic 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()