[GitHub] [camel-k] rafaeltuelho opened a new issue #914: Automatically resolve dependecy for language expressions (eg: groovy)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [camel-k] rafaeltuelho opened a new issue #914: Automatically resolve dependecy for language expressions (eg: groovy)

GitBox
rafaeltuelho opened a new issue #914: Automatically resolve dependecy for language expressions (eg: groovy)
URL: https://github.com/apache/camel-k/issues/914
 
 
   Camel-K can't automatically resolve camel-groovy dependency when using groovy expression inside camel route. See the following route using a groovy expression that try to extract a substring from the exchange body:
   
   ```java
   import org.apache.camel.builder.RouteBuilder;
   import org.apache.camel.Exchange;
   import org.apache.camel.model.dataformat.JsonLibrary;
   
   public class FuseBot extends RouteBuilder {
     @Override
     public void configure() throws Exception {
       from("telegram:bots/{{telegramToken}}")
         .log("command received from Bot: ${body}")
         .convertBodyTo(String.class)
         .choice()
         .when(simple("${body} == '/hello'"))
           .log("Hello from telegram bot!!!")
           .setBody().simple("Hello from Telegram bot!")
           .to("telegram:bots/{{telegramToken}}")
         .when(simple("${body} starts with '/cmd'"))
           .setHeader(Exchange.HTTP_PATH)
           .groovy("request.body.substring(6,request.body.length())")
           .to("http4://www.receitaws.com.br/v1/cnpj/")
           .unmarshal().json(JsonLibrary.Jackson)
           .transform(simple("${body[nome]}"))
           .to("telegram:bots/{{telegramToken}}")
         .otherwise()
           .setBody().simple("Action not Supported")
           .to("telegram:bots/{{telegramToken}}");      
     }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services