public abstract class AbstractSender extends Object implements MessageSender
Constructor and Description |
---|
AbstractSender() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sender.
|
abstract void |
doClose() |
abstract void |
doInit(Properties messageAttributes) |
abstract Serializable |
doSend(Message message,
MeasurementUnit measurementUnit)
Actually performs the send operation.
|
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.
|
boolean |
isKeepConnection()
Should we try to preserve connection between sending of individual messages?
|
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.
|
String |
safeGetTarget(Properties properties)
Gets the target in a safe way to avoid NPE when properties are null.
|
Serializable |
send(Message message,
MeasurementUnit measurementUnit)
Sends a message.
|
AbstractSender |
setKeepConnection(boolean keepConnection)
Should we try to preserve connection between sending of individual messages?
|
AbstractSender |
setTarget(String target)
Sets the target where to send the messages.
|
public final void init() throws PerfCakeException
MessageSender
init
in interface MessageSender
PerfCakeException
- When anything fails, basically this happens when a connection to the target could not have been established.public abstract void doInit(Properties messageAttributes) throws PerfCakeException
PerfCakeException
public final void close() throws PerfCakeException
MessageSender
close
in interface MessageSender
PerfCakeException
- When it was not possible to close the target.public abstract void doClose() throws PerfCakeException
PerfCakeException
public final Serializable send(Message message, MeasurementUnit measurementUnit) throws Exception
MessageSender
send
in interface MessageSender
message
- Message to be sent.measurementUnit
- Measurement unit that carries the current send iteration information.Exception
- When the send operation failed.public void preSend(Message message, Properties messageAttributes) throws Exception
MessageSender
preSend
in interface MessageSender
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.public abstract Serializable doSend(Message message, MeasurementUnit measurementUnit) throws Exception
message
- Message to be sent.measurementUnit
- Measurement unit carrying the current stop-watch.Exception
- When the sending operation failed.MessageSender.send(org.perfcake.message.Message, org.perfcake.reporting.MeasurementUnit)
public void postSend(Message message) throws Exception
MessageSender
postSend
in interface MessageSender
message
- Message that was sent.Exception
- In case anything fails during the finalization.public final String getTarget()
MessageSender
getTarget
in interface MessageSender
public final String getTarget(Properties properties)
MessageSender
getTarget
in interface MessageSender
properties
- Additional properties to replace placeholders in the target template.public final String safeGetTarget(Properties properties)
properties
- Properties to replace placeholders in the target.public final AbstractSender setTarget(String target)
MessageSender
setTarget
in interface MessageSender
target
- The target to be set.public boolean isKeepConnection()
public AbstractSender setKeepConnection(boolean keepConnection)
keepConnection
- True when the connection should be kept open.Copyright © 2010–2017 PerfCake Community. All rights reserved.