On 05/26/2010 01:01 PM, Emmanuel Bourg wrote:
Hi,
I've done some request/response work with Qpid lately, and I implemented
a Hessian layer to make it easier. I'd like to share it here if ever
someone find it useful.
Thanks for sharing, this is interesting! It's a lot like what the WCF
service layer provides (and to some extent what part of QMF tries to do).
The source code is available there:
http://github.com/ebourg/qpid-hessian
That is for java only, but presumably other language bindings could be
written as well, right? Is the data format for messages fixed or can
that be varied as well (providing it meets the expected criteria)?
Any thoughts on hessian v. thrift (I admit, perhaps a little off topic
for this list, but I am curious!)?
Though this is clearly at a higher layer then Qpid in general it does
seem like it could be useful. Perhaps at some point providing examples
(or links to examples) of the RPC/service pattern on top of messaging
from different languages would be a nice addition to the website.
If you've already worked with Hessian to do RPC over HTTP the principle
is almost identical:
1. Create an interface defining the methods exposed:
public interface EchoService {
String echo(String message);
}
2. Implement the interface and extend the HessianEndpoint class
(this is the equivalent of the HessianServlet):
public class EchoServiceEndpoint extends HessianEndpoint
implements EchoService {
public String echo(String message) {
return message;
}
}
3. Deploy the endpoint by attaching it to a Qpid session:
EchoServiceEndpoint endpoint = new EchoServiceEndpoint();
endpoint.run(session);
4. On the client side, create a proxy of the interface:
AMQPHessianProxyFactory factory = new AMQPHessianProxyFactory();
EchoService service = factory.create(EchoService.class,
"qpid://guest:gu...@localhost/test");
5. The service is ready to be consumed!
String echo = service.echo("Hello Qpid!");
Emmanuel Bourg
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]