Hi Michael,

any luck with taking a look at the producer template.

As far as I can observe your routes, everything looks OK, except that it is 
still only partial and not bound together.

You can always execute myBatis from a Processor within your route, I mean 
trigger your existing code base from a Processor that does the job. This might 
ease your ramp up with the myBatis component config an eventually provide you a 
bit more freedom. Nevertheless you won't utilize the entire Camel feature set.

What I've seen in your last route, is that you might want to take a look at the 
section "Using onConsume" in http://camel.apache.org/mybatis.html

Kind regards,

- Christoph

On Jun 3, 2013, at 2:09 PM, Conneen Michael wrote:

> Christoph (et all), 
> 
> Thanks for the reply... I apologize for not being clear.. I know that is 
> important for effective use of everyones time.   Here is the use case.. 
> User http posts a form to servlet (camel servlet.... 
>       I have this working via the camel tomcat example as starting point.. )
> 
> Servlet validates post, parses parameters, executes query, passes query 
> results to velocity to generate html, returns response
> 
> It is the later that I broke down into junit tests to ensure I understand the 
> syntax and that each step works.. So.. what I have is.. 
> 
> execute query .. 
>       I have this working via a junit that basically has a route of . 
>               from("direct:start") 
> .to("mybatis:selectMyList?statementType=SelectList") .log("Tapped message 
> body is ${body}") .to("mock:result"); 
> 
>       and then after the template.sendBody() .. the junit does a 
>       List<Account> list = 
> mock.getReceivedExchanges().get(0).getIn().getBody(List.class); 
> 
>       and iterates over the returned collection .. so I know myBatis is 
> working as designed. 
> 
> generate html from list.. 
>       I kind of have this working in a junit.. though I currently do not 
> execute myBatis via a route.. I execute it as I always have..
> 
>       I execute this .. (mainly because I am struggling to link the routes.. 
> ) 
>       myList = mySqlSession.selectList("selectMyList");  // pojo style 
> myBaits. 
>        template.requestBody("direct:start", myList);
> 
>       my route looks like.. 
>        from("direct:start")   // start from camel itself .. no input queue 
>        .to("velocity:myVelocityTemplate.vm")    // run velocity against input 
> message
>        .to("file://target/subfolder")    // write the output of the velocity 
> to a file. 
>        ;
> 
> where I am trying to get to is something like this.. 
> 
>       route looks like... 
>        from("direct:start")   // start from camel itself .. no input queue 
>       .to("mybatis:selectMyList?statementType=SelectList") 
>       .log("Tapped message body is ${body}")
>        .to("velocity:myVelocityTemplate.vm")    // run velocity against input 
> message
>        .to("file://target/subfolder")    // write the output of the velocity 
> to a file. 
>        ;
> 
> and eventually ..  burry all that into a config.. using the example tomcat 
> servlet as my starting point.. 
> 
> So..finally.. to provide response to your questions.. 
>> A: Are you executing this example as unit test? If so, why don't you apply 
>> the ProducerTemplate and simply pass the list when executing the sendBody() 
>> operation?
>       I tried following the Camel In Action book's logic of an anonymous 
> inner class "new Processor()..", but that seems to have moved to an interface 
> now.  I will look into the ProducerTemplate...
> 
>> B: We'll, ... you probably need to send it somewhere via the to() statement, 
>> e.g. to the jetty component or any other
>       I need to send to the servlet output stream as the use case is post 
> form.. return formatted response.. 
>       I was just going to tackle this problem in a plain old servlet, but 
> thought I would use this as an opportunity to learn camel's EIP capabilities. 
> ;) 
> 
> Kind Regards,
> 
> Michael L. Conneen
> Information Integrators, Inc.
> http://www.infointegrators.com
> PGP Key: http://mconneen.infointegrators.net/mconneen.asc
> 
> 
> 
> On Jun 3, 2013, at 02:55 , Christoph Emmersberger wrote:
> 
>> Hi Michael,
>> 
>> let me try to ask some questions:
>> 
>> A: Are you executing this example as unit test? If so, why don't you apply 
>> the ProducerTemplate and simply pass the list when executing the sendBody() 
>> operation?
>> B: We'll, ... you probably need to send it somewhere via the to() statement, 
>> e.g. to the jetty component or any other.
>> 
>> Cheers,
>> 
>> - Christoph
>> 
>> On Jun 2, 2013, at 11:01 PM, Conneen Michael wrote:
>> 
>>> Folks, 
>>> 
>>> I  suspect I am a stones throw away from the "ah ha" moment.. but I cannot 
>>> seem to get there..   I am a newbie so I purchased and downloaded the Camel 
>>> In Action ebook... Great overview and has gotten me this far.. I do have 
>>> "some" of the individual pieces working.. I just cannot figure out how to 
>>> build the route correctly. 
>>> 
>>> I have searched the camel user forum for "mybatis selectlist velocity" ... 
>>> but have yet to find what I am looking for... 
>>> 
>>> Here is what I want to do.. 
>>> 1.  Run camel using a servlet endpoint as the starting point.   
>>>     From the tomcat example, got this working and mostly understand the 
>>> spring configuration... 
>>>             
>>> 2.  Parse off a parameter and pass into a myBatis select list. .. 
>>>     I have worked with myBatis a lot from POJOs... so I have both POJOs.. 
>>> and I think a direct junit test of the mybatis route.. 
>>>             
>>> 3.  Route the query results to velocity to produce an html table. ... 
>>>     I have junit working where I pass a list via  
>>> template.requestBody("direct:in", list);
>>>             
>>> 4.  Return the results of the velocity template as the html response
>>>     Have not tackled this yet.   Trying to get routes 2 and 3 above first.. 
>>> 
>>> Things I cannot figure out.. 
>>> A.   via "to" routing syntax, how do I provide the appropriate list 
>>> collection to velocity ?  I know the raw syntax is
>>>             List<?> list = 
>>> mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
>>>             but velocity is expecting the collection as part of the body.. 
>>>             
>>> B.  how do I pull the velocity results out and concatenate with my desired 
>>> html output stream?
>>> 
>>> Any pointers to my "ah ha" moment much appreciated..
>> 
> 

Reply via email to