How to implement RPC Mechanism using RabbitMQ in java?

rabbitmq.com/api-guide.html#rpc If not you can download the source for the Java API which includes sample code here. rabbitmq.com/releases/rabbitmq-java-clie... There is an example folder in there - The code below is from java and java Server import com.rabbitmq.client. AMQP; import com.rabbitmq.client.

Channel; import com.rabbitmq.client. Connection; import com.rabbitmq.client. ConnectionFactory; import com.rabbitmq.client.

StringRpcServer; public class Server { public static void main(String args) { try { String hostName = (args. Length > 0)? Args0 : "localhost"; int portNumber = (args.

Length > 1)? Integer. ParseInt(args1) : AMQP.PROTOCOL.

PORT; ConnectionFactory connFactory = new ConnectionFactory(); connFactory. SetHost(hostName); connFactory. SetPort(portNumber); Connection conn = connFactory.newConnection(); final Channel ch = conn.createChannel(); ch.

QueueDeclare(" false, false, false, null); StringRpcServer server = new StringRpcServer(ch, "") { public String handleStringCall(String request) { System.out. Println("Got request: " + request); return " " + request + "! "; } }; server.mainloop(); } catch (Exception ex) { System.err.

Println("Main thread caught exception: " + ex); ex.printStackTrace(); System. Exit(1); } } } Client import com.rabbitmq.client. AMQP; import com.rabbitmq.client.

Channel; import com.rabbitmq.client. Connection; import com.rabbitmq.client. ConnectionFactory; import com.rabbitmq.client.

RpcClient; public class Client { public static void main(String args) { try { String request = (args. Length > 0)? Args0 : "Rabbit"; String hostName = (args.

Length > 1)? Args1 : "localhost"; int portNumber = (args. Length > 2)?Integer.

ParseInt(args2) : AMQP.PROTOCOL. PORT; ConnectionFactory cfconn = new ConnectionFactory(); cfconn. SetHost(hostName); cfconn.

SetPort(portNumber); Connection conn = cfconn.newConnection(); Channel ch = conn.createChannel(); RpcClient service = new RpcClient(ch, "", "out. Println(service. StringCall(request)); conn.close(); } catch (Exception e) { System.err.

Println("Main thread caught exception: " + e); e.printStackTrace(); System. Exit(1); } } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions