Question

Goal to connect to Hornteq and send a message to a queue and route it to a topic or queue and see the contents in the queue and topic after routing and before routing but am getting the error of :

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

Below is the description and output of the program. 2 Question :How can i use the Java DSL as i have used in the context-xml and send a queue to hornetq route it using camel process it and route to an output queue .I have done research but i am still a newbie on this your advice and help will be greatly appreciated... reason of this i will be able to use apache camel for all the integration with hornetq and not activemq. Am using a jndi connection to communicate to wildFly and within the context-xml i have the following

 <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>

And then i create the queues and topics using jboss-cli :

when i run the program which is Note i left the imports

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");
    }
}

i get the following output in the console

--- 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 

On the wildFly side it just outputs the following when i run the Program above.

14:28:17,117 INFO [org.jboss.as.naming] (default task-12) JBAS011806: Channel end notification received, closing channel Channel ID 62358a57 (inbound) of Remoting connection 78dd3e11 to /127.0.0.1:49754

Where am i going wrong ... kindly advice .

Was it helpful?

Solution

Make sure are you using the same version of HornetQ for Camel than for WildFly.

From the error, you are not using the same (it should be HornetQ 2.4.1.Final)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top