spring - 无法刷新目标 'jmsinqueue' 的 JMS 连接 - 5000 毫秒后重试

标签 spring apache-camel hornetq spring-jms wildfly

目标连接到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 使用 Camel 处理它并路由到输出队列。我已经完成了研究,但我仍然是这方面的新手您的建议和帮助将不胜感激... 出于这个原因,我将能够使用 apache camel 与 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:收到 channel 结束通知,关闭 channel channel ID 62358a57(入站)远程连接 78dd3e11 到/127.0.0.1:49754

我哪里错了...请指教。

最佳答案

请确保您为 Camel 使用的 HornetQ 版本与为 WildFly 使用的版本相同。

从报错看,你用的不是同一个(应该是HornetQ 2.4.1.Final)

关于spring - 无法刷新目标 'jmsinqueue' 的 JMS 连接 - 5000 毫秒后重试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22095433/

相关文章:

jboss - hornetq如何持久化消息?

jakarta-ee - HornetQ:如何重用 XAConnection 和 XASession

tomcat - Tomcat 上的 HornetQ

java - Spring Boot - 不支持的主要.次要版本 51.0

spring - Mapstruct - 如何在 Generated Mapper 类中注入(inject) spring 依赖项

apache-camel - Apache Camel SFTP 零大小文件下载

scala 2.10,akka-camel TCP套接字通信

spring - Apache Camel Spring 配置错误 - 无法找到 XML 模式命名空间的 Spring NamespaceHandler [http ://camel. apache.org/schema/spring]

java - Spring Autowiring 的成员可见性

java - 发送 GET 请求时无法将类型 'java.lang.String' 的值转换为所需类型 'java.util.Date'