You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Gilday <ma...@imap.cc> on 2008/09/17 12:18:00 UTC
Minimal Spring config for a webapp
Hi Camel riders,
I'm in the process of writing a web app which needs to simply place a
message on a JMS queue. This is then picked up by an independent
project with Camel routes in it. What I am trying to do is write the
smallest Camel config I need with Spring for the web app. All I think I
really need is a Camel ProducerTemplate and a JmsComponent definition
which details the ActiveMQ connection details.
I am hoping to just use the following (I've removed namespace
definitions)
<beans>
<camel:template id="camelTemplate" />
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
</property>
</bean>
</beans>
Do I need to define a <camel:camelContext> at all?
Has anything changed regarding the <camel:template /> element since
CamelTemplate was deprecated for ProducerTemplate? I've set up a
AbstractJUnit4SpringContextTests with @Autowired on a ProducerTemplate
field and asserted it exists and is an instance of
DefaultProducerTemplate. Was it ever considered to adjust the element
name to be camel:producerTemplate so it is more obvious what it is? Is
it likely there will ever be another *Template in Camel that would make
this element name confusing?
Thanks,
Martin
Re: Minimal Spring config for a webapp
Posted by Martin Gilday <ma...@imap.cc>.
Thanks James, I'd forgotten about that component.
----- Original message -----
From: "James Strachan" <ja...@gmail.com>
To: camel-user@activemq.apache.org
Date: Wed, 17 Sep 2008 11:22:22 +0100
Subject: Re: Minimal Spring config for a webapp
2008/9/17 Martin Gilday <ma...@imap.cc>:
> Hi Camel riders,
>
> I'm in the process of writing a web app which needs to simply place a
> message on a JMS queue. This is then picked up by an independent
> project with Camel routes in it. What I am trying to do is write the
> smallest Camel config I need with Spring for the web app. All I think I
> really need is a Camel ProducerTemplate and a JmsComponent definition
> which details the ActiveMQ connection details.
>
> I am hoping to just use the following (I've removed namespace
> definitions)
>
> <beans>
> <camel:template id="camelTemplate" />
>
> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
> <property name="connectionFactory">
> <bean class="org.apache.activemq.ActiveMQConnectionFactory">
> <property name="brokerURL" value="tcp://localhost:61616" />
> </bean>
> </property>
> </bean>
> </beans>
BTW if you are using ActiveMQ I'd recommend using the ActiveMQ
component...
http://activemq.apache.org/camel/activemq.html
as this is then configured to use pooling correctly.
e.g.
<bean id="jms"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://somehost:61616"/>
</bean>
> Do I need to define a <camel:camelContext> at all?
Yes, right now its mandatory, it makes the CamelContext object which
is injected into the ProducerTemplate etc.
> Has anything changed regarding the <camel:template /> element since
> CamelTemplate was deprecated for ProducerTemplate? I've set up a
> AbstractJUnit4SpringContextTests with @Autowired on a ProducerTemplate
> field and asserted it exists and is an instance of
> DefaultProducerTemplate. Was it ever considered to adjust the element
> name to be camel:producerTemplate so it is more obvious what it is? Is
> it likely there will ever be another *Template in Camel that would make
> this element name confusing?
I think its gonna stay template AFAIK
If its any help there's a little tutorial on using camel with web
apps...
http://activemq.apache.org/camel/tutorial-on-using-camel-in-a-web-application.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: Minimal Spring config for a webapp
Posted by James Strachan <ja...@gmail.com>.
2008/9/17 Martin Gilday <ma...@imap.cc>:
> Hi Camel riders,
>
> I'm in the process of writing a web app which needs to simply place a
> message on a JMS queue. This is then picked up by an independent
> project with Camel routes in it. What I am trying to do is write the
> smallest Camel config I need with Spring for the web app. All I think I
> really need is a Camel ProducerTemplate and a JmsComponent definition
> which details the ActiveMQ connection details.
>
> I am hoping to just use the following (I've removed namespace
> definitions)
>
> <beans>
> <camel:template id="camelTemplate" />
>
> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
> <property name="connectionFactory">
> <bean class="org.apache.activemq.ActiveMQConnectionFactory">
> <property name="brokerURL" value="tcp://localhost:61616" />
> </bean>
> </property>
> </bean>
> </beans>
BTW if you are using ActiveMQ I'd recommend using the ActiveMQ component...
http://activemq.apache.org/camel/activemq.html
as this is then configured to use pooling correctly.
e.g.
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://somehost:61616"/>
</bean>
> Do I need to define a <camel:camelContext> at all?
Yes, right now its mandatory, it makes the CamelContext object which
is injected into the ProducerTemplate etc.
> Has anything changed regarding the <camel:template /> element since
> CamelTemplate was deprecated for ProducerTemplate? I've set up a
> AbstractJUnit4SpringContextTests with @Autowired on a ProducerTemplate
> field and asserted it exists and is an instance of
> DefaultProducerTemplate. Was it ever considered to adjust the element
> name to be camel:producerTemplate so it is more obvious what it is? Is
> it likely there will ever be another *Template in Camel that would make
> this element name confusing?
I think its gonna stay template AFAIK
If its any help there's a little tutorial on using camel with web apps...
http://activemq.apache.org/camel/tutorial-on-using-camel-in-a-web-application.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com