You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Imran Raza Khan <im...@gmail.com> on 2020/12/23 22:53:23 UTC

Simplify processor code with simple throws error - Apache Camel 3.7

I am working on a code in which one processor is like

    public void process(Exchange exchange) throws Exception
    {
        exchange.getIn().setHeader("AMQ_PASSWORD",
exchange.getMessage().getBody(io.fabric8.kubernetes.api.model.Secret.class).getData().get("amq-password"));
    }

I thought to simplify this with following code in route

            ...

.to("kubernetes-secrets:///?kubernetesClient=#kubernetesClient&operation=getSecret")
            .setHeader("amq_pass", simple("
 ${body.getData.get[amq-password]}  "))
                 or
            .setHeader("amq_pass", simple("
 ${bodyAs(io.fabric8.kubernetes.api.model.Secret).getData.get[amq-password]}
 "))
            ...

But all tries leads to following error

    [org.apa.cam.qua.mai.CamelMainRuntime] (Quarkus Main Thread) Failed to
start application: org.apache.camel.FailedToCreateRouteException: Failed to
create route nats-pub at: >>> Set
    Header[nats_user, simple{  ${body.getData.get('amq-password')}  }] <<<
in route: Route(nats-pub)[From[timer://ipc?repeatCount=1&delay=60000] ...
because of No language could be found for: bean

Re: Simplify processor code with simple throws error - Apache Camel 3.7

Posted by Imran Raza Khan <im...@gmail.com>.
Following dependency was missing

<dependency>
  <groupId>org.apache.camel.quarkus</groupId>
  <artifactId>camel-quarkus-bean</artifactId>
</dependency>


On Wed, Dec 23, 2020 at 11:53 PM Imran Raza Khan <im...@gmail.com>
wrote:

> I am working on a code in which one processor is like
>
>     public void process(Exchange exchange) throws Exception
>     {
>         exchange.getIn().setHeader("AMQ_PASSWORD",
> exchange.getMessage().getBody(io.fabric8.kubernetes.api.model.Secret.class).getData().get("amq-password"));
>     }
>
> I thought to simplify this with following code in route
>
>             ...
>
> .to("kubernetes-secrets:///?kubernetesClient=#kubernetesClient&operation=getSecret")
>             .setHeader("amq_pass", simple("
>  ${body.getData.get[amq-password]}  "))
>                  or
>             .setHeader("amq_pass", simple("
>  ${bodyAs(io.fabric8.kubernetes.api.model.Secret).getData.get[amq-password]}
>  "))
>             ...
>
> But all tries leads to following error
>
>     [org.apa.cam.qua.mai.CamelMainRuntime] (Quarkus Main Thread) Failed to
> start application: org.apache.camel.FailedToCreateRouteException: Failed to
> create route nats-pub at: >>> Set
>     Header[nats_user, simple{  ${body.getData.get('amq-password')}  }] <<<
> in route: Route(nats-pub)[From[timer://ipc?repeatCount=1&delay=60000] ...
> because of No language could be found for: bean
>
>