You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by M314 <ma...@gmail.com> on 2013/10/30 12:48:47 UTC
Apache Camel and Synchronized methods in processor
In my routing messages pass myBean twice. Once I have:
... //some code
.process(myBean)
... //some code
.method("myBean", "myMethod")
... //some code
This bean have to be synchronized. I whould like just to add key word:
'synchronized' to methods: 'myMethod' and 'process', but those mehods are
invoked by framewok itself (Camel), so I'm a bit afraid if I can do that
without any consequences. I do not know how exaclly Camel works. So can I
add to those methods word 'synchronized', and what problems can I come
across?
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-and-Synchronized-methods-in-processor-tp5742401.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Camel and Synchronized methods in processor
Posted by Christian Posta <ch...@gmail.com>.
If multiple threads are accessing your beans, then yes, your beans
have to be thread-safe.
On Thu, Oct 31, 2013 at 7:00 AM, M314 <ma...@gmail.com> wrote:
> In general my routing is quite complicated. Do it realy matter how exacly it
> looks like?
>
> Numbers of used threads areset by property one 'concurrentConsumers' for
> JmsConfiguration.
>
> MyBean distribute jobs between chlid applications (balance load of child
> applications) - with dynamic routing. After child application have finished
> jobs, or broke etc - those events are reported to myBean.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-and-Synchronized-methods-in-processor-tp5742401p5742454.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta
Re: Apache Camel and Synchronized methods in processor
Posted by M314 <ma...@gmail.com>.
In general my routing is quite complicated. Do it realy matter how exacly it
looks like?
Numbers of used threads areset by property one 'concurrentConsumers' for
JmsConfiguration.
MyBean distribute jobs between chlid applications (balance load of child
applications) - with dynamic routing. After child application have finished
jobs, or broke etc - those events are reported to myBean.
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-and-Synchronized-methods-in-processor-tp5742401p5742454.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Camel and Synchronized methods in processor
Posted by Christian Posta <ch...@gmail.com>.
if you have multiple threads running the route (maybe show the full route,
and explain how it gets invoked) and you're sharing state in your beans,
then you'll probably want some kind of locking/mutex. adding a synchronized
keyword to the java method could help. maybe you could explain a little
more about the myMethod/myBean and what it does/looks like?
On Wed, Oct 30, 2013 at 4:48 AM, M314 <ma...@gmail.com> wrote:
> In my routing messages pass myBean twice. Once I have:
>
> ... //some code
> .process(myBean)
> ... //some code
> .method("myBean", "myMethod")
> ... //some code
>
> This bean have to be synchronized. I whould like just to add key word:
> 'synchronized' to methods: 'myMethod' and 'process', but those mehods are
> invoked by framewok itself (Camel), so I'm a bit afraid if I can do that
> without any consequences. I do not know how exaclly Camel works. So can I
> add to those methods word 'synchronized', and what problems can I come
> across?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-and-Synchronized-methods-in-processor-tp5742401.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta