Apache Camel,从另一条路线调用一条路线

Pet*_*ter 2 apache-camel jbossfuse

我在一个骆驼上下文中有两条路线。

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <propertyPlaceholder location="classpath:facebook.properties"
            id="properties" />
        <route>
            <from uri="jetty:http://0.0.0.0:8765/getLikes" />
            <to uri="facebook" />
        </route>

        <route>
            <from uri="facebook://userLikes?oAuthAppId={{oAuthAppId}}&amp;oAuthAppSecret={{oAuthAppSecret}}&amp;oAuthAccessToken={{oAuthAccessToken}}" />
            <log message="The message contains ${body}" />
        </route>
    </camelContext>
Run Code Online (Sandbox Code Playgroud)

在第二条路线中,我使用 facebook 组件。我想调用http://localhost:8765/getLikes并从 Facebook 获得所有喜欢的第二条路线。但是第一条路线找不到第二条路线

Ale*_*nin 5

为此,您必须使用direct ( http://camel.apache.org/direct ) 或seda ( http://camel.apache.org/seda.html )等组件:

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <propertyPlaceholder location="classpath:facebook.properties"
            id="properties" />
        <route>                
            <from uri="jetty:http://0.0.0.0:8765/getLikes" />
            <to uri="direct:facebook" />
        </route>

        <route>
            <from uri="direct:facebook" />
            <!-- Maybe you need to set some headers here -->
            <to uri="facebook://userLikes?oAuthAppId={{oAuthAppId}}&amp;oAuthAppSecret={{oAuthAppSecret}}&amp;oAuthAccessToken={{oAuthAccessToken}}" />
            <log message="The message contains ${body}" />
        </route>
    </camelContext>
Run Code Online (Sandbox Code Playgroud)

此链接https://people.apache.org/~dkulp/camel/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html也可以为您提供帮助.