akka-camel: support for using an external camel context (defined in spring xml)

343 views
Skip to first unread message

Thibaut Robert

unread,
Feb 12, 2014, 10:56:54 AM2/12/14
to akka...@googlegroups.com
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

Nothing really satisfying to me. Any other idea or guidance is welcomed :)

Context: I have an existing application written with camel with many routes defined using the spring dsl.
We are migrating part of this application to akka, replacing camel processors with akka actors.

Regards,
Thibaut

√iktor Ҡlang

unread,
Feb 12, 2014, 11:08:59 AM2/12/14
to Akka User List
On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.
 

Nothing really satisfying to me. Any other idea or guidance is welcomed :)

Context: I have an existing application written with camel with many routes defined using the spring dsl.
We are migrating part of this application to akka, replacing camel processors with akka actors.

Regards,
Thibaut

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.



--
Cheers,

———————
Viktor Klang
Chief Architect - Typesafe

Twitter: @viktorklang

Raymond Roestenburg

unread,
Feb 12, 2014, 11:57:35 AM2/12/14
to akka...@googlegroups.com
On Wed, Feb 12, 2014 at 5:08 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:



On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.

+1
Strange that setting the Registry on the CamelContext does not work, have you verified this yourself that it does not work? 



--
Raymond Roestenburg

Thibaut Robert

unread,
Feb 12, 2014, 12:58:53 PM2/12/14
to akka...@googlegroups.com


On Wednesday, February 12, 2014 5:57:35 PM UTC+1, Raymond Roestenburg wrote:

On Wed, Feb 12, 2014 at 5:08 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:



On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.

+1
Strange that setting the Registry on the CamelContext does not work, have you verified this yourself that it does not work? 

Setting the registry is not enough. It does not allow to define routes in xml, unless I missed something.
I'll have a deeper look tomorrow, maybe we can take the route definition from spring (inside a routeContext tag) and apply them to the akka camel context.

Alvaro Rodriguez

unread,
Feb 12, 2014, 8:00:12 PM2/12/14
to akka...@googlegroups.com
Hey Robert,
I need this too.
I think it's probably the root cause of this http://stackoverflow.com/questions/16923467/how-to-get-spring-to-wire-my-jmscomponent which has bugged me for some time now.
If you'd like, email me and maybe I can help you code and/or test a solution.
Regards
Alvaro

Thibaut Robert

unread,
Feb 13, 2014, 5:03:38 AM2/13/14
to akka...@googlegroups.com


On Wednesday, February 12, 2014 6:58:53 PM UTC+1, Thibaut Robert wrote:


On Wednesday, February 12, 2014 5:57:35 PM UTC+1, Raymond Roestenburg wrote:

On Wed, Feb 12, 2014 at 5:08 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:



On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.

+1
Strange that setting the Registry on the CamelContext does not work, have you verified this yourself that it does not work? 

Setting the registry is not enough. It does not allow to define routes in xml, unless I missed something.
I'll have a deeper look tomorrow, maybe we can take the route definition from spring (inside a routeContext tag) and apply them to the akka camel context.
I looked at this. This seems to me to be a wrong approach. xml-defined routes are supposed to be used with an xml-defined context.
So I give a try to allow context injection in akka.

Raymond Roestenburg

unread,
Feb 13, 2014, 5:47:05 AM2/13/14
to akka...@googlegroups.com
On Thu, Feb 13, 2014 at 11:03 AM, Thibaut Robert <thibaut...@gmail.com> wrote:


On Wednesday, February 12, 2014 6:58:53 PM UTC+1, Thibaut Robert wrote:


On Wednesday, February 12, 2014 5:57:35 PM UTC+1, Raymond Roestenburg wrote:

On Wed, Feb 12, 2014 at 5:08 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:



On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.

+1
Strange that setting the Registry on the CamelContext does not work, have you verified this yourself that it does not work? 

Setting the registry is not enough. It does not allow to define routes in xml, unless I missed something.
I'll have a deeper look tomorrow, maybe we can take the route definition from spring (inside a routeContext tag) and apply them to the akka camel context.
I looked at this. This seems to me to be a wrong approach. xml-defined routes are supposed to be used with an xml-defined context.
So I give a try to allow context injection in akka.

Cool, looking forward to it.

Thibaut Robert

unread,
Feb 14, 2014, 9:32:39 AM2/14/14
to akka...@googlegroups.com
On Thursday, February 13, 2014 11:47:05 AM UTC+1, Raymond Roestenburg wrote:



On Thu, Feb 13, 2014 at 11:03 AM, Thibaut Robert <thibaut...@gmail.com> wrote:


On Wednesday, February 12, 2014 6:58:53 PM UTC+1, Thibaut Robert wrote:


On Wednesday, February 12, 2014 5:57:35 PM UTC+1, Raymond Roestenburg wrote:

On Wed, Feb 12, 2014 at 5:08 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:



On Wed, Feb 12, 2014 at 4:56 PM, Thibaut Robert <thibaut...@gmail.com> wrote:
Hi,

I'd like to use akka-camel with my own camel context rather than using the private one defined in the CamelExtension (to reuse routes defined in spring xml)
As discussed in this thread: https://groups.google.com/d/topic/akka-user/ZvF6zQqrCvo/discussion, the camel context is not injectable in the extension.

I would be happy to propose a pull-request. However I need some help on how to pass the context to the extension. At the moment I'm thinking at:
- adding a public useContext(ctx) method on the CamelExtension object, making it mutable, not very clean. 

 
- using a config option to define a classname, that will be dynamically loaded to find the context: seems too complicated.

I'd go for that, it is how everything else works in Akka.

+1
Strange that setting the Registry on the CamelContext does not work, have you verified this yourself that it does not work? 

Setting the registry is not enough. It does not allow to define routes in xml, unless I missed something.
I'll have a deeper look tomorrow, maybe we can take the route definition from spring (inside a routeContext tag) and apply them to the akka camel context.
I looked at this. This seems to me to be a wrong approach. xml-defined routes are supposed to be used with an xml-defined context.
So I give a try to allow context injection in akka.

Cool, looking forward to it.

Hi. Just sent a PR !

Matteo Cusmai

unread,
Feb 21, 2014, 1:04:19 PM2/21/14
to akka...@googlegroups.com
I had the same needed and I have applied a workaround.

I have 2 different camel contexts, the former is a spring camel context with all my camel routes, they use vm component as producer endpoint.
The latter is the akka camel context that hosts my actors consumers endpoint that consume from vm components.
It works good enough, but It is only a workaround.

Thibaut Robert

unread,
Feb 23, 2014, 8:50:55 AM2/23/14
to akka...@googlegroups.com
I used the same work around. With the change I propose, that will hopefully be included in 2.3.1, you should get rid of it. Don't hesitate to have a look and share your view on my proposal.

Thibaut Robert

unread,
Feb 23, 2014, 8:51:18 AM2/23/14
to akka...@googlegroups.com

Matteo Cusmai

unread,
Feb 23, 2014, 9:12:49 AM2/23/14
to akka...@googlegroups.com
Can I see more about your proposal?
Please share the pr.

Konrad Malawski

unread,
Feb 23, 2014, 10:28:45 AM2/23/14
to akka...@googlegroups.com
@Matteo PR’s are public => https://github.com/akka/akka/pull/2014 :-)

-- 
Konrad

On Sunday, 23 February 2014 at 14:12, Matteo Cusmai wrote:

Can I see more about your proposal?
Please share the pr.

Matteo Cusmai

unread,
Feb 23, 2014, 11:46:58 AM2/23/14
to akka...@googlegroups.com
Thanks a lot Konrad,
I didn't know it, I am newbie on akka.


Matteo Cusmai


You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/TrAmYLrTFKo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.

mtsui

unread,
Mar 3, 2014, 9:53:10 AM3/3/14
to akka...@googlegroups.com
Hi,

Is there any documentation or examples out there to get this to work with the snapshot? I'm very interested in using akka with an external spring camel context.

Thanks,
mtsui

Björn Antonsson

unread,
Mar 4, 2014, 11:30:57 AM3/4/14
to akka...@googlegroups.com
Hi mtsui,

There is a test and documentation added in the pull request. It is not yet merged to master, so it isn’t available in the snapshots yet.

B/

On 3 March 2014 at 16:06:20, mtsui (kawai...@gmail.com) wrote:

Hi,

Is there any documentation or examples out there to get this to work with the snapshot? I'm very interested in using akka with an external spring camel context.

Thanks,
mtsui

On Sunday, February 23, 2014 10:28:45 AM UTC-5, Konrad Malawski wrote:
@Matteo PR’s are public => https://github.com/akka/akka/pull/2014 :-)

-- 
Konrad

On Sunday, 23 February 2014 at 14:12, Matteo Cusmai wrote:

Can I see more about your proposal?
Please share the pr.


-- 
Björn Antonsson
Typesafe – Reactive Apps on the JVM
twitter: @bantonsson

Guillermo

unread,
Jun 25, 2014, 11:01:14 AM6/25/14
to akka...@googlegroups.com
Hi,

So, Is there any documentation or examples out there to get this to work with the current version (2.3.3)?

Thanks.

Guillermo

unread,
Jun 26, 2014, 7:32:48 AM6/26/14
to akka...@googlegroups.com
Ok, I found it!

"By Default, a new CamelContext is created when the CamelExtension starts. If you want to inject your own context instead, you can extend the ContextProvider trait and add the FQCN of your implementation in the config, as the value of the "akka.camel.context-provider". This interface define a single method getContext used to load the CamelContext."

Thanks.


Reply all
Reply to author
Forward
0 new messages