You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Adrian C <ad...@gmail.com> on 2008/12/05 14:30:07 UTC

jms client restart

Hi,

I have question about hows best to deal with a client application restarting
while waiting to receive a response.

Here's the scenario - a client application is invoking a synchronous web
services over JMS. If the client is restarted or crashed after a request has
been send to the broker how should the client pick up the message once the
client restarts?

Would is be possible to store the correlation id of the message once
dispatched & persist this. If the client restarts and there are outstanding
correlation ids then it must poll for these messages - however how would one
get CXF to process this message as the response to the original request?

I am sure this is an issue that others have faced or perhaps I am missing
something.

Thanks,

-- 
View this message in context: http://www.nabble.com/jms-client-restart-tp20853766p20853766.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: jms client restart

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Chris,

I think a kind of interceptor makes sense but I would not inject a jms 
listener. We could define a correlation interceptor that does two things:
- When sending out a message it stores the exchange and the correlation id
- When receiving a message it finds the correlated exchange and connects 
the incoming message to the exchange

This should allow you to write an interceptor that manages persistence 
of messages. Recently we added continuation support to the transports 
perhaps this could also be done with such an interceptor.
The aproach would then also allow to create an interceptor that simply 
does no correlation so you can receive all responses asynchronously.

Greetings

Christian

cxfuser17 schrieb:
> Adrian/Christian,
>
> I've been looking over the JMSConduit code.  I believe we could solve this
> issue if we allowed for developers to inject their own JMS listener into the
> conduit.  
>
> We have set up an interceptor to inject our own JMS correlation Id into the
> Message Object.  If we had a way to inject our own consumer to the conduit
> we could manage the persistence and correlation of request/response
> messages.
>
> Let me know what you think.
>
> Thanks!
>
> -Chris
>
>
>
> Christian Schneider wrote:
>   
>> Hi Adrian,
>>
>> I think this can be done in CXF. I was talking more about what you do in 
>> the application layer and how you design your service.
>> For example if your service call creates a customer object then you can 
>> simply return a generated customer id on success.
>> In this case you need the correlation id to make sense of the reply. If 
>> you instead return the complete Customer data you just set including the 
>> customer id that was created while doing
>> the call then you can probably process the reply without knowing the 
>> request that caused this reply. When doing loosely coupled asynchronous 
>> services it is very important to design like
>> in the second example.
>>
>> Greetings
>>
>> Christian
>>
>> Adrian Corcoran schrieb:
>>     
>>> Hi Christian,
>>>
>>> So when you say that you have to write the client in a really
>>> asynchronous
>>> way are you saying you don't really think that there is a way that this
>>> can
>>> be done using CXF?
>>>
>>> Thanks,
>>>  Adrian
>>>   
>>>       
>> -- 
>>
>> Christian Schneider
>> ---
>> http://www.liquid-reality.de
>>
>>
>>
>>     
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: jms client restart

Posted by cxfuser17 <mo...@gmail.com>.
Adrian/Christian,

I've been looking over the JMSConduit code.  I believe we could solve this
issue if we allowed for developers to inject their own JMS listener into the
conduit.  

We have set up an interceptor to inject our own JMS correlation Id into the
Message Object.  If we had a way to inject our own consumer to the conduit
we could manage the persistence and correlation of request/response
messages.

Let me know what you think.

Thanks!

-Chris



Christian Schneider wrote:
> 
> Hi Adrian,
> 
> I think this can be done in CXF. I was talking more about what you do in 
> the application layer and how you design your service.
> For example if your service call creates a customer object then you can 
> simply return a generated customer id on success.
> In this case you need the correlation id to make sense of the reply. If 
> you instead return the complete Customer data you just set including the 
> customer id that was created while doing
> the call then you can probably process the reply without knowing the 
> request that caused this reply. When doing loosely coupled asynchronous 
> services it is very important to design like
> in the second example.
> 
> Greetings
> 
> Christian
> 
> Adrian Corcoran schrieb:
>> Hi Christian,
>>
>> So when you say that you have to write the client in a really
>> asynchronous
>> way are you saying you don't really think that there is a way that this
>> can
>> be done using CXF?
>>
>> Thanks,
>>  Adrian
>>   
> 
> 
> -- 
> 
> Christian Schneider
> ---
> http://www.liquid-reality.de
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jms-client-restart-tp20853766p20917773.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: jms client restart

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Adrian,

I think this can be done in CXF. I was talking more about what you do in 
the application layer and how you design your service.
For example if your service call creates a customer object then you can 
simply return a generated customer id on success.
In this case you need the correlation id to make sense of the reply. If 
you instead return the complete Customer data you just set including the 
customer id that was created while doing
the call then you can probably process the reply without knowing the 
request that caused this reply. When doing loosely coupled asynchronous 
services it is very important to design like
in the second example.

Greetings

Christian

Adrian Corcoran schrieb:
> Hi Christian,
>
> So when you say that you have to write the client in a really asynchronous
> way are you saying you don't really think that there is a way that this can
> be done using CXF?
>
> Thanks,
>  Adrian
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: jms client restart

Posted by Adrian Corcoran <ad...@gmail.com>.
Hi Christian,

So when you say that you have to write the client in a really asynchronous
way are you saying you don't really think that there is a way that this can
be done using CXF?

Thanks,
 Adrian

On Sun, Dec 7, 2008 at 8:21 PM, Christian Schneider <chris@die-schneider.net
> wrote:

> Hi Adrian,
>
> the case with multiple clients on the same queue can even be a big
> advantage if you use it correctly. If a client A sends the request and you
> do not need any context to process the reply then client B can pick up from
> this point. I think in many cases this is not very difficult to achieve and
> it  gives you real fault tolerance and scalability on the client.
> When a context is needed the client can save it to a database before doing
> the request.
>
> I have already proposed a correlation handling that is independent from the
> transports. This could then also support persistence. The problem is though
> that the context a client needs to continue processing when a reply is
> received can be more than the CXF Exchange that can be retrieved with the
> correlation id. In any case it will not be possible to simply do an
> synchronous call if you want to be able to restart the client after the
> request has been sent. So I guess in most cases you simply have to write the
> client in a really asynchronous way and do correlation handling in the
> application layer.
>
> Greetings
>
> Christian
>
>
> Adrian Corcoran schrieb:
>
>> Hi Christian,
>>
>> Thanks for the reply! Yes this is along the lines of what I was thinking
>> that this could work - would be great this was in 2.1.4. But as you say
>> the
>> issue with this is if there are multiple clients feeding off the same
>> reply
>> queue.
>>
>> Would it also be possible to supply CXF with a list of outstanding
>> correlation ids to process on start-up? Is there a way that we can do this
>> in CXF at the moment?
>>
>> Perhaps even the implementation behind the storage of correlations ids
>> could
>> be abstracted out so that by default CXF would use in process correlation
>> id
>> store and if anyone wanted to get into persistence (XA transactions and
>> all
>> that fun) they could write their own implemenation?
>>
>> Any thoughts?
>>
>>
>> On Sat, Dec 6, 2008 at 9:08 AM, Christian Schneider <
>> chris@die-schneider.net
>>
>>
>>> wrote:
>>>
>>>
>>
>>
>>
>
>
> --
>
> Christian Schneider
> ---
> http://www.liquid-reality.de
>
>

Re: jms client restart

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Adrian,

the case with multiple clients on the same queue can even be a big 
advantage if you use it correctly. If a client A sends the request and 
you do not need any context to process the reply then client B can pick 
up from this point. I think in many cases this is not very difficult to 
achieve and it  gives you real fault tolerance and scalability on the 
client.
When a context is needed the client can save it to a database before 
doing the request.

I have already proposed a correlation handling that is independent from 
the transports. This could then also support persistence. The problem is 
though that the context a client needs to continue processing when a 
reply is received can be more than the CXF Exchange that can be 
retrieved with the correlation id. In any case it will not be possible 
to simply do an synchronous call if you want to be able to restart the 
client after the request has been sent. So I guess in most cases you 
simply have to write the client in a really asynchronous way and do 
correlation handling in the application layer.

Greetings

Christian


Adrian Corcoran schrieb:
> Hi Christian,
>
> Thanks for the reply! Yes this is along the lines of what I was thinking
> that this could work - would be great this was in 2.1.4. But as you say the
> issue with this is if there are multiple clients feeding off the same reply
> queue.
>
> Would it also be possible to supply CXF with a list of outstanding
> correlation ids to process on start-up? Is there a way that we can do this
> in CXF at the moment?
>
> Perhaps even the implementation behind the storage of correlations ids could
> be abstracted out so that by default CXF would use in process correlation id
> store and if anyone wanted to get into persistence (XA transactions and all
> that fun) they could write their own implemenation?
>
> Any thoughts?
>
>
> On Sat, Dec 6, 2008 at 9:08 AM, Christian Schneider <chris@die-schneider.net
>   
>> wrote:
>>     
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: jms client restart

Posted by Adrian Corcoran <ad...@gmail.com>.
Hi Christian,

Thanks for the reply! Yes this is along the lines of what I was thinking
that this could work - would be great this was in 2.1.4. But as you say the
issue with this is if there are multiple clients feeding off the same reply
queue.

Would it also be possible to supply CXF with a list of outstanding
correlation ids to process on start-up? Is there a way that we can do this
in CXF at the moment?

Perhaps even the implementation behind the storage of correlations ids could
be abstracted out so that by default CXF would use in process correlation id
store and if anyone wanted to get into persistence (XA transactions and all
that fun) they could write their own implemenation?

Any thoughts?


On Sat, Dec 6, 2008 at 9:08 AM, Christian Schneider <chris@die-schneider.net
> wrote:

> Hi Adrian,
>
> as far as I know it is not possible to continue a synchronous request after
> a client restart. I use synchronous calls only for read requests. In this
> case I set a timeout for the message so it gets discarded after some time.
>
> If you call a write operation it is perhaps best to do it completely
> asynchronous by using a one way service for the call to the operation. The
> reponse could then be sent to another one way service that listens on a
> topic. The client can then "offer" this service to listen for the response.
>
> Perhaps it is also possible to change cxf in a way to support this
> scenario. We had a similar case in the company I work for. We went with the
> solution above but it is quite complicated. Perhaps we can support the same
> level of security with some changes in CXF. Since some time CXF supports
> asynchronous calls to a request / reply service. If it really does not
> matter which instance of a client receives the response we could turn of the
> correlation id checking. So the scenario would look like this:
>
> - Client send a request with an asynch frontend and gives a permanent reply
> queue
> - Client goes down
> - Server replies on the reply queue. The reply message should have no
> timeout in this case
> - Client comes up again
> - Client receives the reply on the reply queue. Since correlation checking
> is turned off it processes the reply
> - The reply handler of the asnyc frontend is called with the reply
>
> What do you think?
>
> Greetings
>
> Christian
>
> Adrian C schrieb:
>
>> Hi,
>>
>> I have question about hows best to deal with a client application
>> restarting
>> while waiting to receive a response.
>>
>> Here's the scenario - a client application is invoking a synchronous web
>> services over JMS. If the client is restarted or crashed after a request
>> has
>> been send to the broker how should the client pick up the message once the
>> client restarts?
>>
>> Would is be possible to store the correlation id of the message once
>> dispatched & persist this. If the client restarts and there are
>> outstanding
>> correlation ids then it must poll for these messages - however how would
>> one
>> get CXF to process this message as the response to the original request?
>>
>> I am sure this is an issue that others have faced or perhaps I am missing
>> something.
>>
>> Thanks,
>>
>>
>>
>
>
> --
>
> Christian Schneider
> ---
> http://www.liquid-reality.de
>
>

Re: jms client restart

Posted by Christian Schneider <ch...@die-schneider.net>.
I have just checked the jms code. Currently we can not handle this but 
the change is perhaps quite easy.
Just added an issue to track this:
https://issues.apache.org/jira/browse/CXF-1933

Greetings

Christian

Christian Schneider schrieb:
> - Client send a request with an asynch frontend and gives a permanent 
> reply queue
> - Client goes down
> - Server replies on the reply queue. The reply message should have no 
> timeout in this case
> - Client comes up again
> - Client receives the reply on the reply queue. Since correlation 
> checking is turned off it processes the reply
> - The reply handler of the asnyc frontend is called with the reply
>

-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: jms client restart

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Adrian,

as far as I know it is not possible to continue a synchronous request 
after a client restart. I use synchronous calls only for read requests. 
In this case I set a timeout for the message so it gets discarded after 
some time.

If you call a write operation it is perhaps best to do it completely 
asynchronous by using a one way service for the call to the operation. 
The reponse could then be sent to another one way service that listens 
on a topic. The client can then "offer" this service to listen for the 
response.

Perhaps it is also possible to change cxf in a way to support this 
scenario. We had a similar case in the company I work for. We went with 
the solution above but it is quite complicated. Perhaps we can support 
the same level of security with some changes in CXF. Since some time CXF 
supports asynchronous calls to a request / reply service. If it really 
does not matter which instance of a client receives the response we 
could turn of the correlation id checking. So the scenario would look 
like this:

- Client send a request with an asynch frontend and gives a permanent 
reply queue
- Client goes down
- Server replies on the reply queue. The reply message should have no 
timeout in this case
- Client comes up again
- Client receives the reply on the reply queue. Since correlation 
checking is turned off it processes the reply
- The reply handler of the asnyc frontend is called with the reply

What do you think?

Greetings

Christian

Adrian C schrieb:
> Hi,
>
> I have question about hows best to deal with a client application restarting
> while waiting to receive a response.
>
> Here's the scenario - a client application is invoking a synchronous web
> services over JMS. If the client is restarted or crashed after a request has
> been send to the broker how should the client pick up the message once the
> client restarts?
>
> Would is be possible to store the correlation id of the message once
> dispatched & persist this. If the client restarts and there are outstanding
> correlation ids then it must poll for these messages - however how would one
> get CXF to process this message as the response to the original request?
>
> I am sure this is an issue that others have faced or perhaps I am missing
> something.
>
> Thanks,
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de