SericeMix の起動中にバンドルがロードされるとすぐに、ServiceA が ServiceB を呼び出すことを試みています。Service2 には activemq エンドポイントがあり、その特定のサービスのメソッドを呼び出す必要があります。私はそのメソッドで ServiceA のメソッドを自動トリガーするのに役立つ bean タグの spring init-method 属性を試しました。私は serviceB のメソッドを呼び出しています。エンドポイントで No Consumer のような例外が発生しています。Service1 が起動するとすぐに、@Produce アノテーションの activemq エンドポイントを使用して初期化する必要がある service2 のインスタンスを取得していないと仮定します。他の通常のシナリオでは、同じサービスが正常に機能します。
例外: 原因: org.apache.camel.CamelExchangeException: エンドポイントで使用可能なコンシューマーがありません: Endpoint[direct://ServiceB]。Exchange[Message: BeanInvocation public java.lang.String java.lang.Object.toString() with null]] at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:46) at org.apache. camel.component.bean.CamelInvocationHandler.invoke(CamelInvocationHandler.java:64) ... 35 もっと見る
参考までにコード ブロックをコピーして貼り付けます。
public class ServiceA{
@Produce(uri = "direct:ServiceB") //Active MQ endpoint
private ServiceB serviceB;
public void start()
{
Object obj = serviceB.getData(); }
. . .
.....
}
}
**bundle-context.xml**
//Changes for method to auto trigger during spring bean load
<bean id="serviceA" class="com.test.serviceA" init-method="start">
</bean>
**bundle-context-camel.xml**
<osgi:camelContext id="ServiceA"
xmlns="http://camel.apache.org/schema/spring">
<template id="producerTemplate" />
<!-- These routes are outbound to other services -->
<route>
<from uri="ServiceB" />
<bean ref="enrichOutboundExchangeRef" />
<to uri="activemq:ServiceB?transferException=true" />
</route>
..............
</osgi:camelContext>
または、この要件を達成する必要がある場合、他の方法はありますか? servicemix の起動中に、サービスを自動的にロードする (他のサービスを消費する) ことができます。