【发布时间】:2020-10-16 17:25:42
【问题描述】:
我们正在尝试在 SericeMix 启动期间在加载捆绑包后立即调用 ServiceA。 Service2 具有 activemq 端点,我们需要调用该特定服务的方法。我尝试了 bean 标记中的 spring init-method 属性,这有助于自动触发 ServiceA 中的方法,我正在调用 serviceB 的方法。我得到了端点没有可用的异常之类的异常。我假设只要 Service1 启动,它就不会获得需要使用 @Produce 注释 activemq 端点初始化的 service2 的实例。相同的服务在其他正常情况下也能正常工作。
例外: 原因:org.apache.camel.CamelExchangeException:端点上没有可用的消费者:端点 [direct://ServiceB]。 Exchange[消息:BeanInvocation public java.lang.String java.lang.Object.toString() with 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**
//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 启动期间自动加载服务(使用其他服务)。
【问题讨论】:
-
令人困惑的帖子...ServiceA/B vs Service1/2??另外,您有一个标有“ActiveMQ 端点”的“direct:ServiceB”端点……不确定您要做什么。清理问题,我们可能会提供帮助......
标签: apache-camel apache-servicemix fuseesb