camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From VinothKR <vinsmai...@gmail.com>
Subject Re: Camel route set map object in body
Date Sun, 10 Apr 2016 18:08:33 GMT
Hi Ranx,
Thanks. I was able to send a Map object to the body using bean.

Converter class:
public Map<String,Object> myConverter(String toDisplay) 
	{ 
		logger.debug("Invoking my converter for type
"+toDisplay.getClass().getName()+" toDisplay "+toDisplay); 
		Gson gson = new Gson();
		Type mapType = new TypeToken<Map&lt;String, Object>>(){}.getType();
		Map<String,Object> requiredData = gson.fromJson(toDisplay, mapType);
		logger.debug("Output from converter: "+requiredData);
		return requiredData; 
	} 

PropertiesMap:
final Map<String,String> propertiesMap = new HashMap<String,String>();
			propertiesMap.put("EmpId", "23456");

Route:
from("quartz2://sampleGroup/sampleTimer?trigger.repeatCount=1")
					.routeId("scheduler").noAutoStartup()
					.setBody(new SimpleExpression(propertiesMap.toString()))
					.bean(new QuartzStandaloneTest(), "myConverter") 
					.to("direct:hivein");

Thanks,
Vinoth.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-set-map-object-in-body-tp5780863p5780880.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message