You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Justin Rosenberg <Ju...@crlcorp.com> on 2014/12/08 22:54:07 UTC

Spring Camel "Parent" Context

I have many (over 100) projects that all include a core Spring project where ActiveMQ is configured.  Currently each project defines its own camel context as such:

	<camel:camelContext id="CamelContext-${project.artifactId}_${project.version}">
		<camel:contextScan/>
	</camel:camelContext>

I would like to change some parameters in the way the camel context is defined.  I could simply put the context in the common project, however the ID would not match the ID of the sub-project.  Therefore I would like to do something like the following:

In the common project:

	<camel:camelContext id="AbstractCamelContext" allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks" abstract="true">
		<camel:contextScan/>
	</camel:camelContext>

In each individual project

	<camel:camelContext id="CamelContext-${project.artifactId}_${project.version}" parent="AbstractCamelContext "/>

Since "camel:camelContext" is just short-hand for Spring Configuration.  Could someone help me understand what the traditional Spring equivalent would be for:

	<camel:camelContext id="AbstractCamelContext" allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks">
		<camel:contextScan/>
	</camel:camelContext>

Thank you,

Justin

CONFIDENTIALITY NOTICE:
The information in this message, and any attachment, is intended for the 
sole use of the individual and entity to whom it is addressed. This 
information may be privileged, confidential, and protected from 
disclosure. If you are not the intended recipient you are hereby notified 
that you have received this communication in error and that any review, 
disclosure, dissemination, distribution or copying of it, or its contents, 
is strictly prohibited. If you think that you have received this message 
in error please notify the sender and destroy all copies of this 
communication and any attachments. Thank you.

Re: FW: Spring Camel "Parent" Context

Posted by JustinCRL <Ju...@crlcorp.com>.
Looks like a JIRA had already been created.  Claus wasn't a big fan of the
change.

https://issues.apache.org/jira/browse/CAMEL-5858

I might try to create a patch and see if there will still be resistance.  I
can't imagine I'm the only one with a use case of centralized CamelContext
configuration, but wanting to customize on a per actual context
implementation.  Specifically setting unique ID's can help with logging and
JMX management.



--
View this message in context: http://camel.465427.n5.nabble.com/Spring-Camel-Parent-Context-tp5760366p5760715.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FW: Spring Camel "Parent" Context

Posted by Willem Jiang <wi...@gmail.com>.
I think the magic is happened in side of camel spring post processor which inject the camel context to CamelContextAware interface. If you use CamelContextFactoryBean directly, it won’t setup the post processor for you out of box.

Please feel free to fill a JIRA for adding support of parent and abstraction. 

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On December 9, 2014 at 9:35:49 AM, JustinCRL (justin.rosenberg@crlcorp.com) wrote:
> I got farther with this.
>  
> > class="org.apache.camel.spring.CamelContextFactoryBean">
>  
>  
>  
>  
>  
>  
>  
> .*
>  
>  
>  
>  
>  
>  
> However, my org.apache.camel.spring.SpringRouteBuilder is
> org.apache.camel.CamelContextAware and the context is not being set on it.
> There is obviously a bit of *magic* involved in getting  
> to work. I will either have to live with copying the configuration for all
> of my projects, or have a single configuration with a single name. I might
> put in a feature request to support "abstract" and "parent" references. If
> I do, I'll add the link to the JIRA here.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760347.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  


Re: FW: Spring Camel "Parent" Context

Posted by JustinCRL <Ju...@crlcorp.com>.
I got farther with this.

	<bean id="MyCamelContext"
class="org.apache.camel.spring.CamelContextFactoryBean">
		<property name="id" value="MyCamelContext" />
		<property name="allowUseOriginalMessage" value="false" />
		<property name="shutdownRunningTask" value="CompleteAllTasks" />
		<property name="contextScan">
			<bean class="org.apache.camel.model.ContextScanDefinition">
				<property name="includes">
					<list>
						<value>.*</value>
					</list>
				</property>
			</bean>
		</property>
	</bean>

However, my org.apache.camel.spring.SpringRouteBuilder is
org.apache.camel.CamelContextAware and the context is not being set on it. 
There is obviously a bit of *magic* involved in getting <camel:camelContext>
to work.  I will either have to live with copying the configuration for all
of my projects, or have a single configuration with a single name.  I might
put in a feature request to support "abstract" and "parent" references.  If
I do, I'll add the link to the JIRA here.



--
View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760347.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FW: Spring Camel "Parent" Context

Posted by JustinCRL <Ju...@crlcorp.com>.
There is a spring.handlers file in META-INF that references
org.apache.camel.spring.handler.CamelNamespaceHandler.  This is the link
between the Spring Tag and the construction on the implementation classes. 
However, I'm still missing a step in the definition that will cause the
Context to start when Spring Context loads.



--
View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760346.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FW: Spring Camel "Parent" Context

Posted by JustinCRL <Ju...@crlcorp.com>.
Actually the context didn't start.  I'll update here once I figure it out. 
In the meantime, any help is appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760345.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FW: Spring Camel "Parent" Context

Posted by JustinCRL <Ju...@crlcorp.com>.
I believe I have figured it out. 

The equivalent of: 
<camel:camelContext id="AbstractCamelContext"
allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks">  
  <camel:contextScan/>  
</camel:camelContext>  


Is: 
<bean id="AbstractCamelContext"
class="org.apache.camel.spring.CamelContextFactoryBean">
  <property name="allowUseOriginalMessage" value="false" />
  <property name="shutdownRunningTask" value="CompleteAllTasks" />
  <property name="contextScan">
    <bean class="org.apache.camel.model.ContextScanDefinition" />
  </property>
</bean>

If I am wrong please let me know.  Also if someone could explain where I can
see the translation of http://camel.apache.org/schema/spring tags to
classes, I would be grateful.  Useful knowledge for me to know in the
future.



--
View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760344.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FW: Spring Camel "Parent" Context

Posted by rosenbergj <Ro...@crlcorp.com>.
I believe I have figured it out.

The equivalent of:
<camel:camelContext id="AbstractCamelContext"
allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks"> 
  <camel:contextScan/> 
</camel:camelContext> 


Is:
<bean id="AbstractCamelContext"
class="org.apache.camel.spring.CamelContextFactoryBean">
	<property name="allowUseOriginalMessage" value="false" />
	<property name="shutdownRunningTask" value="CompleteAllTasks" />
	<property name="contextScan">
		<bean class="org.apache.camel.model.ContextScanDefinition" />
	</property>
</bean>

If I am wrong please let me know.  Also if someone could explain where I can
see the translation of http://camel.apache.org/schema/spring tags to
classes, I would be grateful.  Useful knowledge for me to know in the
future. 



--
View this message in context: http://camel.465427.n5.nabble.com/FW-Spring-Camel-Parent-Context-tp5760339p5760343.html
Sent from the Camel - Users mailing list archive at Nabble.com.

FW: Spring Camel "Parent" Context

Posted by Justin Rosenberg <Ju...@crlcorp.com>.
I have many (over 100) projects that all include a core Spring project where ActiveMQ is configured.  Currently each project defines its own camel context as such:

	<camel:camelContext id="CamelContext-${project.artifactId}_${project.version}">
		<camel:contextScan/>
	</camel:camelContext>

I would like to change some parameters in the way the camel context is defined.  I could simply put the context in the common project, however the ID would not match the ID of the sub-project.  Therefore I would like to do something like the following:

In the common project:

	<camel:camelContext id="AbstractCamelContext" allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks" abstract="true">
		<camel:contextScan/>
	</camel:camelContext>

In each individual project

	<camel:camelContext id="CamelContext-${project.artifactId}_${project.version}" parent="AbstractCamelContext "/>

Since "camel:camelContext" is just short-hand for Spring Configuration.  Could someone help me understand what the traditional Spring equivalent would be for:

	<camel:camelContext id="AbstractCamelContext" allowUseOriginalMessage="false" shutdownRunningTask="CompleteAllTasks">
		<camel:contextScan/>
	</camel:camelContext>

Thank you,

Justin
 

CONFIDENTIALITY NOTICE:
The information in this message, and any attachment, is intended for the 
sole use of the individual and entity to whom it is addressed. This 
information may be privileged, confidential, and protected from 
disclosure. If you are not the intended recipient you are hereby notified 
that you have received this communication in error and that any review, 
disclosure, dissemination, distribution or copying of it, or its contents, 
is strictly prohibited. If you think that you have received this message 
in error please notify the sender and destroy all copies of this 
communication and any attachments. Thank you.