Apache camel 在ServiceMix 4.3启动时加载服务,该服务使用ActiveMQ/Apache Camel使用另一个服务

Apache camel 在ServiceMix 4.3启动时加载服务,该服务使用ActiveMQ/Apache Camel使用另一个服务,apache-camel,apache-servicemix,fuseesb,Apache Camel,Apache Servicemix,Fuseesb,我们正在尝试ServiceA在Seriemix启动期间一旦加载捆绑包就调用ServiceB。Service2拥有activemq端点,我们需要调用该特定服务的方法。我尝试在bean标记中使用spring init method属性,这有助于在ServiceA中自动触发一个方法。在该方法中,我调用serviceB的方法。我遇到了一个异常,好像端点没有可用的消费者。我假设一旦Service1启动,它就不会获取service2的实例,而service2需要使用@product annotation a

我们正在尝试ServiceA在Seriemix启动期间一旦加载捆绑包就调用ServiceB。Service2拥有activemq端点,我们需要调用该特定服务的方法。我尝试在bean标记中使用spring init method属性,这有助于在ServiceA中自动触发一个方法。在该方法中,我调用serviceB的方法。我遇到了一个异常,好像端点没有可用的消费者。我假设一旦Service1启动,它就不会获取service2的实例,而service2需要使用@product annotation activemq endpoint进行初始化。同样的服务在其他正常场景中也可以正常工作

例外情况: 原因:org.apache.camel.camelException:端点上没有可用的使用者:端点[direct://ServiceB]. Exchange[消息:BeaniNotification public java.lang.String java.lang.Object.toString()带null]] 位于org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:46) 位于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**

//在Springbean加载期间将方法更改为自动触发
**bundle-context-camel.xml**


..............

或者,如果我需要达到这个要求,他们会采取其他方式吗?我可以在servicemix引导过程中自动加载服务(使用其他服务)。

您可以使用seda而不是direct,因为它基于队列,因此消费者可以来来往往

还可以尝试使用弹簧,具体取决于属性

<bean id="serviceA" depends-on="myCamel" .../>

<osgi:camelContext id="myCamel" ...>

我们尝试了上述方法,但仍然遇到异常,我们通过在服务初始化期间向onCamelContextStarted()添加一个侦听器来解决

谢谢
Ravi

如果您得到的是“端点上没有可用的消费者”,这意味着消息被路由到尚未初始化的端点。我建议使用JMS队列来分离服务。这样,serviceA可以将消息放入队列(独立于serviceB的可用性),serviceB可以在队列准备就绪时充当该队列的轮询消费者。

混淆后…serviceA/B与Service1/2??此外,您还有一个标记为“ActiveMQ端点”的“direct:ServiceB”端点……不确定您要做什么。解决这个问题,我们或许可以帮你。。。
         <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>
<bean id="serviceA" depends-on="myCamel" .../>

<osgi:camelContext id="myCamel" ...>