sshyh / play2javarabbitmq Goto Github PK
View Code? Open in Web Editor NEWThis project forked from chanan/play2javarabbitmq
Play 2 Java connection to RabbitMQ
This project forked from chanan/play2javarabbitmq
Play 2 Java connection to RabbitMQ
This application is a Java implementation of the following blog post: http://www.javacodegeeks.com/2012/04/connect-to-rabbitmq-amqp-using-scala.html with some correction to the technique here: http://blog.hasbeco.me/post/35586367370/akka-amqp-play-and-scala-a-follow-up Update: ------- Add to this demo RPC call over Rabbit MQ. I modified the JsonRpcServer & JsonRpcClient to do two things: 1. Changed JsonRpcServer to use DefaultConsumer instead of QueueingConsumer so as not to block the thread. 2. Changed both JsonRpcServer & JsonRpcClient to handle complex types instead of just primitves (and strings). How To Use: ----------- 1. One way messaging: a. Create an untyped actor (in this demo: CommandActor) b. Connect a Channel & Queue to the Actor: channel.basicConsume(RabbitConfig.getRabbitQueue(), false, "event_filter", new CommandConsumer(channel, actor)); (in Sender class in this demo) c. Publish messages to the queue as usual. 2. RPC a. On the server create a service that will be typed actor (in this demo: remote.RemoteCalcultor, remote.RemoteCalculatorImpl). b. Create the typed actor: RemoteCalculator calculatorkActor =TypedActor.get(Akka.system()).typedActorOf(new TypedProps<RemoteCalculatorImpl>(RemoteCalculator.class, RemoteCalculatorImpl.class)); (in infrastucture.Sender) c. Create the JsonRpcServer: calculator = new JsonRpcServer(channel, RabbitConfig.getRabbitRpcQueue(), RemoteCalculator.class, calculatorkActor); (note: Use the JsonRpcServer in the infrastructure and not the one that comes with RabbitMQ driver) d. Start the RpcServer: calculator.start(); e. On the client create a JsonRpcClient: JsonRpcClient client = new JsonRpcClient(channel, "", RabbitConfig.getRabbitRpcQueue()); (in services.CalculatorFactory) (again note: Use the class from infrastructure not RabbitMQ driver). f. Call the remote service: calculator.add(1, 2); (in controllers.Application) Future: ------- This should really be made into a Play 2 Module...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.