Class RpcClient

java.lang.Object
com.rabbitmq.client.RpcClient
Direct Known Subclasses:
JsonRpcClient

public class RpcClient extends Object
Convenience class which manages simple RPC-style communication. The class is agnostic about the format of RPC arguments / return values. It simply provides a mechanism for sending a message to an exchange with a given routing key, and waiting for a response.
  • Field Details

  • Constructor Details

    • RpcClient

      public RpcClient(Channel channel, String exchange, String routingKey, String replyTo, int timeout) throws IOException
      Construct a new RpcClient that will communicate on the given channel, sending requests to the given exchange with the given routing key. Causes the creation of a temporary private autodelete queue. The name of this queue can be specified.
      Parameters:
      channel - the channel to use for communication
      exchange - the exchange to connect to
      routingKey - the routing key
      replyTo - the queue where the server should put the reply
      timeout - milliseconds before timing out on wait for response
      Throws:
      IOException - if an error is encountered
    • RpcClient

      public RpcClient(Channel channel, String exchange, String routingKey, String replyTo) throws IOException
      Construct a new RpcClient that will communicate on the given channel, sending requests to the given exchange with the given routing key. Causes the creation of a temporary private autodelete queue. The name of the queue can be provided (only relevant for RabbitMQ servers that do not support Direct Reply-to. Waits forever for responses (that is, no timeout).
      Parameters:
      channel - the channel to use for communication
      exchange - the exchange to connect to
      routingKey - the routing key
      replyTo - the queue where the server should put the reply
      Throws:
      IOException - if an error is encountered
    • RpcClient

      public RpcClient(Channel channel, String exchange, String routingKey) throws IOException
      Construct a new RpcClient that will communicate on the given channel, sending requests to the given exchange with the given routing key. Direct Reply-to will be used for response propagation. Waits forever for responses (that is, no timeout).
      Parameters:
      channel - the channel to use for communication
      exchange - the exchange to connect to
      routingKey - the routing key
      Throws:
      IOException - if an error is encountered
    • RpcClient

      public RpcClient(Channel channel, String exchange, String routingKey, int timeout) throws IOException
      Construct a new RpcClient that will communicate on the given channel, sending requests to the given exchange with the given routing key.

      Causes the creation of a temporary private autodelete queue. The name of this queue will be "amq.rabbitmq.reply-to".

      Parameters:
      channel - the channel to use for communication
      exchange - the exchange to connect to
      routingKey - the routing key
      timeout - milliseconds before timing out on wait for response
      Throws:
      IOException - if an error is encountered
  • Method Details