Apache Camel,从一条路线调用另一条路线
Apache Camel, calling one route from another
我在一个骆驼上下文中有两条路线。
<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}}&oAuthAppSecret={{oAuthAppSecret}}&oAuthAccessToken={{oAuthAccessToken}}" />
<log message="The message contains ${body}" />
</route>
</camelContext>
在第二条路线中,我使用了 facebook 组件。
我想打电话给 http://localhost:8765/getLikes 并从第二条路线获得的 facebook 获得所有喜欢。但是第一条路线找不到第二条
您必须为此使用 direct (http://camel.apache.org/direct) or 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}}&oAuthAppSecret={{oAuthAppSecret}}&oAuthAccessToken={{oAuthAccessToken}}" />
<log message="The message contains ${body}" />
</route>
</camelContext>
这篇linkhttps://people.apache.org/~dkulp/camel/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.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="facebook" />
</route>
<route>
<from uri="facebook://userLikes?oAuthAppId={{oAuthAppId}}&oAuthAppSecret={{oAuthAppSecret}}&oAuthAccessToken={{oAuthAccessToken}}" />
<log message="The message contains ${body}" />
</route>
</camelContext>
在第二条路线中,我使用了 facebook 组件。 我想打电话给 http://localhost:8765/getLikes 并从第二条路线获得的 facebook 获得所有喜欢。但是第一条路线找不到第二条
您必须为此使用 direct (http://camel.apache.org/direct) or 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}}&oAuthAppSecret={{oAuthAppSecret}}&oAuthAccessToken={{oAuthAccessToken}}" />
<log message="The message contains ${body}" />
</route>
</camelContext>
这篇linkhttps://people.apache.org/~dkulp/camel/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html对你也有帮助。