Class RabbitMQHelper


  • public class RabbitMQHelper
    extends Object
    Helper class for RabbitMQ operations.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Summary

      Constructors 
      Constructor Description
      RabbitMQHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeQuietly​(com.rabbitmq.client.Channel channel)
      Closes the channel.
      static void closeQuietly​(com.rabbitmq.client.Connection connection)
      Closes the connection.
      static void closeQuietly​(com.rabbitmq.client.Connection connection, List<String> queues)
      Closes the connection and deletes any auto-created queues.
      static com.rabbitmq.client.Channel createChannel​(adams.core.logging.LoggingSupporter logging, com.rabbitmq.client.Connection connection, int prefetchCount)
      Creates a new channel and returns it.
      static com.rabbitmq.client.Channel createChannel​(com.rabbitmq.client.Connection connection, int prefetchCount)
      Creates a new channel and returns it.
    • Constructor Detail

      • RabbitMQHelper

        public RabbitMQHelper()
    • Method Detail

      • createChannel

        public static com.rabbitmq.client.Channel createChannel​(com.rabbitmq.client.Connection connection,
                                                                int prefetchCount)
        Creates a new channel and returns it.
        Parameters:
        connection - the connection to use
        prefetchCount - how many jobs a client can pull off queue before having to ack them, 0 is unlimited
        Returns:
        the channel, null if failed to create or no connection available
      • createChannel

        public static com.rabbitmq.client.Channel createChannel​(adams.core.logging.LoggingSupporter logging,
                                                                com.rabbitmq.client.Connection connection,
                                                                int prefetchCount)
        Creates a new channel and returns it.
        Parameters:
        logging - for logging errors
        connection - the connection to use
        prefetchCount - how many jobs a client can pull off queue before having to ack them, 0 is unlimited
        Returns:
        the channel, null if failed to create or no connection available
      • closeQuietly

        public static void closeQuietly​(com.rabbitmq.client.Channel channel)
        Closes the channel.
        Parameters:
        channel - the channel to close, can be null
      • closeQuietly

        public static void closeQuietly​(com.rabbitmq.client.Connection connection)
        Closes the connection.
        Parameters:
        connection - the connection to close
      • closeQuietly

        public static void closeQuietly​(com.rabbitmq.client.Connection connection,
                                        List<String> queues)
        Closes the connection and deletes any auto-created queues.
        Parameters:
        connection - the connection to close
        queues - the auto-created queues to close