Class RabbitMQProducer

  • All Implemented Interfaces:
    MessageProducer

    public class RabbitMQProducer
    extends Object
    implements MessageProducer
    The message producer responsible to store message into RabbitMQ queue
    • Constructor Detail

      • RabbitMQProducer

        public RabbitMQProducer​(RabbitMQStore store)
        The RabbitMQ producer
        Parameters:
        store - the RabbitMQStore object
    • Method Detail

      • storeMessage

        public boolean storeMessage​(MessageContext synCtx)
        Store the given message into the queue and return whether the operation success or not
        Specified by:
        storeMessage in interface MessageProducer
        Parameters:
        synCtx - Message to be saved.
        Returns:
        true if storing of the message is successful, false otherwise.
      • cleanup

        public boolean cleanup()
        Used to close the channel opened in this object instance. This should be called after the end of each call on storeMessage method But instead of this, try with resources will close the channel
        Specified by:
        cleanup in interface MessageProducer
        Returns:
        true if clean up is successful, false otherwise.
      • getId

        public String getId()
        Get ID of this RabbitMQ producer
        Specified by:
        getId in interface MessageProducer
        Returns:
        the ID
      • setId

        public void setId​(int id)
        Set ID of this RabbitMQ producer
        Specified by:
        setId in interface MessageProducer
        Parameters:
        id - ID
      • setRoutingKey

        public void setRoutingKey​(String routingKey)
        Set the routing key bind with the exchange
        Parameters:
        routingKey - the message routing key
      • setExchangeName

        public void setExchangeName​(String exchangeName)
        Set the exchange name to publish the message
        Parameters:
        exchangeName - the exchange to publish the message to
      • setConnection

        public void setConnection​(com.rabbitmq.client.Connection connection)
        Set the Connection object
        Parameters:
        connection - a Connection object
      • setChannel

        public void setChannel​(com.rabbitmq.client.Channel channel)
        Set the Channel object
        Parameters:
        channel - a Channel object
      • setPublisherConfirmsEnabled

        public void setPublisherConfirmsEnabled​(boolean publisherConfirmsEnabled)
        Set the publisher confirm enabled or not
        Parameters:
        publisherConfirmsEnabled - publsher confirm enabled or not
      • isInitialized

        public boolean isInitialized()
        Verify to whether producer was initialized
        Returns:
        is initialized