public interface MessageSender
init()
and close()
methods should be used to establish and close a permanent connection.
It is a design consideration of any implementation whether to handle the connection establishment separately (and not measure it),
or to open and close a connection with every single request (and make it part of the performance measurement).
Most provided implementations (if not all) handle the connection separately as we are really interested only in measuring the message
exchange.
preSend(org.perfcake.message.Message, java.util.Properties)
and postSend(org.perfcake.message.Message)
methods are still not part of the performance measurement and can prepare the message for
actual sending or handle any cleanup.
send(org.perfcake.message.Message, org.perfcake.reporting.MeasurementUnit)
method must handle just the message exchange. No logging or complex error handling code should be placed here. Therefore
we allow any generic exception to be thrown.Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sender.
|
String |
getTarget()
Gets the target where to send the messages.
|
String |
getTarget(Properties properties)
Gets the target where to send the messages providing additional properties to replace placeholders in the
target template.
|
void |
init()
Initializes the sender.
|
void |
postSend(Message message)
Performs any action that needs to be done to complete the sending of the message but is not directly related to the sending operation and thus not measured.
|
void |
preSend(Message message,
Properties messageAttributes)
Performs any action that needs to be done to send the message but is not directly related to the sending operation and thus not measured.
|
Serializable |
send(Message message,
MeasurementUnit measurementUnit)
Sends a message.
|
MessageSender |
setTarget(String target)
Sets the target where to send the messages.
|
void init() throws PerfCakeException
PerfCakeException
- When anything fails, basically this happens when a connection to the target could not have been established.void close() throws PerfCakeException
PerfCakeException
- When it was not possible to close the target.void preSend(Message message, Properties messageAttributes) throws Exception
message
- Message to be sent.messageAttributes
- Attributes that can be used to replace placeholders in message and or target.Exception
- In case anything fails during the preparation.Serializable send(Message message, MeasurementUnit measurementUnit) throws Exception
message
- Message to be sent.measurementUnit
- Measurement unit that carries the current send iteration information.Exception
- When the send operation failed.void postSend(Message message) throws Exception
message
- Message that was sent.Exception
- In case anything fails during the finalization.String getTarget()
String getTarget(Properties properties)
properties
- Additional properties to replace placeholders in the target template.MessageSender setTarget(String target)
target
- The target to be set.Copyright © 2010–2017 PerfCake Community. All rights reserved.