You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by selezovikj <se...@gmail.com> on 2008/10/21 14:59:55 UTC

Sending from a POJO to an endpoint

I have the following code: 

while ((strLine = br.readLine()) != null)   {
	if(messageName.equals(strLine)){
					
		System.out.println("MESSAGE equals line in file");

		@EndpointInject(uri="bean:filterCCBean")
		ProducerTemplate producer;
		producer.sendBody(message);
                break;
	} else {
					
		@EndpointInject(uri="bean:log4jBean")
		ProducerTemplate producer;
		producer.sendBody(message);
					
}

}

Basically I want if the line that I am reading from a file is matched with
messageName, I want the producer to send the "message" object to the
"filterCCBean". If I am in the else part, I want the object to be sent to
the "log4jBean". 
I guess this is not the right way to do this since Eclipse is complaining
the EndpointInject is not allowed for that location. 

Any help ?
-- 
View this message in context: http://www.nabble.com/Sending-from-a-POJO-to-an-endpoint-tp20089728s22882p20089728.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Sending from a POJO to an endpoint

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You can use the producer as a class variable, instead

Public class X

   @EndpointInject(name = "producer")
   Private ProducerTemplate producer;

And then you can use the same producer, but the first parameter is the uri

  producer.sendBody("bean:foo", payload);

And then you need to have the endpoint inject name as a spring bean id in the spring .xml file. There is a special tag for this in camel = template as shown below.

<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
   <template id="producer"/>  
</camelContext>






Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: selezovikj [mailto:semir.elezovic@gmail.com] 
Sent: 21. oktober 2008 15:00
To: camel-user@activemq.apache.org
Subject: Sending from a POJO to an endpoint


I have the following code: 

while ((strLine = br.readLine()) != null)   {
	if(messageName.equals(strLine)){
					
		System.out.println("MESSAGE equals line in file");

		@EndpointInject(uri="bean:filterCCBean")
		ProducerTemplate producer;
		producer.sendBody(message);
                break;
	} else {
					
		@EndpointInject(uri="bean:log4jBean")
		ProducerTemplate producer;
		producer.sendBody(message);
					
}

}

Basically I want if the line that I am reading from a file is matched with
messageName, I want the producer to send the "message" object to the
"filterCCBean". If I am in the else part, I want the object to be sent to
the "log4jBean". 
I guess this is not the right way to do this since Eclipse is complaining
the EndpointInject is not allowed for that location. 

Any help ?
-- 
View this message in context: http://www.nabble.com/Sending-from-a-POJO-to-an-endpoint-tp20089728s22882p20089728.html
Sent from the Camel - Users mailing list archive at Nabble.com.