Package org.hobbit.core.rabbit
Class DataSenderImpl
java.lang.Object
org.hobbit.core.rabbit.DataSenderImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,DataSender
Implementation of the
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.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataSenderImpl.DataSenderConfirmHandlerprivate static final intprivate static final intprivate final intprivate static final org.slf4j.Loggerprivate RabbitQueue -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataSenderImpl(RabbitQueue queue, int deliveryMode, int messageConfirmBuffer) -
Method Summary
Modifier and TypeMethodDescriptionstatic DataSenderImpl.Builderbuilder()Returns a newly createdDataSenderImpl.Builder.voidclose()voidA blocking method that closes the sender when its work is done, i.e., all messages have been consumed by receivers from the queue.voidsendData(byte[] data) Send the given data to the queue.protected voidsendData(byte[] data, com.rabbitmq.client.AMQP.BasicProperties.Builder probBuilder) protected voidsendData(com.rabbitmq.client.AMQP.BasicProperties properties, byte[] data)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DEFAULT_MESSAGE_BUFFER_SIZE
private static final int DEFAULT_MESSAGE_BUFFER_SIZE- See Also:
-
DEFAULT_DELIVERY_MODE
private static final int DEFAULT_DELIVERY_MODE- See Also:
-
queue
-
deliveryMode
private final int deliveryMode -
confirmHandler
-
-
Constructor Details
-
DataSenderImpl
-
-
Method Details
-
sendData
Description copied from interface:DataSenderSend the given data to the queue.- Specified by:
sendDatain interfaceDataSender- Parameters:
data- the data that should be sent- Throws:
IOException- if an exception occurs during the communication with the queue
-
sendData
protected void sendData(byte[] data, com.rabbitmq.client.AMQP.BasicProperties.Builder probBuilder) throws IOException - Throws:
IOException
-
sendData
protected void sendData(com.rabbitmq.client.AMQP.BasicProperties properties, byte[] data) throws IOException - Throws:
IOException
-
closeWhenFinished
public void closeWhenFinished()Description copied from interface:DataSenderA blocking method that closes the sender when its work is done, i.e., all messages have been consumed by receivers from the queue.- Specified by:
closeWhenFinishedin interfaceDataSender
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
builder
Returns a newly createdDataSenderImpl.Builder.- Returns:
- a new
DataSenderImpl.Builderinstance
-