You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Gianfranco Boccalon <gi...@eng.it> on 2007/05/15 16:18:46 UTC

Listeners and concurrency problems

Hello all,
I'm not able to find documentation about the methods exchangeSent and 
exchangeAccepted in the interface ExchangeListener.
I suppose the difference is about WHEN the listener is notified of the 
exchange: before or after the exchange is sent to the endpoint, but I 
noticed that my listener doesn't work properly if I perform my logic in 
the exchangeAccepted instead of the exchangeSent.
The exchanges notified should be the same ?

Another problem is: I have a listener that in some cases is quite slow, 
so in some cases it's still working when it's invoked again for  
processing next messages, and for me this is a problem because the 
listener works properly only if it processes the messages in the right 
order.
I temporarily solved the problem creating a synchronized section in my 
listener, so all exchanges are managed sequentially, but I dont like 
this solution because I'm in trouble about performances.
The listeners are executed in the same thread of components ?
If yes, I suppose that a slow listener can affect the performances of 
the entire system, and a solution may be to enqueue the exchange and 
process it separately. Right ?

Thanks in advance

-- 
Gianfranco Boccalon
Engineering Ingegneria Informatica S.p.A.
Direzione Centrale Ricerca e Innovazione
Direzione Architetture e Consulenza
35127 PADOVA
Corso Stati Uniti 23/I
Tel. +39.049.8692508
Cell. 335.7813507
Fax +39.049.8692566
E-mail: gianfranco.boccalon@eng.it


Re: Listeners and concurrency problems

Posted by Guillaume Nodet <gn...@gmail.com>.
On 5/15/07, Gianfranco Boccalon <gi...@eng.it> wrote:
>
> Hello all,
> I'm not able to find documentation about the methods exchangeSent and
> exchangeAccepted in the interface ExchangeListener.
> I suppose the difference is about WHEN the listener is notified of the
> exchange: before or after the exchange is sent to the endpoint, but I
> noticed that my listener doesn't work properly if I perform my logic in
> the exchangeAccepted instead of the exchangeSent.
> The exchanges notified should be the same ?


I guess yes, though you should only rely on the exchange id, as there is
some
trick for the exchanges:  there are two instances that use the same
underlying data,
and each one is given to a component, so  that both component have an
exchange
containing the same data, but with a different view (for the role, checks,
etc ..)

Another problem is: I have a listener that in some cases is quite slow,
> so in some cases it's still working when it's invoked again for
> processing next messages, and for me this is a problem because the
> listener works properly only if it processes the messages in the right
> order.
> I temporarily solved the problem creating a synchronized section in my
> listener, so all exchanges are managed sequentially, but I dont like
> this solution because I'm in trouble about performances.
> The listeners are executed in the same thread of components ?
> If yes, I suppose that a slow listener can affect the performances of
> the entire system, and a solution may be to enqueue the exchange and
> process it separately. Right ?


Yes. Calls to listeners are made synchronously.
You will probably want to make a copy  (pay attention to the streams)
using the o.a.s.jbi.util.MessageUtil class and put those in a queue
(in memory, or maybe jms if the process may fill the memory).

Thanks in advance
>
> --
> Gianfranco Boccalon
> Engineering Ingegneria Informatica S.p.A.
> Direzione Centrale Ricerca e Innovazione
> Direzione Architetture e Consulenza
> 35127 PADOVA
> Corso Stati Uniti 23/I
> Tel. +39.049.8692508
> Cell. 335.7813507
> Fax +39.049.8692566
> E-mail: gianfranco.boccalon@eng.it
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/