Search code examples
apache-camelcxfcxfrs

Apache Camel Route cannot find Endpoint


I created a cxf route for my application like this:

from("cxfrs:{{url}}?resourceClasses=MyImpl&bindingStyle=SimpleConsumer")
.to("${header.operationName}").end();
from("direct:{{getUser}}")
        .bean("userImpl", "getUserByName")
        .marshal().json(JsonLibrary.Jackson)
    .to("log:foo");

    from("direct:{{login}}")    
        .bean("userImpl", "loginUser")
        .marshal().json(JsonLibrary.Jackson)
    .to("log:foo");

If I try get my operationName in a processor, I can get it, but if I call this route, I have this message:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Error 500 No consumers available on endpoint: Endpoint[direct://$%7Bheader.operationName%7D]. Exchange[ID-NBSPO049-64311-1498773394077-0-2] while invoking public java.lang.String com.itau.ea4.implementacao.UserImpl.loginUser(java.lang.String,java.lang.String) with params [teste, 1234].</title>
</head>
<body>
    <h2>HTTP ERROR 500</h2>
    <p>Problem accessing /user/login. Reason:

        <pre>    No consumers available on endpoint: Endpoint[direct://$%7Bheader.operationName%7D]. Exchange[ID-NBSPO049-64311-1498773394077-0-2] while invoking public java.lang.String com.itau.ea4.implementacao.UserImpl.loginUser(java.lang.String,java.lang.String) with params [teste, 1234].</pre>
    </p>
    <hr>
    <i>
        <small>Powered by Jetty://</small>
    </i>
    <hr/>
</body>

What's wrong with my route? And why my header cannot is recognized?


Solution

  • The problem is in:

    .to("${header.operationName}")
    

    "to(...)" doesn't support dynamic data so in your case it actually tries to send to endpoint "direct:{header.operationName}".

    To use dynamic value from header you can use toD (from Camel 2.19) or recipientsList with one recipient (Camel before 2.19)