|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.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 | |
---|---|
ServiceDescription |
serviceDescription
Holds the JSON-RPC service description for this client. |
Constructor Summary | |
---|---|
JsonRpcClient(Channel channel,
java.lang.String exchange,
java.lang.String routingKey)
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. |
void |
retrieveServiceDescription()
Private API - invokes the "system.describe" method on the server, and parses and stores the resulting service description in this object. |
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 |
Field Detail |
---|
public ServiceDescription serviceDescription
Constructor Detail |
---|
public JsonRpcClient(Channel channel, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException, JsonRpcException
java.io.IOException
JsonRpcException
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
JsonRpcException
- if the reply object contained an exception
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
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.io.IOException
coerce(java.lang.String, java.lang.String)
public ServiceDescription getServiceDescription()
public void retrieveServiceDescription() throws java.io.IOException, JsonRpcException
java.io.IOException
JsonRpcException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |