Package org.apache.nutch.rabbitmq

## Class RabbitMQClient

- java.lang.Object
- - org.apache.nutch.rabbitmq.RabbitMQClient

-     public class RabbitMQClient
      extends Object

  Client for RabbitMQ

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RabbitMQClient​(String uri)` | Builds a new instance of `RabbitMQClient`
    `RabbitMQClient​(String serverHost, int serverPort, String serverVirtualHost, String serverUsername, String serverPassword)` | Builds a new instance of `RabbitMQClient`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `bind​(String exchangeName, String exchangeOptions, String queueName, String queueOptions, String bindingKey, String bindingArguments)` | Creates a relationship between an exchange and a queue.
    `void` | `close()` | Closes the channel and the connection with the server.
    `void` | `openChannel()` | Opens a new channel into the opened connection.
    `void` | `publish​(String exchangeName, String routingKey, RabbitMQMessage message)` | Publishes a new message over an exchange.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RabbitMQClient

          public RabbitMQClient​(String serverHost,
                                int serverPort,
                                String serverVirtualHost,
                                String serverUsername,
                                String serverPassword)
                         throws IOException

      Builds a new instance of `RabbitMQClient`
      Parameters:
        `serverHost` - The server host.
        `serverPort` - The server port.
        `serverVirtualHost` - The virtual host into the RabbitMQ server.
        `serverUsername` - The username to access the server.
        `serverPassword` - The password to access the server.
      Throws:
        `IOException` - It is thrown if there is some issue during the connection creation.

    - #### RabbitMQClient

          public RabbitMQClient​(String uri)
                         throws IOException

      Builds a new instance of `RabbitMQClient`
      Parameters:
        `uri` - The connection parameters in the form amqp://userName:password@hostName:portNumber/virtualHost
      Throws:
        `IOException` - It is thrown if there is some issue during the connection creation.

  - ### Method Detail

    - #### openChannel

          public void openChannel()
                           throws IOException

      Opens a new channel into the opened connection.
      Throws:
        `IOException` - It is thrown if there is some issue during the channel creation.

    - #### bind

          public void bind​(String exchangeName,
                           String exchangeOptions,
                           String queueName,
                           String queueOptions,
                           String bindingKey,
                           String bindingArguments)
                    throws IOException

      Creates a relationship between an exchange and a queue.
      Parameters:
        `exchangeName` - The exchange's name.
        `exchangeOptions` - Options used when the exchange is created.

        It must have the form type={type},durable={durable} where:

        - {type} is fanout, direct, headers or topic
        - {durable} is true or false
        `queueName` - The queue's name.
        `queueOptions` - Options used when the queue is created.

        It must have the form durable={type},exclusive={durable},auto-delete={durable},arguments={durable} where:

        - durable is true or false
        - exclusive is true or false
        - auto-delete is true or false
        - arguments must have the for {key1:value1;key2:value2}
        `bindingKey` - The routine key to use for the binding.
        `bindingArguments` - This parameter is only used when the exchange's type is headers. In other cases is ignored.

        It must have the form key1=value1,key2=value2

      Throws:
        `IOException` - If there is some issue creating the relationship.

    - #### publish

          public void publish​(String exchangeName,
                              String routingKey,
                              RabbitMQMessage message)
                       throws IOException

      Publishes a new message over an exchange.
      Parameters:
        `exchangeName` - The exchange's name where the message will be published.
        `routingKey` - The routing key used to route the message in the exchange.
        `message` - The message itself.
      Throws:
        `IOException` - If there is some issue publishing the message.

    - #### close

          public void close()
                     throws IOException

      Closes the channel and the connection with the server.
      Throws:
        `IOException` - If there is some issue trying to close the channel or connection.