org.apache.qpid.ping
Class PingDurableClient
java.lang.Object
org.apache.qpid.requestreply.PingPongProducer
org.apache.qpid.ping.PingDurableClient
- All Implemented Interfaces:
- Runnable, ExceptionListener
- Direct Known Subclasses:
- PingSendOnlyClient
public class PingDurableClient
- extends PingPongProducer
- implements ExceptionListener
PingDurableClient is a variation of the PingPongProducer
ping tool. Instead of sending its pings and
receiving replies to them at the same time, this tool sends pings until it is signalled by some 'event' to stop
sending. It then waits for another signal before it re-opens a fresh connection and attempts to receive all of the
pings that it has succesfully sent. It is intended to be an interactive test that lets a user experiment with
failure conditions when using durable messaging.
The events that can stop it from sending are input from the user on the console, failure of its connection to
the broker, completion of sending a specified number of messages, or expiry of a specified duration. In all cases
it will do its best to clean up and close the connection before opening a fresh connection to receive the pings
with.
The event to re-connect and attempt to recieve the pings is input from the user on the console.
This ping client inherits the configuration properties of its parent class (PingPongProducer
) and
additionally accepts the following parameters:
Parameters
Parameter | Default | Comments
|
---|
numMessages | 100 | The total number of messages to send.
|
numMessagesToAction | -1 | The number of messages to send before taking a custom 'action'.
|
duration | 30S | The length of time to ping for. (Format dDhHmMsS, for d days, h hours,
m minutes and s seconds).
|
This ping client also overrides some of the defaults of its parent class, to provide a reasonable set up
when no parameters are specified.
Parameters
Parameter | Default | Comments
|
---|
uniqueDests | false | Prevents destination names being timestamped.
|
transacted | true | Only makes sense to test with transactions.
|
persistent | true | Only makes sense to test persistent.
|
durableDests | true | Should use durable queues with persistent messages.
|
commitBatchSize | 10
|
rate | 20 | Total default test time is 5 seconds.
|
When a number of messages or duration is specified, this ping client will ping until the first of those limits
is reached. Reaching the limit will be interpreted as the first signal to stop sending, and the ping client will
wait for the second signal before receiving its pings.
This class provides a mechanism for extensions to add arbitrary actions, after a particular number of messages
have been sent. When the number of messages equal the value set in the 'numMessagesToAction' property is method,
the takeAction()
method is called. By default this does nothing, but extensions of this class can provide
custom behaviour with alternative implementations of this method (for example taking a backup).
CRC Card
Responsibilities | Collaborations
|
---|
Send and receive pings.
|
Accept user input to signal stop sending.
|
Accept user input to signal start receiving.
|
Provide feedback on pings sent versus pings received.
|
Provide extension point for arbitrary action on a particular message count.
|
Fields inherited from class org.apache.qpid.requestreply.PingPongProducer |
_ackMode, _brokerDetails, _chainedMessageListener, _connection, _consAckMode, _consTransacted, _consumer, _consumerConnection, _consumerSession, _destinationName, _factoryName, _failAfterCommit, _failAfterSend, _failBeforeCommit, _failBeforeSend, _failOnce, _fileProperties, _isDurable, _isPubSub, _isUnique, _maxPendingSize, _messageSize, _noOfConsumers, _noOfDestinations, _overrideClientId, _password, _persistent, _pingDestinations, _producer, _producerSession, _publish, _queueJVMSequenceID, _queueNamePostfix, _queueSharedID, _rate, _rateLimiter, _replyDestination, _selector, _transacted, _txBatchSize, _username, _verbose, _virtualpath, ACK_MODE_DEFAULT, ACK_MODE_PROPNAME, BROKER_DEFAULT, BROKER_PROPNAME, CONSUME_ONLY_DEFAULT, CONSUME_ONLY_PROPNAME, CONSUMER_ACK_MODE_DEFAULT, CONSUMER_ACK_MODE_PROPNAME, CONSUMER_TRANSACTED_DEFAULT, CONSUMER_TRANSACTED_PROPNAME, defaults, DELAY_BEFORE_CONSUME, DELAY_BEFORE_CONSUME_PROPNAME, DESTINATION_COUNT_DEFAULT, DESTINATION_COUNT_PROPNAME, DURABLE_DESTS_DEFAULT, DURABLE_DESTS_PROPNAME, EXCLUSIVE_DEFAULT, FACTORY_NAME_DEAFULT, FACTORY_NAME_PROPNAME, FAIL_AFTER_COMMIT_DEFAULT, FAIL_AFTER_COMMIT_PROPNAME, FAIL_AFTER_SEND_DEFAULT, FAIL_AFTER_SEND_PROPNAME, FAIL_BEFORE_COMMIT_DEFAULT, FAIL_BEFORE_COMMIT_PROPNAME, FAIL_BEFORE_SEND_DEFAULT, FAIL_BEFORE_SEND_PROPNAME, FAIL_ONCE_DEFAULT, FAIL_ONCE_PROPNAME, FILE_PROPERTIES_DEAFULT, FILE_PROPERTIES_PROPNAME, MAX_PENDING_DEFAULT, MAX_PENDING_PROPNAME, MESSAGE_SIZE_DEAFULT, MESSAGE_SIZE_PROPNAME, MESSAGE_TIMESTAMP_PROPNAME, NO_LOCAL_DEFAULT, NUM_CONSUMERS_DEFAULT, NUM_CONSUMERS_PROPNAME, OVERRIDE_CLIENT_ID_DEAFULT, OVERRIDE_CLIENT_ID_PROPNAME, PASSWORD_DEFAULT, PASSWORD_PROPNAME, PERSISTENT_MODE_DEFAULT, PERSISTENT_MODE_PROPNAME, PING_QUEUE_NAME_DEFAULT, PING_QUEUE_NAME_PROPNAME, PREFETCH_DEFAULT, PREFILL_DEFAULT, PREFILL_PROPNAME, PUBSUB_DEFAULT, PUBSUB_PROPNAME, QUEUE_NAME_POSTFIX_DEFAULT, QUEUE_NAME_POSTFIX_PROPNAME, RATE_DEFAULT, RATE_PROPNAME, SELECTOR_DEFAULT, SELECTOR_PROPNAME, SEND_ONLY_DEFAULT, SEND_ONLY_PROPNAME, TIMEOUT_DEFAULT, TIMEOUT_PROPNAME, timestampFormatter, TRANSACTED_DEFAULT, TRANSACTED_PROPNAME, TX_BATCH_SIZE_DEFAULT, TX_BATCH_SIZE_PROPNAME, UNIQUE_DESTS_DEFAULT, UNIQUE_DESTS_PROPNAME, USERNAME_DEFAULT, USERNAME_PROPNAME, VERBOSE_DEFAULT, VERBOSE_PROPNAME, VIRTUAL_HOST_DEFAULT, VIRTUAL_HOST_PROPNAME |
Method Summary |
protected void |
closeConnection()
|
List<Destination> |
getReplyDestinations()
Returns the ping destinations themselves as the reply destinations for this pinger to listen to. |
Thread |
getShutdownHook()
Gets a shutdown hook that will cleanly shut this down when it is running the ping loop. |
static void |
main(String[] args)
Starts the ping/wait/receive process. |
protected void |
receive(int messagesSent)
|
protected int |
send()
Performs the main test procedure implemented by this ping client. |
void |
takeAction()
Performs an aribtrary action once the 'numMesagesToAction' count is reached on sending messages. |
Methods inherited from class org.apache.qpid.requestreply.PingPongProducer |
close, commitTx, createConnection, createPingDestinations, createProducer, createReplyConsumers, establishConnection, getConsumersPerDestination, getExpectedNumPings, getTestMessage, getTimestamp, onException, onMessageWithConsumerNo, pause, pingAndWaitForReply, pingAndWaitForReply, pingLoop, pingNoWaitForReply, removeChainedMessageListener, run, sendMessage, setChainedMessageListener, setTimestamp, setupCorrelationID, start, stop, waitForUser |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NUM_MESSAGES_PROPNAME
public static final String NUM_MESSAGES_PROPNAME
- See Also:
- Constant Field Values
NUM_MESSAGES_DEFAULT
public static final String NUM_MESSAGES_DEFAULT
- See Also:
- Constant Field Values
DURATION_PROPNAME
public static final String DURATION_PROPNAME
- See Also:
- Constant Field Values
DURATION_DEFAULT
public static final String DURATION_DEFAULT
- See Also:
- Constant Field Values
NUM_MESSAGES_TO_ACTION_PROPNAME
public static final String NUM_MESSAGES_TO_ACTION_PROPNAME
- See Also:
- Constant Field Values
NUM_MESSAGES_TO_ACTION_DEFAULT
public static final String NUM_MESSAGES_TO_ACTION_DEFAULT
- See Also:
- Constant Field Values
PingDurableClient
public PingDurableClient(Properties overrides)
throws Exception
- Throws:
Exception
- Any exceptions are allowed to fall through.
main
public static void main(String[] args)
- Starts the ping/wait/receive process.
- Parameters:
args
- The command line arguments.
send
protected int send()
throws Exception
- Performs the main test procedure implemented by this ping client. See the class level comment for details.
- Throws:
Exception
closeConnection
protected void closeConnection()
receive
protected void receive(int messagesSent)
throws Exception
- Throws:
Exception
getReplyDestinations
public List<Destination> getReplyDestinations()
- Returns the ping destinations themselves as the reply destinations for this pinger to listen to. This has the
effect of making this pinger listen to its own pings.
- Overrides:
getReplyDestinations
in class PingPongProducer
- Returns:
- The ping destinations.
getShutdownHook
public Thread getShutdownHook()
- Gets a shutdown hook that will cleanly shut this down when it is running the ping loop. This can be registered with
the runtime system as a shutdown hook. This shutdown hook sets an additional terminate flag, compared with the
shutdown hook in
PingPongProducer
, because the publish flag is used to indicate that sending or receiving
message should stop, not that the application should termiante.
- Overrides:
getShutdownHook
in class PingPongProducer
- Returns:
- A shutdown hook for the ping loop.
takeAction
public void takeAction()
- Performs an aribtrary action once the 'numMesagesToAction' count is reached on sending messages. This default
implementation does nothing.
Licensed to the Apache Software Foundation