I gathered you wanted to send a map of data and not the quartz data. What wasn't clear from your code snippet is where the bodyMap was coming from. I'm not sure why you are calling toString on the bodyMap in your SimpleExpression and then calling convertToMap after it. Isn't it already the map you want to use?
// You are converting your bodyMap to a string [setBody[simple{{ObligorId=23456}}] //Why are you converting the string to a map now? [scheduler ] [convertBodyTo1 ] [convertBodyTo[java.util.Map] Here's an easy way to get a grip on what is happening with data types and data transformation in a route. Create a method on the class that takes Object and that simply return the same thing they received and then print what they receive along with the class name of the object. public Object invoke(Object toDisplay) { System.out.println(toDispaly.getClass().getName()); //Print anything else you might want to see. return toDisplay; } I'm more used to doing this in Blueprint so can't recall the exact Java DSL syntax but it would be something like: from("quartz2://sampleGroup/sampleTimer?trigger.repeatCount=1") .routeId("scheduler").noAutoStartup().beanRef(this, "invoke") .setBody(new SimpleExpression(bodyMap.toString())).beanRef(this, "invoke") That will then shown you the body class type before and after the setBody call. It would also let you access any data. It could be used as a poor man's converter as well. In fact, you should be able to do what you want with the same sort of structure. If you just want to invoke your ProducerTemplate you can do that as well. It all depends on your objectives. Map<String,Object> bodyMap = new HashMap<String,Object>(); bodyMap.put("EmpId", "23456"); Object out = ProducerTemplate.requestBody("direct:hivein",bodyMap); But unable to achieve the same using quartzScheduler route, camel.addRoutes( new RouteBuilder() { @Override public void configure() throws Exception { from("quartz2://sampleGroup/sampleTimer?trigger.repeatCount=1") .routeId("scheduler").noAutoStartup().beanRef(this, "invokeRoute"); } }); public Object invokeRoute(Ojbect o) { //What do you get for "o" here. If you are just taking the bodyMap instance variable from the object object then you could just us that. Object out = ProducerTemplate.requestBody("direct:hivein",bodyMap); return out; } On Sun, Apr 10, 2016 at 1:32 AM, VinothKR <vinsmai...@gmail.com> wrote: > Hi Ranx, > Thanks for the response. > I will not be able to pass any object type other string to setBody or > simpleExpression methods. I just want to pass a dynamic value to the route. > The message i'm getting is, > Message History > > --------------------------------------------------------------------------------------------------------------------------------------- > RouteId ProcessorId Processor > Elapsed (ms) > [scheduler ] [scheduler ] > [quartz2://sampleGroup/sampleTimer?trigger.repeatCount=1 > ] [ 31] > [scheduler ] [setBody2 ] > [setBody[simple{{ObligorId=23456}}] > ] [ 0] > [scheduler ] [convertBodyTo1 ] [convertBodyTo[java.util.Map] > ] [ 16] > > Exchange > > --------------------------------------------------------------------------------------------------------------------------------------- > Exchange[ > Id ID-PHX2MYMV32-65463-1460269525386-0-3 > ExchangePattern InOnly > Headers > {breadcrumbId=ID-PHX2MYMV32-65463-1460269525386-0-2, > calendar=null, CamelRedelivered=false, CamelRedeliveryCounter=0, > fireTime=Sat Apr 09 23:25:31 MST 2016, jobDetail=JobDetail > 'sampleGroup.sampleTimer': jobClass: > 'org.apache.camel.component.quartz2.CamelJob concurrentExectionDisallowed: > false persistJobDataAfterExecution: false isDurable: false > requestsRecovers: > false, jobInstance=org.apache.camel.component.quartz2.CamelJob@3cd6fd7f, > jobRunTime=-1, mergedJobDataMap=org.quartz.JobDataMap@ec12eb0, > nextFireTime=null, previousFireTime=Sat Apr 09 23:25:26 MST 2016, > refireCount=0, result=null, scheduledFireTime=Sat Apr 09 23:25:27 MST 2016, > scheduler=org.quartz.impl.StdScheduler@45106922, trigger=Trigger > 'sampleGroup.sampleTimer': triggerClass: > 'org.quartz.impl.triggers.SimpleTriggerImpl calendar: 'null' > misfireInstruction: 1 nextFireTime: null, triggerGroup=sampleGroup, > triggerName=sampleTimer} > BodyType String > Body {ObligorId=23456} > ] > > > > ---------------------------------------------------------------------------------------------------- > > The use case i'm trying to achieve is from a jsp page i will be sending a > employee id and for the employee id i will trigger a quartz scheduled job > to > fetch employee record from table every specified time. The cron expression > and the employee id will be from the jsp page. So i want to set them in > body > and access it in route. > The concern is not about the quartz scheduler but passing a map object > through the body to the route. > > Thanks, > Vinoth. > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Camel-route-set-map-object-in-body-tp5780863p5780868.html > Sent from the Camel - Users mailing list archive at Nabble.com. >