Class DefaultMessagingService

java.lang.Object
org.kryonite.kryomessaging.service.DefaultMessagingService
All Implemented Interfaces:
MessagingService

public class DefaultMessagingService extends Object implements MessagingService
  • Field Details

  • Constructor Details

  • Method Details

    • sendMessage

      public void sendMessage(Message<?> message)
      Description copied from interface: MessagingService
      Send a message with any class as a payload.
      Specified by:
      sendMessage in interface MessagingService
      Parameters:
      message - to send into the queue.
    • setupExchange

      public void setupExchange(String exchange, com.rabbitmq.client.BuiltinExchangeType exchangeType) throws IOException
      Description copied from interface: MessagingService
      Setup an exchange with a specific type and name.
      Specified by:
      setupExchange in interface MessagingService
      Parameters:
      exchange - The exchanges name
      exchangeType - The exchanges BuiltinExchangeType
      Throws:
      IOException - when an error is encountered during exchange setup.
    • bindQueueToExchange

      public void bindQueueToExchange(String queue, String exchange) throws IOException
      Description copied from interface: MessagingService
      Bind a queue to an existing exchange.

      If the given queue doesn't exist it will be created automatically.

      Specified by:
      bindQueueToExchange in interface MessagingService
      Parameters:
      queue - The queues name
      exchange - The exchanges name
      Throws:
      IOException - when an error is encountered during binding process.
    • bindQueueToExchange

      public void bindQueueToExchange(String queue, String exchange, String routingKey) throws IOException
      Description copied from interface: MessagingService
      Bind a queue to an exchange with a specific routing key.

      If the given queue doesn't exist it will be created automatically.

      Specified by:
      bindQueueToExchange in interface MessagingService
      Parameters:
      queue - The queues name
      exchange - The exchanges name
      routingKey - a exchange look at when deciding how to route the message.
      Throws:
      IOException - when an error is encountered during binding process.
    • startConsuming

      public <T> void startConsuming(String queue, MessageCallback<T> callback, Class<T> classOfCallback) throws IOException
      Description copied from interface: MessagingService
      Start consuming messages from a queue.
      Specified by:
      startConsuming in interface MessagingService
      Type Parameters:
      T - is the type of the message.
      Parameters:
      queue - The queues name
      callback - used for consuming the messages.
      classOfCallback - is the class of the messages that should be consumed.
      Throws:
      IOException - when an error is encountered during consumption.