You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cwash <ch...@gmail.com> on 2012/08/06 03:09:35 UTC

Any example of JAX-RS frontend async consumers?

I would love to avoid having to write and publish my own code that helps
clients consume my JAX-RS service in an async manner via callback or polling
(similar to the JAX-WS AsyncHandler).

In my purusual of the docs and Google I didn't find anything related to
doing this for a JAX-WS service.

I know I can use Camel to achieve this, but I was wondering if has someone
solved this before?  Is it a feature of CXF and I just missed it?

Thanks



--
View this message in context: http://cxf.547215.n5.nabble.com/Any-example-of-JAX-RS-frontend-async-consumers-tp5712070.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Any example of JAX-RS frontend async consumers?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 09/08/12 09:08, Sergey Beryozkin wrote:
> Hi
> On 07/08/12 21:36, Christopher Wash wrote:
>> Thanks for your quick reply, Sergey.
>>
>> If the code for this exists, I may try to model my solution off of it and
>> then switch to utilize CXF once available. Could you point me in the
>> direction of the APIs that support this?
>>
> The only thing I can say at the moment is that I will do something
> similar to what Dan did with the JAX-WS frontend.

Dan helped me with linking a new asynchronous HTTP conduit with the 
client runtime which has been retrofitted to support all the new JAX-RS 
2.0 client enhancements (filters, interceptors, new Response API and new 
exception classes, and async, except for the actual new client API - 
that will be supported later).

The way to do asynchronous invocations with WebClient:

Option 1: use JAX-RS 2.0 AsyncInvoker
http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/client/AsyncInvoker.html

Example:

Future<Book> future = webClient.async().get(Book.class);
Future<Book> future = webClient.async().post(Entity.xml(new Book()), 
Book.class, new MyInvocationCallback<Book>());

Option2. Use 'shortcuts' on WebClient:

Future<Book> future = webClient.get(Book.class, new 
MyInvocationCallback<Book>());

Future<Book> future = webClient.post(new Book(), Book.class, new 
MyInvocationCallback<Book>());


It is available only in CXF 2.7.0 (to be released soon)

Cheers, Sergey

Re: Any example of JAX-RS frontend async consumers?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 07/08/12 21:36, Christopher Wash wrote:
> Thanks for your quick reply, Sergey.
>
> If the code for this exists, I may try to model my solution off of it and
> then switch to utilize CXF once available.  Could you point me in the
> direction of the APIs that support this?
>
The only thing I can say at the moment is that I will do something 
similar to what Dan did with the JAX-WS frontend.

Cheers, Sergey

Re: Any example of JAX-RS frontend async consumers?

Posted by Christopher Wash <ch...@gmail.com>.
Thanks for your quick reply, Sergey.

If the code for this exists, I may try to model my solution off of it and
then switch to utilize CXF once available.  Could you point me in the
direction of the APIs that support this?

Re: Any example of JAX-RS frontend async consumers?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 06/08/12 04:09, cwash wrote:
> I would love to avoid having to write and publish my own code that helps
> clients consume my JAX-RS service in an async manner via callback or polling
> (similar to the JAX-WS AsyncHandler).
Thanks for confirming that it is indeed possible, requires more work but 
is possible
>
> In my purusual of the docs and Google I didn't find anything related to
> doing this for a JAX-WS service.
>
> I know I can use Camel to achieve this, but I was wondering if has someone
> solved this before?  Is it a feature of CXF and I just missed it?

I've started the process of upgrading the CXF trunk to the latest 
available JAX-RS 2.0 API and this feature will eventually be provided 
but not in 2.7.0.
However, while this feature will definitely be provided as part of this 
upgrade process, I will likely get it done with CXF-specific WebClient 
API first; so this feature will be in.

Cheers, Sergey

>
> Thanks
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Any-example-of-JAX-RS-frontend-async-consumers-tp5712070.html
> Sent from the cxf-user mailing list archive at Nabble.com.