Class DataSenderImpl

java.lang.Object
org.hobbit.core.rabbit.DataSenderImpl
All Implemented Interfaces:
Closeable, AutoCloseable, DataSender

public class DataSenderImpl extends Object implements 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)
  • Field Details

  • Constructor Details

    • DataSenderImpl

      protected DataSenderImpl(RabbitQueue queue, int deliveryMode, int messageConfirmBuffer)
  • Method Details

    • sendData

      public void sendData(byte[] data) throws IOException
      Description copied from interface: DataSender
      Send the given data to the queue.
      Specified by:
      sendData in interface DataSender
      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: DataSender
      A 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:
      closeWhenFinished in interface DataSender
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • builder

      public static DataSenderImpl.Builder builder()
      Returns a newly created DataSenderImpl.Builder.
      Returns:
      a new DataSenderImpl.Builder instance