You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Emmanuel Bourg <eb...@apache.org> on 2010/05/26 14:01:11 UTC

RPC over AMQP with Hessian

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. The source code is available there:

http://github.com/ebourg/qpid-hessian


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:guest@localhost/test");


5. The service is ready to be consumed!

     String echo = service.echo("Hello Qpid!");



Emmanuel Bourg


Re: RPC over AMQP with Hessian

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 27/05/2010 10:19, Gordon Sim a écrit :

> 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!)?

My layer is Java centric but it's possible to rewrite the client part in 
another language (there are Hessian implementations for C, C#, Ruby, 
Python and more). The message format is not Java specific [1].

I haven't tried Thrift yet. It's probably easier to use if cross 
language interoperability is an important requirement. But in a Java 
only scenario I prefer the simplicity of Hessian (no IDL). On the 
performance side Thrift seems to have an advantage [2].


Emmanuel Bourg

[1] http://hessian.caucho.com/doc/hessian-ws.html
[2] http://wiki.github.com/eishay/jvm-serializers/


Re: RPC over AMQP with Hessian

Posted by Gordon Sim <gs...@redhat.com>.
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:guest@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:users-subscribe@qpid.apache.org


Re: RPC over AMQP with Hessian

Posted by Gordon Sim <gs...@redhat.com>.
On 05/06/2011 11:01 AM, Emmanuel Bourg wrote:
> Hi,
>
> Thanks to the availability of the Maven artifacts with the 0.10 release
> I've been able to finalize the library to do Hessian remote procedure
> calls over AMQP. A documentation is available with complete code
> examples on Github:
>
> http://ebourg.github.com/qpid-hessian

Cool! We should have a link to things like this from the qpid page 
(assuming authors of linked to projects are ok with that of course!).

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: RPC over AMQP with Hessian

Posted by Emmanuel Bourg <eb...@apache.org>.
Hi,

Thanks to the availability of the Maven artifacts with the 0.10 release 
I've been able to finalize the library to do Hessian remote procedure 
calls over AMQP. A documentation is available with complete code 
examples on Github:

http://ebourg.github.com/qpid-hessian

The library is also available through Maven.

   <dependency>
     <groupId>org.apache-extras.qpid</groupId>
     <artifactId>qpid-hessian</artifactId>
     <version>1.0</version>
   </dependency>

Emmanuel Bourg


Le 26/05/2010 14:01, Emmanuel Bourg a écrit :
> 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. The source code is available there:
>
> http://github.com/ebourg/qpid-hessian
>
>
> 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:guest@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:users-subscribe@qpid.apache.org