public class DataSenderImpl extends Object implements DataSender
DataSender interface.
Use the internal DataSenderImpl.Builder class for creating instances of the
DataSenderImpl class. Note that the created
DataSenderImpl will either use a given RabbitQueue or create
a new one. In both cases the receiver will become the owner of the queue,
i.e., if the DataSenderImpl instance is closed the queue will be
closed as well.
Note that choosing a message buffer size smaller than
DEFAULT_MESSAGE_BUFFER_SIZE=1000
might lead the sender to get stuck since confirmations might be sent rarely
by the RabbitMQ broker.
| Modifier and Type | Class and Description |
|---|---|
static class |
DataSenderImpl.Builder |
protected class |
DataSenderImpl.DataSenderConfirmHandler |
protected static class |
DataSenderImpl.Message |
| Modifier and Type | Field and Description |
|---|---|
private DataSenderImpl.DataSenderConfirmHandler |
confirmHandler |
private static int |
DEFAULT_DELIVERY_MODE |
private static int |
DEFAULT_MESSAGE_BUFFER_SIZE |
private int |
deliveryMode |
private static org.slf4j.Logger |
LOGGER |
private RabbitQueue |
queue |
| Modifier | Constructor and Description |
|---|---|
protected |
DataSenderImpl(RabbitQueue queue,
int deliveryMode,
int messageConfirmBuffer) |
| Modifier and Type | Method and Description |
|---|---|
static DataSenderImpl.Builder |
builder()
Returns a newly created
DataSenderImpl.Builder. |
void |
close() |
void |
closeWhenFinished()
A blocking method that closes the sender when its work is done, i.e., all
messages have been consumed by receivers from the queue.
|
protected void |
sendData(com.rabbitmq.client.AMQP.BasicProperties properties,
byte[] data) |
void |
sendData(byte[] data)
Send the given data to the queue.
|
protected void |
sendData(byte[] data,
com.rabbitmq.client.AMQP.BasicProperties.Builder probBuilder) |
private static final org.slf4j.Logger LOGGER
private static final int DEFAULT_MESSAGE_BUFFER_SIZE
private static final int DEFAULT_DELIVERY_MODE
private RabbitQueue queue
private final int deliveryMode
private final DataSenderImpl.DataSenderConfirmHandler confirmHandler
protected DataSenderImpl(RabbitQueue queue, int deliveryMode, int messageConfirmBuffer)
public void sendData(byte[] data)
throws IOException
DataSendersendData in interface DataSenderdata - the data that should be sentIOException - if an exception occurs during the communication with the
queueprotected void sendData(byte[] data,
com.rabbitmq.client.AMQP.BasicProperties.Builder probBuilder)
throws IOException
IOExceptionprotected void sendData(com.rabbitmq.client.AMQP.BasicProperties properties,
byte[] data)
throws IOException
IOExceptionpublic void closeWhenFinished()
DataSendercloseWhenFinished in interface DataSenderpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic static DataSenderImpl.Builder builder()
DataSenderImpl.Builder.DataSenderImpl.Builder instanceCopyright © 2017–2018. All rights reserved.