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 static int |
DEFAULT_MESSAGE_SIZE |
private int |
deliveryMode |
protected IdGenerator |
idGenerator |
private static org.slf4j.Logger |
LOGGER |
private int |
maxMessageSize |
private int |
messageSize |
private String |
name |
private RabbitQueue |
queue |
| Modifier | Constructor and Description |
|---|---|
protected |
DataSenderImpl(RabbitQueue queue,
IdGenerator idGenerator,
int messageSize,
int deliveryMode,
int messageConfirmBuffer,
String name) |
| 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.
|
void |
sendData(byte[] data,
String dataId)
Send the given data to the queue using the given Id as identifier.
|
void |
sendData(InputStream is)
Send the given data to the queue.
|
void |
sendData(InputStream is,
String dataId)
Send the given data to the queue using the given Id as identifier.
|
protected void |
sendData(InputStream is,
String dataId,
com.rabbitmq.client.AMQP.BasicProperties.Builder probBuilder) |
private static final org.slf4j.Logger LOGGER
private static final int DEFAULT_MESSAGE_SIZE
private static final int DEFAULT_MESSAGE_BUFFER_SIZE
private static final int DEFAULT_DELIVERY_MODE
protected IdGenerator idGenerator
private RabbitQueue queue
private final int messageSize
private final int maxMessageSize
private final int deliveryMode
private final DataSenderImpl.DataSenderConfirmHandler confirmHandler
private final String name
protected DataSenderImpl(RabbitQueue queue, IdGenerator idGenerator, int messageSize, int deliveryMode, int messageConfirmBuffer, String name)
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
queuepublic void sendData(byte[] data,
String dataId)
throws IOException
DataSendersendData in interface DataSenderdata - the data that should be sentdataId - the Id that is used as identifierIOException - if an exception occurs during the communication with the
queuepublic void sendData(InputStream is) throws IOException
DataSendersendData in interface DataSenderis - an InputStream from which the data is readIOException - if an exception occurs during the communication with the
queuepublic void sendData(InputStream is, String dataId) throws IOException
DataSendersendData in interface DataSenderis - an InputStream from which the data is readdataId - the Id that is used as identifierIOException - if an exception occurs during the communication with the
queueprotected void sendData(InputStream is, String dataId, 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.