目标连接到Hornteq并将消息发送到队列并将其路由到一个主题或队列,并在路由之后和路由之前查看队列和主题中的内容
但是出现以下错误:
Could not refresh JMS Connection for destination 'jmsinqueue' - retrying in 5000 ms. Cause: Failed to create session factory; nested exception is java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint
下面是程序的描述和输出.
2问题:如何使用我在context-xml中使用的Java DSL,并使用骆驼将其发送到hornetq路由队列,并将其路由到输出队列.我已经进行了研究,但我仍然是新手您的建议和帮助将不胜感激…
由于这个原因,我将能够使用apache骆驼与hornetq而不是activemq进行所有集成.
我正在使用jndi连接与wildFly进行通信,并且在context-xml中有以下内容
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
<prop key="java.naming.provider.url">http-remoting://localhost:8080</prop>
<prop key="java.naming.security.principal">testuser</prop>
<prop key="java.naming.security.credentials">password</prop>
</props>
</property>
</bean>
<bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>java:jms/RemoteConnectionFactory</value>
</property>
</bean>
<bean name="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
</bean>
<bean id="mylogger" class="org.apache.camel.component.log.LogComponent"/>
<bean id="logMessageOnTimerEvent"
class="com.naistech.camelhornetq.LogMessageOnTimerEventRouteBuilder"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="logMessageOnTimerEvent"/>
</camelContext>
<camel:camelContext id="context1">
<camel:route id="FirstRoute">
<!-- <camel:from uri="jms:queue:inputqueue"/>-->
<camel:from uri="jms:queue:jmsinqueue"/>
<camel:log logName="jmsLog" message="Got message from JMS queue:"/>
<camel:to uri="jms:topic:helloworld"/>
</camel:route>
</camel:camelContext>
</beans>
然后我使用jboss-cli创建队列和主题:
当我运行程序是
注意我离开了进口
public class SpringJavaDslApplication extends RouteBuilder {
public static void main(String[] args) throws InterruptedException, Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml");
applicationContext.start();
// let the Camel runtime do its job for 5 seconds
Thread.sleep(5000);
//----------------------------------------------------------------------
SimpleRegistry registry = new SimpleRegistry();
// add POJOs to the registry here using registry.put("name", <object reference>)
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("mylogger", new LogComponent());
context.addRoutes(new LogMessageOnTimerEventRouteBuilder());
context.start();
// let the Camel runtime do its job for 5 seconds
Thread.sleep(5000);
// shutdown
context.stop();
//----------------------------------------------------------------------
// shutdown
applicationContext.stop();
}
public void configure() throws Exception {
from("jms:queue:someQueue")
.to("jms:queue:someOtherQueue");
}
}
我在控制台中得到以下输出
--- exec-maven-plugin:1.2.1:exec (default-cli) @ camelHornetq-wildfly ---
2014-02-28 14:28:15,196 [main ] INFO ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6d4b8027: startup date [Fri Feb 28 14:28:15 EAT 2014]; root of context hierarchy
2014-02-28 14:28:15,243 [main ] INFO XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/camel-context.xml]
2014-02-28 14:28:16,441 [main ] INFO DefaultListableBeanFactory - Overriding bean definition for bean 'template': replacing [Generic bean: class [org.apache.camel.spring.CamelProducerTemplateFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.apache.camel.spring.CamelProducerTemplateFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-02-28 14:28:16,441 [main ] INFO DefaultListableBeanFactory - Overriding bean definition for bean 'consumerTemplate': replacing [Generic bean: class [org.apache.camel.spring.CamelConsumerTemplateFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.apache.camel.spring.CamelConsumerTemplateFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-02-28 14:28:16,518 [main ] INFO DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@35c5acda: defining beans [jndiTemplate,jmsQueueConnectionFactory,jms,mylogger,logMessageOnTimerEvent,camel-1:beanPostProcessor,camel-1,context1:beanPostProcessor,context1]; root of factory hierarchy
2014-02-28 14:28:16,606 [main ] INFO xnio - XNIO version 3.2.0.Final
2014-02-28 14:28:16,671 [main ] INFO nio - XNIO NIO Implementation Version 3.2.0.Final
2014-02-28 14:28:16,741 [main ] INFO remoting - JBoss Remoting version 4.0.0.Final
2014-02-28 14:28:17,131 [ndpoint" task-6] ERROR RemoteNamingStoreV1 - Channel end notification received, closing channel Channel ID e2358a57 (outbound) of Remoting connection 550661b8 to localhost/127.0.0.1:8080
2014-02-28 14:28:17,592 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is starting
2014-02-28 14:28:17,593 [main ] INFO ManagedManagementStrategy - JMX is enabled
2014-02-28 14:28:17,717 [main ] INFO DefaultTypeConverter - Loaded 176 type converters
2014-02-28 14:28:17,888 [main ] INFO SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2014-02-28 14:28:17,937 [main ] INFO SpringCamelContext - Route: route1 started and consuming from: Endpoint[timer://logMessageTimer?period=1s]
2014-02-28 14:28:17,949 [main ] INFO SpringCamelContext - Total 1 routes, of which 1 is started.
2014-02-28 14:28:17,954 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) started in 0.359 seconds
2014-02-28 14:28:17,958 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: context1) is starting
2014-02-28 14:28:17,958 [main ] INFO ManagedManagementStrategy - JMX is enabled
2014-02-28 14:28:17,979 [main ] INFO DefaultTypeConverter - Loaded 176 type converters
2014-02-28 14:28:18,039 [main ] INFO SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2014-02-28 14:28:18,103 [main ] INFO SpringCamelContext - Route: FirstRoute started and consuming from: Endpoint[jms://queue:jmsinqueue]
2014-02-28 14:28:18,111 [main ] INFO SpringCamelContext - Total 1 routes, of which 1 is started.
2014-02-28 14:28:18,112 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: context1) started in 0.153 seconds
2014-02-28 14:28:18,973 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-1, firedTime=Fri Feb 28 14:28:18 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:18,993 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:18 EAT 2014
2014-02-28 14:28:19,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-3, firedTime=Fri Feb 28 14:28:19 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:19,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:19 EAT 2014
2014-02-28 14:28:20,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-5, firedTime=Fri Feb 28 14:28:20 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:20,938 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:20 EAT 2014
2014-02-28 14:28:21,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-7, firedTime=Fri Feb 28 14:28:21 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:21,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:21 EAT 2014
2014-02-28 14:28:22,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-9, firedTime=Fri Feb 28 14:28:22 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:22,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:22 EAT 2014
2014-02-28 14:28:23,116 [mer[jmsinqueue]] INFO ultJmsMessageListenerContainer - JMS message listener invoker needs to establish shared Connection
2014-02-28 14:28:23,116 [main ] INFO DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-4) is starting
2014-02-28 14:28:23,116 [main ] INFO ManagedManagementStrategy - JMX is enabled
2014-02-28 14:28:23,117 [mer[jmsinqueue]] ERROR ultJmsMessageListenerContainer - Could not refresh JMS Connection for destination 'jmsinqueue' - retrying in 5000 ms. Cause: Failed to create session factory; nested exception is java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint
2014-02-28 14:28:23,343 [main ] INFO DefaultTypeConverter - Loaded 176 type converters
2014-02-28 14:28:23,374 [main ] INFO DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2014-02-28 14:28:23,399 [main ] INFO DefaultCamelContext - Route: route2 started and consuming from: Endpoint[timer://logMessageTimer?period=1s]
2014-02-28 14:28:23,403 [main ] INFO DefaultCamelContext - Total 1 routes, of which 1 is started.
2014-02-28 14:28:23,403 [main ] INFO DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-4) started in 0.287 seconds
2014-02-28 14:28:23,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-11, firedTime=Fri Feb 28 14:28:23 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:23,938 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:23 EAT 2014
2014-02-28 14:28:24,399 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-2-1, firedTime=Fri Feb 28 14:28:24 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:24,400 [logMessageTimer] INFO route2 - Event triggered by logMessageTimer at Fri Feb 28 14:28:24 EAT 2014
2014-02-28 14:28:24,936 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-13, firedTime=Fri Feb 28 14:28:24 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:24,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:24 EAT 2014
2014-02-28 14:28:25,399 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-2-3, firedTime=Fri Feb 28 14:28:25 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:25,400 [logMessageTimer] INFO route2 - Event triggered by logMessageTimer at Fri Feb 28 14:28:25 EAT 2014
2014-02-28 14:28:25,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-15, firedTime=Fri Feb 28 14:28:25 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:25,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:25 EAT 2014
2014-02-28 14:28:26,399 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-2-5, firedTime=Fri Feb 28 14:28:26 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:26,400 [logMessageTimer] INFO route2 - Event triggered by logMessageTimer at Fri Feb 28 14:28:26 EAT 2014
2014-02-28 14:28:26,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-17, firedTime=Fri Feb 28 14:28:26 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:26,937 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:26 EAT 2014
2014-02-28 14:28:27,400 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-2-7, firedTime=Fri Feb 28 14:28:27 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:27,400 [logMessageTimer] INFO route2 - Event triggered by logMessageTimer at Fri Feb 28 14:28:27 EAT 2014
2014-02-28 14:28:27,937 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-0-19, firedTime=Fri Feb 28 14:28:27 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:27,938 [logMessageTimer] INFO route1 - Event triggered by logMessageTimer at Fri Feb 28 14:28:27 EAT 2014
2014-02-28 14:28:28,118 [mer[jmsinqueue]] ERROR ultJmsMessageListenerContainer - Could not refresh JMS Connection for destination 'jmsinqueue' - retrying in 5000 ms. Cause: Failed to create session factory; nested exception is java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint
2014-02-28 14:28:28,400 [logMessageTimer] INFO insideTheRoute - Exchange[ExchangePattern: InOnly, Headers: {breadcrumbId=ID-naistech-53400-1393586897419-2-9, firedTime=Fri Feb 28 14:28:28 EAT 2014}, BodyType: null, Body: [Body is null]]
2014-02-28 14:28:28,400 [logMessageTimer] INFO route2 - Event triggered by logMessageTimer at Fri Feb 28 14:28:28 EAT 2014
2014-02-28 14:28:28,403 [main ] INFO DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-4) is shutting down
2014-02-28 14:28:28,404 [main ] INFO DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
2014-02-28 14:28:28,407 [ - ShutdownTask] INFO DefaultShutdownStrategy - Route: route2 shutdown complete, was consuming from: Endpoint[timer://logMessageTimer?period=1s]
2014-02-28 14:28:28,407 [main ] INFO DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
2014-02-28 14:28:28,412 [main ] INFO DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-4) uptime 5.295 seconds
2014-02-28 14:28:28,412 [main ] INFO DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-4) is shutdown in 0.008 seconds
2014-02-28 14:28:28,412 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutting down
2014-02-28 14:28:28,412 [main ] INFO DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
2014-02-28 14:28:28,413 [ - ShutdownTask] INFO DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[timer://logMessageTimer?period=1s]
2014-02-28 14:28:28,413 [main ] INFO DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
2014-02-28 14:28:28,416 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) uptime 10.826 seconds
2014-02-28 14:28:28,416 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutdown in 0.004 seconds
2014-02-28 14:28:28,416 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: context1) is shutting down
2014-02-28 14:28:28,416 [main ] INFO DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
2014-02-28 14:28:33,119 [ - ShutdownTask] INFO DefaultShutdownStrategy - Route: FirstRoute shutdown complete, was consuming from: Endpoint[jms://queue:jmsinqueue]
2014-02-28 14:28:33,119 [main ] INFO DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 4 seconds
2014-02-28 14:28:33,122 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: context1) uptime 15.164 seconds
2014-02-28 14:28:33,122 [main ] INFO SpringCamelContext - Apache Camel 2.12.2 (CamelContext: context1) is shutdown in 4.706 seconds
在wildFly方面,当我运行上述程序时,它仅输出以下内容.
14:28:17,117 INFO [org.jboss.as.naming](默认任务12)JBAS011806:接收到通道结束通知,关闭了将远程连接78dd3e11连接到/127.0.0.1:49754的通道通道ID 62358a57(入站)
我要去哪儿了…好建议.
解决方法:
确保您为驼峰使用的HornetQ版本与WildFly使用的版本相同.
由于错误,您使用的不是相同的文件(应该是HornetQ 2.4.1.Final)