You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "ben.oday" <be...@initekconsulting.com> on 2011/04/23 16:37:26 UTC

Re: how can i get bean map property in camel

if you are using Spring to initialize the bean, you should use the bean
ref/annotation approach to implement recipient list...see this example

http://camel.apache.org/recipientlist-annotation.html


aronftd wrote:
> 
> i define MessageRouter in spring xml ,when i be in debug mode ,i find the
> apc3AddrMap property is null;
> but i test  MessageRouter  not in camel ,it can get  the map property ,
> how can i do ,thanks!    
> 
> 
> 
> public class FileToJMSRouter extends RouteBuilder {
> 	
> 	public String rcvQ;
> 	public String sendQ;
>     @Override
>     public void configure() throws Exception {
>         // load file orders from src/data into the JMS queue
> //    	DataFormat jaxb = new
> JaxbDataFormat("com.sinosky.cdip.route.xsd.rply");
>     	String sendQStr = "jms:" + sendQ;
>     	String rcvQStr = "jms:" + rcvQ;    	
>         errorHandler(defaultErrorHandler()
>                 .maximumRedeliveries(2)
>                 .redeliveryDelay(1000)
>                 .retryAttemptedLogLevel(LoggingLevel.WARN));            
>     	from("file:src/data?delay=1000")
>     	.to(sendQStr)
>     
> .to("file:logs/send?fileName=${date:now:yyyy-MM-dd}/${exchangeId}.xml")    	
>     	.recipientList().method(MessageRouter.class, "routeTo")
>     	.setBody(constant("success"))
>     	.to(rcvQStr)
>     
> .to("file:logs/receive?fileName=${date:now:yyyy-MM-dd}/${exchangeId}.xml");
>     	;
>     }
> 	public String getRcvQ() {
> 		return rcvQ;
> 	}
> 	public void setRcvQ(String rcvQ) {
> 		this.rcvQ = rcvQ;
> 	}
> 	public String getSendQ() {
> 		return sendQ;
> 	}
> 	public void setSendQ(String sendQ) {
> 		this.sendQ = sendQ;
> 	}
> }
> 
> 
> public class MessageRouter {
> 	private Map&lt;String,String&gt; apc3AddrMap;
> 
> 	public Map&lt;String, String&gt; getApc3AddrMap() {
> 		return apc3AddrMap;
> 	}
> 
> 	public void setApc3AddrMap(Map&lt;String, String&gt; apc3AddrMap) {
> 		this.apc3AddrMap = apc3AddrMap;
> 	}
> 	public String routeTo(@XPath("/R/RCV/APC3/text()") String key) { 
> 	    String str = apc3AddrMap.get(key);
>         return str; 
>     } 
> 
> }
> 

-----
Ben O'Day
IT Consultant -http://benoday.blogspot.com

--
View this message in context: http://camel.465427.n5.nabble.com/how-can-i-get-bean-map-property-in-camel-tp4330192p4334746.html
Sent from the Camel - Users mailing list archive at Nabble.com.