我正在尝试在其中一个bean中使用POJO producing。消息传递有效,我可以将消息从bean中获取到我的camelcontext中。问题是我收到这些警告消息:
java.lang.IllegalStateException: ProducerTemplate has not been started
at org.apache.camel.impl.DefaultProducerTemplate.getProducerCache(DefaultProducerTemplate.java:685) ~[?:?]
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:163) ~[?:?]
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:159) ~[?:?]
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:142) ~[?:?]
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:172) ~[?:?]
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:382) ~[?:?]
at com.tcon.beansosgi.OpcuaBean.onSubscriptionValue(OpcuaBean.java:130) ~[14:com.tcon.beansosgi:1.0.0]
at com.tcon.beansosgi.OpcuaBean.lambda$null$0(OpcuaBean.java:52) ~[14:com.tcon.beansosgi:1.0.0]
at org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaMonitoredItem.lambda$setValueConsumer$1(OpcUaMonitoredItem.java:135) ~[254:org.eclipse.milo.sdk-client:0.3.3]
at org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaMonitoredItem.onValueArrived(OpcUaMonitoredItem.java:188) ~[254:org.eclipse.milo.sdk-client:0.3.3]
at org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscriptionManager.lambda$null$39(OpcUaSubscriptionManager.java:698) ~[254:org.eclipse.milo.sdk-client:0.3.3]
at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) [258:org.eclipse.milo.stack-core:0.3.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
我正在使用OSGi捆绑软件来部署我的blueprint.xml和相应的bean。为了进行部署,atm将生成的JAR文件放入Karaf的deploy文件夹中。我的deploy文件夹中还有一个features.xml文件,用于处理我的bean的第三方依赖关系。
这就是我使用POJO产生的方式:
@EndpointInject(uri = "direct:onSubscriptionValue")
static ProducerTemplate producer;
public static void onSubscriptionValue(UaMonitoredItem item, DataValue value) {
Pair<NodeId, DataValue> pair = new MutablePair<NodeId, DataValue>(item.getReadValueId().getNodeId(), value);
producer.sendBody(pair);
}
端点direct:onSubscriptionValue
在捆绑的blueprint.xml中:
<route id="onSubscriptionValue" startupOrder="200">
<from uri="direct:onSubscriptionValue"/>
<to uri="mock:subValue"/>
</route>
direct:onSubscriptionValue
没有使用者。 / li>
direct:onSubscriptionValue
的startupOrder设置为1 我还发现,如果我用我的deploy目录中的bundle JAR文件启动Karaf,则在触发pojo生产者之前必须执行bundle:restart,据我所知,这不会出现错误。这使我相信,我需要修改捆绑软件的启动顺序,以使其启动晚于所有其他捆绑软件,但是我读到,这在很大程度上被认为是不良设计的指标。如何确保我不会收到这些WARN消息?