connFactory.setUri(uri);
Connection conn = connFactory.newConnection();
final Channel ch = conn.createChannel();
ch.queueDeclare("Hello", false, false, false, null);
JsonRpcServer server =
new JsonRpcServer(ch, "Hello", HelloJsonService.class,
new HelloJsonService() {
public String greeting(String name) {
return "Hello, "+name+", from JSON-RPC over AMQP!";
}
public int sum(java.util.List<Integer> args) {
int s = 0;
for (int i: args) { s += i; }
return s;
}
});
server.mainloop();
} catch (Exception ex) {
System.err.println("Main thread caught exception: " + ex);
ex.printStackTrace();
System.exit(1);
}