public class RpcClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RpcClient.Response
The response object is an envelope that contains all of the data provided to the `handleDelivery` consumer
|
| Modifier and Type | Field and Description |
|---|---|
protected static int |
NO_TIMEOUT
NO_TIMEOUT value must match convention on
BlockingCell.uninterruptibleGet(int) |
| Constructor and Description |
|---|
RpcClient(Channel channel,
String exchange,
String routingKey)
Construct a new RpcClient that will communicate on the given channel, sending
requests to the given exchange with the given routing key.
|
RpcClient(Channel channel,
String exchange,
String routingKey,
int timeout)
Construct a new RpcClient that will communicate on the given channel, sending
requests to the given exchange with the given routing key.
|
RpcClient(Channel channel,
String exchange,
String routingKey,
String replyTo)
Construct a new RpcClient that will communicate on the given channel, sending
requests to the given exchange with the given routing key.
|
RpcClient(Channel channel,
String exchange,
String routingKey,
String replyTo,
int timeout)
Construct a new RpcClient that will communicate on the given channel, sending
requests to the given exchange with the given routing key.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkConsumer()
Private API - ensures the RpcClient is correctly open.
|
void |
close()
Public API - cancels the consumer, thus deleting the temporary queue, and marks the RpcClient as closed.
|
RpcClient.Response |
doCall(AMQP.BasicProperties props,
byte[] message) |
Channel |
getChannel()
Retrieve the channel.
|
Consumer |
getConsumer()
Retrieve the consumer.
|
Map<String,BlockingCell<Object>> |
getContinuationMap()
Retrieve the continuation map.
|
int |
getCorrelationId()
Retrieve the correlation id.
|
String |
getExchange()
Retrieve the exchange.
|
String |
getRoutingKey()
Retrieve the routing key.
|
Map<String,Object> |
mapCall(Map<String,Object> message)
Perform an AMQP wire-protocol-table based RPC roundtrip
There are some restrictions on the values appearing in the table: they must be of type String, LongString, Integer, BigDecimal, Date,
or (recursively) a Map of the enclosing type. |
Map<String,Object> |
mapCall(Object[] keyValuePairs)
Perform an AMQP wire-protocol-table based RPC roundtrip, first
constructing the table from an array of alternating keys (in
even-numbered elements, starting at zero) and values (in
odd-numbered elements, starting at one)
Restrictions on value arguments apply as in mapCall(Map). |
byte[] |
primitiveCall(AMQP.BasicProperties props,
byte[] message) |
byte[] |
primitiveCall(byte[] message)
Perform a simple byte-array-based RPC roundtrip.
|
void |
publish(AMQP.BasicProperties props,
byte[] message) |
RpcClient.Response |
responseCall(byte[] message)
Perform a simple byte-array-based RPC roundtrip
Useful if you need to get at more than just the body of the message
|
protected DefaultConsumer |
setupConsumer()
Registers a consumer on the reply queue.
|
String |
stringCall(String message)
Perform a simple string-based RPC roundtrip.
|
protected static final int NO_TIMEOUT
BlockingCell.uninterruptibleGet(int)public RpcClient(Channel channel, String exchange, String routingKey, String replyTo, int timeout) throws IOException
channel - the channel to use for communicationexchange - the exchange to connect toroutingKey - the routing keyreplyTo - the queue where the server should put the replytimeout - milliseconds before timing out on wait for responseIOException - if an error is encounteredpublic RpcClient(Channel channel, String exchange, String routingKey, String replyTo) throws IOException
channel - the channel to use for communicationexchange - the exchange to connect toroutingKey - the routing keyreplyTo - the queue where the server should put the replyIOException - if an error is encounteredpublic RpcClient(Channel channel, String exchange, String routingKey) throws IOException
channel - the channel to use for communicationexchange - the exchange to connect toroutingKey - the routing keyIOException - if an error is encounteredpublic 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".channel - the channel to use for communicationexchange - the exchange to connect toroutingKey - the routing keytimeout - milliseconds before timing out on wait for responseIOException - if an error is encounteredpublic void checkConsumer()
throws IOException
IOException - if an error is encounteredpublic void close()
throws IOException
IOException - if an error is encounteredprotected DefaultConsumer setupConsumer() throws IOException
IOException - if an error is encounteredpublic void publish(AMQP.BasicProperties props, byte[] message) throws IOException
IOExceptionpublic RpcClient.Response doCall(AMQP.BasicProperties props, byte[] message) throws IOException, ShutdownSignalException, TimeoutException
public byte[] primitiveCall(AMQP.BasicProperties props, byte[] message) throws IOException, ShutdownSignalException, TimeoutException
public byte[] primitiveCall(byte[] message)
throws IOException,
ShutdownSignalException,
TimeoutException
message - the byte array request message to sendShutdownSignalException - if the connection dies during our waitIOException - if an error is encounteredTimeoutException - if a response is not received within the configured timeoutpublic RpcClient.Response responseCall(byte[] message) throws IOException, ShutdownSignalException, TimeoutException
message - the byte array request message to sendShutdownSignalException - if the connection dies during our waitIOException - if an error is encounteredTimeoutException - if a response is not received within the configured timeoutpublic String stringCall(String message) throws IOException, ShutdownSignalException, TimeoutException
message - the string request message to sendShutdownSignalException - if the connection dies during our waitIOException - if an error is encounteredTimeoutException - if a timeout occurs before the response is receivedpublic Map<String,Object> mapCall(Map<String,Object> message) throws IOException, ShutdownSignalException, TimeoutException
String, LongString, Integer, BigDecimal, Date,
or (recursively) a Map of the enclosing type.message - the table to sendShutdownSignalException - if the connection dies during our waitIOException - if an error is encounteredTimeoutException - if a timeout occurs before a response is receivedpublic Map<String,Object> mapCall(Object[] keyValuePairs) throws IOException, ShutdownSignalException, TimeoutException
mapCall(Map).keyValuePairs - alternating {key, value, key, value, ...} data to sendShutdownSignalException - if the connection dies during our waitIOException - if an error is encounteredTimeoutException - if a timeout occurs before a response is receivedpublic Channel getChannel()
public String getExchange()
public String getRoutingKey()
public Map<String,BlockingCell<Object>> getContinuationMap()
public int getCorrelationId()
public Consumer getConsumer()
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.