我正在尝试配置3个驼峰路由以使用相同的JMS组件。
问题是当我“不得不”在这些不同的路径中使用相同的组件时。当我这样做时,有时会出现一个错误,告知无法连接到ActiveMQ。这是因为并发吗?如果是,我想知道是否有可能立即配置这个组件,并在没有这种并发性的情况下使用它。
当我用不同的名称定义组件时,它是有效的。E、 g:amq1、amq2和amq3。
我正在使用:
代码:创建JMS组件的方法:
public JmsComponent createComponent() {
private ActiveMQJMSConnectionFactory connection;
connection = new ActiveMQJMSConnectionFactory(host, user, password);
connection.setMinLargeMessageSize(10000000);
return JmsComponent.jmsComponent(connection);
}
将组件添加到路由:
路线1:
@Component
public class Route1 extends RouteBuilder {
@Override
public void configure() throws Exception {
if (!getContext().getComponentNames().contains("amq")) {
getContext().addComponent("amq", createComponent());
}
from("amq:" + queue)
.routeId("Route1")
.to("mock:result");
}
}
路线2:
@Component
public class Route2 extends RouteBuilder {
@Override
public void configure() throws Exception {
if (!getContext().getComponentNames().contains("amq")) {
getContext().addComponent("amq", createComponent());
}
from("amq:" + queue)
.routeId("Route2")
.to("mock:result");
}
}
路线3:
@Component
public class Route3 extends RouteBuilder {
@Override
public void configure() throws Exception {
if (!getContext().getComponentNames().contains("amq")) {
getContext().addComponent("amq", createComponent());
}
from("timer:Test?period=2s")
.routeId("Route3")
.setBody(simple("test"))
.to("amq:" + queue);
}
}
AMQ经纪人接收器:
<acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61616?connectionTtl=60000;needClientAuth=true;supportAdvisory=false;anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
<acceptor name="amqp">tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true</acceptor>
<acceptor name="hornetq">tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true</acceptor>
<acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true</acceptor>
</acceptors>
错误:
Error processing exchange. Exchange[ID-op20190003-01-valenet-18-wlgfm-1560467581146-0-2]. Caused by: [org.springframework.jms.UncategorizedJmsException - Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Failed to create session factory; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]]
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Failed to create session factory; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:526)
at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:440)
at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:394)
at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:157)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197)
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:757)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:265)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:260)
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
... 26 common frames omitted
Caused by: org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException: AMQ119007: Cannot connect to server(s). Tried with all available servers.
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:784)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:755)
... 30 common frames omitted
您可以通过扩展DefaultCamelContext来创建自己的CamelContext,并在那里只创建一次组件。
@Component
class YourCamelContext extends DefaultCamelContext {
@PostConstruct
private void addStuff() {
addComponent("amq", createComponent());
...
问题内容: 我正在尝试使用单独的路线,但在我的React App中添加/编辑表单的组件相同,如下所示: 现在,在manageClient组件中,我解析查询参数(我在编辑路由中传递带有客户端ID的查询字符串),并根据传递的查询参数有条件地进行渲染。 问题在于这不会再次重新安装整个组件。假设打开了一个编辑页面,并且用户单击添加组件,URL发生了更改,但是该组件没有重新加载,因此保留在编辑页面上。 有办
我有一个Camel路由,它从jboss JMS队列读取消息发送到两个直接路由,其中一个直接路由成功地处理了消息并发送到另一个JMS队列,另一个直接路由处理消息失败。 我的期望是,原始交换移动到死信通道,第一个直接路由不应该提交,使用回滚将消息发送到JMS队列。 我尝试过许多可能性,但没有一个成功。下面我提供了骆驼路线。好心帮帮我。
我有一个camel Java DSL路由,它被定义为从队列中获取消息并将它们路由到Java处理器。路由定义了一些异常处理,它查找特定类型的异常,并在处理器抛出该异常时将消息放回队列中。我已经知道这条路由实际上是可行的,但是我想对这条路由进行正确的单元测试。 是否可以发布一个简单的基于Java DSL的示例来说明如何执行此操作?我从各种帖子中拼凑出一些建议,也许我应该使用camel占位符功能,用se
问题内容: 我有两个路线组,“动漫”和“漫画”。这些URL是/ anime/或/manga/,但它们都共享完全相同的控制器和模板 (唯一不同的是用于每个模板的配色方案,但这些颜色是在检查是否通过过滤器的过滤器中确定的)正在查看的特定项目是动漫还是漫画) : 动漫陈述定义: 漫画状态定义: 如您所见,其中已经有很多重复,我一点都不喜欢。随着我不断添加新路线,重复次数只会增加 (您已经可以看到mang
String postProcessor=“file: from(processFiles).threads(10).routeid(“someid”) .to(“bean:someBean”); 从(postProcessor).routeid(“PostProcress”).到(“bean:PostProcessorBean”); 解决方案已经到位。但目前需要更多的时间。因此,我们尝试在cam
我有一张地图,如下所示: