camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "naveen.palle" <naveen.pall...@gmail.com>
Subject Building Camel Dynamic router getting after properties from Database
Date Tue, 17 Nov 2015 06:08:52 GMT
Hi,

I am currently working on dynamic camel route builder for each customer. I
am getting customer information form database.  My route : 

public class RouteAllCust extends SpringRouteBuilder{

	
	public String dataSource;
	
	@SuppressWarnings("unchecked")
	@Override
	public void configure() throws Exception {
		
		//Route0
		from("direct:cornExp"+dataSource)
		.to("sql:select * from PropertiesTable where keytext like
'cid.csv.ftp%'?dataSourceRef="+dataSource)
		.process(new CustomerProcessor())
		.split(header("customers"))
			.process(new IndivisualCustomerProcessor())
			.to("quartz://timerName" + "${in.header.cid}" + 
"?${in.header.cornExpression}").routeId("Cron Scheduler Route "+
"${in.header.cid}")
			.to("direct:ftpupload"+dataSource);
	
	}

	public String getDataSource() {
		return dataSource;
	}

	public void setDataSource(String dataSource) {
		this.dataSource = dataSource;
	}
}
 
I have injected dataSource form spring config.

CustomerProcessor : 
public class CustomerProcessor implements Processor {
@Override
	public void process(Exchange exchange) throws Exception {

		logger.info("Getting customer list map");
		List<Map&lt;String, Object>> customerList = (List<Map&lt;String, Object>>)
exchange.getIn().getBody(List.class);
		exchange.getIn().setHeader("customers", customerList);
		logger.info("Customer list size : " + cust.size());

	}
}

IndivisualCustomerProcessor :

public class IndivisualCustomerProcessor implements Processor{

	private static final Logger logger =
LoggerFactory.getLogger(IndivisualCustomerProcessor.class);
	@Override
	public void process(Exchange exchange) throws Exception {
		
		//logger.info("Getting Indivisual Customer ");
		
		Customer c = (Customer) exchange.getIn().getBody(Customer.class);
		if(c.getcId() != null)	{
			Map<String, Object> headerMap = new HashMap<String, Object>();
			headerMap.put("cid", c.getcId());
			headerMap.put("ccode", c.getCustomerCode());
			headerMap.put("username",c.getUserName());
			headerMap.put("password",c.getPassword());
			headerMap.put("ftphost",c.getFtpHost());
			headerMap.put("reportsubscription", c.getReportSubscription());
			headerMap.put("customerprofile", c.getCustProfile());
			headerMap.put("cornExpression", c.getCustProfile());
					
			exchange.getIn().setHeaders(headerMap);
		}
		else{
			logger.info("Can not process this customer. Customer id is null. " +
c.toString());
		}
		
		logger.info("Processing of Customer id   : " + c.getcId() + " - " +
c.getCustProfile());
		
	}

Where I am setting customer properties in the header. These properties are
used to create route for each customer.


I am getting following error : 

Failed to resolve endpoint:
quartz://timerName$%7Bin.header.cid%7D?%24%7Bin.header.cornExpression%7D=
due to: There are 1 parameters that couldn't be set on the endpoint. Check
the uri if the parameters are spelt correctly and that they are properties
of the endpoint. Unknown parameters=[{${in.header.cornExpression}=}]

I have used header("cornExpression") instead of ${in.header.cornExpression}.
I am getting same error message.

Can anyone help me to fix the issue.

Thank you





--
View this message in context: http://camel.465427.n5.nabble.com/Building-Camel-Dynamic-router-getting-after-properties-from-Database-tp5773968.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message