You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ganga_camel <ga...@gmail.com> on 2016/02/11 14:09:27 UTC

Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Hi,

I am exploring Spring Boot to write the camel routes...I started off by
creating a Maven Project using the camel-archetype-spring-boot.

The project contained 2 classes,
1. a class that extends from fatjarrouter, which houses the camel routes
2. a class by name WarInitializer which extends FatWarInitializer, which I
understand is the starting point to trigger the class containing the routes

The requirement that I am working on is to add a WebSphere MQ component to
the Camel Context so that I will be able to use it in my routes to
communicate to the WMQ Queues.

Since there is no Main class, neither Camel-context.xml, I am left wondering
where do I register the component into the camel context.

Can help would be appreciated..

Thanks,
Ganga



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Posted by ganga_camel <ga...@gmail.com>.
sure....am new to Spring annotations, will explore further... Thanks for the
insight...

Thanks,
Ganga



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593p5777627.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah in this case @Bean is like the CDI @Producs annotation. To create
and produce a bean. There should also be a name or id attribute on
@Bean you can use in case you want to set the bean name there instead
of the method name.

You may want to add @Bean for the connection factory so you can
specify its init and destroy methods in case you need to init and
close it. Though spring has some convention that it may be able to
auto detect them also.

You may need to research a bit here.



On Thu, Feb 11, 2016 at 2:54 PM, ganga_camel <ga...@gmail.com> wrote:
> thanks for the response.....Posted my finding just before I saw your
> response.....
> @Bean worked for me...
>
> Thanks,
> Ganga
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593p5777597.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Posted by ganga_camel <ga...@gmail.com>.
thanks for the response.....Posted my finding just before I saw your
response.....
@Bean worked for me...

Thanks,
Ganga



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593p5777597.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Posted by Claus Ibsen <cl...@gmail.com>.
You use a @Bean in spring boot to configure and setup the camel component.

See for example
https://github.com/apache/camel/tree/master/examples/camel-example-spring-boot-metrics

Or you can use that CamelContextConfiguration callback and add the
component in the before start method.

On Thu, Feb 11, 2016 at 2:09 PM, ganga_camel <ga...@gmail.com> wrote:
> Hi,
>
> I am exploring Spring Boot to write the camel routes...I started off by
> creating a Maven Project using the camel-archetype-spring-boot.
>
> The project contained 2 classes,
> 1. a class that extends from fatjarrouter, which houses the camel routes
> 2. a class by name WarInitializer which extends FatWarInitializer, which I
> understand is the starting point to trigger the class containing the routes
>
> The requirement that I am working on is to add a WebSphere MQ component to
> the Camel Context so that I will be able to use it in my routes to
> communicate to the WMQ Queues.
>
> Since there is no Main class, neither Camel-context.xml, I am left wondering
> where do I register the component into the camel context.
>
> Can help would be appreciated..
>
> Thanks,
> Ganga
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel Spring Boot - Adding JmsComponent for WMQ to Camel Context

Posted by ganga_camel <ga...@gmail.com>.
I found the answer....

I had to create a method that returned the jmscomponent and annotate it with
@Bean. @Bean annotation is a synonym for the </Bean> in camel-context.xml

The name of the method is the bean name, which I used in my routes to
communicate with the queues.

listed as below, this will register a component by name "wmq". I referenced
this id in my route as listed below

from("file:src/data?noop=true").to("*wmq:QName*").log("writting to Queue is
complete");

@Bean
	JmsComponent wmq() {
		JmsComponent jmsComp = new JmsComponent();
		try {

			MQQueueConnectionFactory jmsConF = new MQQueueConnectionFactory();
			jmsConF.setHostName("<>");
			jmsConF.setQueueManager("<>");
			jmsConF.setPort(<>);
			jmsConF.setChannel("<>");
			jmsConF.setTransportType(<>);

			JmsTransactionManager trsnMgr = new JmsTransactionManager(jmsConF);

			jmsComp.setConnectionFactory(jmsConF);
			jmsComp.setTransactionManager(trsnMgr);
			jmsComp.setTransacted(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return jmsComp;
	}



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-Boot-Adding-JmsComponent-for-WMQ-to-Camel-Context-tp5777593p5777596.html
Sent from the Camel - Users mailing list archive at Nabble.com.