Hi, You can do the following from(seda) .to(http) .process(new Processor() { public void process(Exchange exchange) throws Exception { // do something... } });
This should do the trick. Cheers, Ashwin... kitplummer wrote: > > Thanks Claus, that works. But, I need to handle the returned contents > from my Route. Just figured I needed the Exchange to get at the contents > as a String. > > Kit > > > Claus Ibsen-2 wrote: >> >> Can you not just do a >> >> from(seda).to(http); >> >> The camel http component will automatic use POST if no uri parameters. >> You should also be able to configure in the uri for the http endpoint >> that it should use POST >> >> >> On Tue, Jan 26, 2010 at 2:37 PM, kitplummer <kitplum...@gmail.com> wrote: >>> >>> Getting closer: >>> >>> import org.apache.camel.Exchange >>> import org.apache.camel.Processor >>> import org.apache.camel.Message >>> >>> class JobRoute { >>> def configure = { >>> println "Setting JobRoute Camel Router..." >>> from("seda:my.queue") { >>> Exchange exchange = >>> template.send("http://localhost:4567/jodmock", >>> [ >>> process: { exchange -> >>> exchange.getIn().setHeader(Exchange.HTTP_METHOD, >>> constant(POST)); >>> } >>> ] as Processor >>> ); >>> Message out = exchange.getOut(); >>> int responseCode = >>> out.getHeader(HttpProducer.HTTP_RESPONSE_CODE, Integer.class); >>> } >>> } >>> } >>> >>> Produces: >>> >>> Caused by: groovy.lang.MissingMethodException: No signature of method: >>> org.ix.grails.plugins.camel.GrailsRouteBuilder.from() is applicable for >>> argument types: (java.lang.String, JobRoute$_closure1_closure2) values: >>> [seda:my.queue, jobroute$_closure1_closu...@55661f7b] >>> >>> Run-time error, so we're past the compilation problem. I guess it >>> doesn't >>> like the second closure. :) >>> >>> Thanks for the help. Still curious about how to the get the my.queue >>> message into the body of the In's POST. >>> >>> Kit >>> >>> wkeenan wrote: >>>> >>>> On Tue, Jan 26, 2010 at 5:25 AM, kitplummer <kitplum...@gmail.com> >>>> wrote: >>>> >>>>> >>>>> Ok, just thinking at this point...and I don't yet understand Camel >>>>> well >>>>> enough. So, I need some insight. >>>>> >>>>> What I want to do is use Camel to facilitate some back-end business >>>>> logic >>>>> in >>>>> my Grails app. Here's the general idea. From my Grails app I send a >>>>> block >>>>> of text to a Route. I want this route to be configured to take in a >>>>> block >>>>> of raw text (seda:my.queue) and send my.queue as the body of an HTTP >>>>> POST >>>>> to >>>>> an external service - and consume the returned body, sending it back >>>>> to a >>>>> Grails service. I have the last part figured, but missing the Camel >>>>> guts. >>>>> >>>>> Here's where I'm starting: >>>>> >>>>> class JobRoute { >>>>> def configure = { >>>>> println "Setting JobRoute Camel Router..." >>>>> from("seda:my.queue") { >>>>> Exchange exchange = >>>>> template.send("http://localhost:4567/jodmock", >>>>> new Processor() { >>>>> process(exchange) { >>>>> >>>>> exchange.getIn().setHeader(Exchange.HTTP_METHOD, >>>>> constant(org.apache.camel.component.http.HttpMethods.POST)); >>>>> } >>>>> } >>>>> ); >>>>> Message out = exchange.getOut(); >>>>> int responseCode = >>>>> out.getHeader(HttpProducer.HTTP_RESPONSE_CODE, Integer.class); >>>>> } >>>>> } >>>>> } >>>>> >>>>> The "new Processor() instantiation barfs during compile with: >>>>> >>>>> [groovyc] >>>>> /Users/kplummer/Development/ts/grails-app/routes/JobRoute.groovy: >>>>> 9: You cannot create an instance from the abstract interface >>>>> 'org.apache.camel.Processor'. >>>>> [groovyc] @ line 9, column 17. >>>>> [groovyc] new Processor() { >>>>> [groovyc] >>>>> >>>>> >>>> try this: >>>> >>>> class JobRoute extends RouteBuilder { >>>> void configure { >>>> println "Setting JobRoute Camel Router..." >>>> from("seda:my.queue") { >>>> Exchange exchange = >>>> template.send("http://localhost:4567/jodmock >>>> ", >>>> [ >>>> process: { exchange -> >>>> exchange.getIn().setHeader(Exchange.HTTP_METHOD, >>>> constant(org.apache.camel.component.http.HttpMethods.POST)); >>>> } >>>> ] as Processor >>>> ); >>>> Message out = exchange.getOut(); >>>> int responseCode = >>>> out.getHeader(HttpProducer.HTTP_RESPONSE_CODE, Integer.class); >>>> } >>>> } >>>> } >>>> >>>> >>>> >>>>> And, I haven't figured out to get the my.queue to the contents of the >>>>> In. >>>>> >>>>> Help! >>>>> >>>>> Thanks. >>>>> Kit >>>>> -- >>>>> View this message in context: >>>>> http://old.nabble.com/Grails-Camel---pass-queue-message-to-HTTP-POST--tp27318113p27318113.html >>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>> >>>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/Grails-Camel---pass-queue-message-to-HTTP-POST--tp27318113p27322707.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >>> >>> >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> >> > > ----- --- Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence Progress Software Corporation 14 Oak Park Drive Bedford, MA 01730 --- +1-972-304-9084 (Office) +1-972-971-1700 (Mobile) ---- Blog: http://opensourceknowledge.blogspot.com/ -- View this message in context: http://old.nabble.com/Grails-Camel---pass-queue-message-to-HTTP-POST--tp27318113p27338409.html Sent from the Camel - Users mailing list archive at Nabble.com.