Ok, I have the following problem:
Let's say we have two REST resources /objects and /notifications.
/notifications is a WebSocket resource provided by the Atmosphere framework.
Let's say a client POSTs to /objects to create a new resource.
Pseudocode
@Path("/objects")
class Objects {
@POST
public Response create() {
long rev = nextRevision();
SomeObject obj = new SomeObject(rev);
return Response.created(...).entity(obj).build();
}
}
nextRevision() increases the global revision number and fires an internal
event. The /notifications resource listens for the event and sends a
WebSocket message to all connected clients saying "Hey, I have a new object
resource with revision x".
The problem here is that the WebSocket notification is send before the
client received the response from the /objects POST request. So what I'd
like to do is put the code which fires the internal revision event at a
place where I'm certain that the client first received the POST response
from /objects.
2012/9/30 Martin Matula <martin.matula_at_oracle.com>
> Hi,
> Not at the moment. Can you provide more info on your use-case? Maybe a
> writer interceptor could be used if you are using Jersey 2.
> Martin
>
>
> On 9/29/12 12:23 PM, Sven Jacobs wrote:
>
>> I would like to perform some action *after* a successful REST response
>> has been send.
>> For example:
>>
>> @Path("/")
>> class Example {
>> @GET
>> public String example() {
>> return "Hello world"; // How to perform some action after the
>> response has been send?
>> }
>> }
>>
>> Is there some kind of event handler I can inject and add a listener or
>> something like that?
>>
>> Thanks
>>
>> Sven
>>
>
>