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.

Reply via email to