|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.rabbitmq.client.RpcClient com.rabbitmq.tools.jsonrpc.JsonRpcClient
public class JsonRpcClient
JSON-RPC is a lightweight
RPC mechanism using JSON
as a data language for request and reply messages. It is
rapidly becoming a standard in web development, where it is
used to make RPC requests over HTTP. RabbitMQ provides an
AMQP transport binding for JSON-RPC in the form of the
JsonRpcClient
class.
JSON-RPC services are self-describing - each service is able
to list its supported procedures, and each procedure
describes its parameters and types. An instance of
JsonRpcClient retrieves its service description using the
standard system.describe
procedure when it is
constructed, and uses the information to coerce parameter
types appropriately. A JSON service description is parsed
into instances of ServiceDescription
. Client
code can access the service description by reading the
serviceDescription
field of
JsonRpcClient
instances.
call(String, Object[])
,
call(String[])
Field Summary |
---|
Fields inherited from class com.rabbitmq.client.RpcClient |
---|
NO_TIMEOUT |
Constructor Summary | |
---|---|
JsonRpcClient(Channel channel,
java.lang.String exchange,
java.lang.String routingKey)
|
|
JsonRpcClient(Channel channel,
java.lang.String exchange,
java.lang.String routingKey,
int timeout)
Construct a new JsonRpcClient, passing the parameters through to RpcClient's constructor. |
Method Summary | |
---|---|
java.lang.Object |
call(java.lang.String[] args)
Public API - as call(String,Object[]) , but takes the
method name from the first entry in args , and the
parameters from subsequent entries. |
java.lang.Object |
call(java.lang.String method,
java.lang.Object[] params)
Public API - builds, encodes and sends a JSON-RPC request, and waits for the response. |
static java.lang.Object |
checkReply(java.util.Map<java.lang.String,java.lang.Object> reply)
Private API - parses a JSON-RPC reply object, checking it for exceptions. |
static java.lang.Object |
coerce(java.lang.String val,
java.lang.String type)
Private API - used by call(String[]) to ad-hoc convert
strings into the required data types for a call. |
java.lang.Object |
createProxy(java.lang.Class<?> klass)
Public API - gets a dynamic proxy for a particular interface class. |
ServiceDescription |
getServiceDescription()
Public API - gets the service description record that this service loaded from the server itself at construction time. |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Public API - implements InvocationHandler.invoke. |
Methods inherited from class com.rabbitmq.client.RpcClient |
---|
checkConsumer, close, getChannel, getConsumer, getContinuationMap, getCorrelationId, getExchange, getReplyQueue, getRoutingKey, mapCall, mapCall, primitiveCall, primitiveCall, publish, setupConsumer, setupReplyQueue, stringCall |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsonRpcClient(Channel channel, java.lang.String exchange, java.lang.String routingKey, int timeout) throws java.io.IOException, JsonRpcException, java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutException
- if a response is not received within the timeout specified, if any
java.io.IOException
JsonRpcException
public JsonRpcClient(Channel channel, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException, JsonRpcException, java.util.concurrent.TimeoutException
java.io.IOException
JsonRpcException
java.util.concurrent.TimeoutException
Method Detail |
---|
public static java.lang.Object checkReply(java.util.Map<java.lang.String,java.lang.Object> reply) throws JsonRpcException
JsonRpcException
public java.lang.Object call(java.lang.String method, java.lang.Object[] params) throws java.io.IOException, JsonRpcException, java.util.concurrent.TimeoutException
JsonRpcException
- if the reply object contained an exception
java.util.concurrent.TimeoutException
- if a response is not received within the timeout specified, if any
java.io.IOException
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Throwable
public java.lang.Object createProxy(java.lang.Class<?> klass) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.lang.Object coerce(java.lang.String val, java.lang.String type) throws java.lang.NumberFormatException
call(String[])
to ad-hoc convert
strings into the required data types for a call.
java.lang.NumberFormatException
public java.lang.Object call(java.lang.String[] args) throws java.lang.NumberFormatException, java.io.IOException, JsonRpcException, java.util.concurrent.TimeoutException
call(String,Object[])
, but takes the
method name from the first entry in args
, and the
parameters from subsequent entries. All parameter values are
passed through coerce() to attempt to make them the types the
server is expecting.
JsonRpcException
- if the reply object contained an exception
java.lang.NumberFormatException
- if a coercion failed
java.util.concurrent.TimeoutException
- if a response is not received within the timeout specified, if any
java.io.IOException
coerce(java.lang.String, java.lang.String)
public ServiceDescription getServiceDescription()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |