4 Replies Latest reply on May 27, 2016 8:06 AM by ravi narayanan

    Issue while Remote Connection to Hornet queue from Switchyard .

    ravi narayanan Expert

      Hi All,

       

      I need to connect to a remote Hornet Queue in different server.

       

      I have the following configuratiuon.

       

      package com.example.switchyard.switchyard_example_MQ_Test2;

      import java.util.Properties;

      import javax.enterprise.inject.Produces;

      import javax.inject.Named;

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.resource.cci.ConnectionFactory;

       

      public class namedRemoteConnectionFactory {

       

       

        public namedRemoteConnectionFactory() {

        // TODO Auto-generated constructor stub

        }

       

        @Produces @Named("namedRemoteConnectionFactory")

        public ConnectionFactory create() {

           try {

               final Properties env = new Properties();

               env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

               env.put(Context.PROVIDER_URL, "remote://127.0.0.1:5445");

               env.put(Context.SECURITY_PRINCIPAL, "hornetquser1");

               env.put(Context.SECURITY_CREDENTIALS, "hornetqpwd.1");

               InitialContext ic = new InitialContext(env);

               return (ConnectionFactory) ic.lookup("java:jboss/exported/jms/RemoteConnectionFactory");

           }

           catch (Exception e) {

               e.printStackTrace();

               return null;

           }

        }

       

       

      }

       

      Switchyard XML:

       

      <sca:service name="ESBService" promote="Component/ESBService">

            <sy:interface.esb inputType="java.lang.String"/>

            <jms:binding.jms name="jms1">

              <jms:queue>SampleClusterQ</jms:queue>

              <jms:connectionFactory>#namedRemoteConnectionFactory</jms:connectionFactory>

            </jms:binding.jms>

          </sca:service>

       

       

      Iam getting error while doing deployment attached error logs and standlone-full-ha config xml.

       

      Caused by: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001305 The given type interface javax.jms.ConnectionFactory is not a type of the bean Producer Method [ConnectionFactory] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named public com.example.switchyard.switchyard_example_MQ_Test2.namedRemoteConnectionFactory.create()]

        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:633)

        at org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:391)

        at org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:200)

        at org.apache.camel.component.cdi.CdiBeanRegistry.lookup(CdiBeanRegistry.java:51)

        at org.apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:51)

        ... 34 more

        • 1. Re: Issue while Remote Connection to Hornet queue from Switchyard .
          Tomohisa igarashi Master

          The error message is saying that the namedRemoteConnectionFactory.create() doesn't return a javax.jms.ConnectionFactory while it should.

          • 2. Re: Issue while Remote Connection to Hornet queue from Switchyard .
            ravi narayanan Expert

            Hello,

            am I doing some thing wrong?why is it not returning connection factory.

            i Have attached code snippet and standalone configuration.

            • 3. Re: Issue while Remote Connection to Hornet queue from Switchyard .
              Tomohisa igarashi Master

              This is the culprit:

              import javax.resource.cci.ConnectionFactory;
              

               

              CCI ConnectionFactory is not compatible with JMS ConnectionFactory.

              • 4. Re: Issue while Remote Connection to Hornet queue from Switchyard .
                ravi narayanan Expert

                Hi,

                i have changed the connection factory as below and getting No bean could be found in the registry for: namedRemoteConnectionFactory of type: javax.jms.ConnectionFactory error while deployment .

                 

                package com.example.switchyard.switchyard_example_MQ_Test2;

                import java.util.Properties;

                import javax.enterprise.inject.Produces;

                import javax.inject.Named;

                import javax.jms.ConnectionFactory;

                import javax.naming.Context;

                import javax.naming.InitialContext;

                public class namedRemoteConnectionFactory {

                 

                 

                  public namedRemoteConnectionFactory() {

                  // TODO Auto-generated constructor stub

                  }

                 

                  @Produces @Named("namedRemoteConnectionFactory")

                  public ConnectionFactory create() {

                     try {

                         final Properties env = new Properties();

                         env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                         env.put(Context.PROVIDER_URL, "remote://127.0.0.1:5445");

                         env.put(Context.SECURITY_PRINCIPAL, "hornetquser1");

                         env.put(Context.SECURITY_CREDENTIALS, "hornetqpwd.1");

                         InitialContext ic = new InitialContext(env);

                         return (ConnectionFactory) ic.lookup("jboss/exported/jms/RemoteConnectionFactory");

                     }

                     catch (Exception e) {

                         e.printStackTrace();

                         return null;

                     }

                  }

                 

                 

                }

                 

                 

                13:59:46,493 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."switchyard-example-MQ-Test2-0.0.1-SNAPSHOT.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."switchyard-example-MQ-Test2-0.0.1-SNAPSHOT.jar".SwitchYardService: org.switchyard.SwitchYardException: org.apache.camel.FailedToCreateRouteException: Failed to create route V1CamelJmsBindingModel/ESBService@jms1#604016733: Route[[From[jms:queue:SampleClusterQ?connectionFactory=%23na... because of Failed to resolve endpoint: jms://queue:SampleClusterQ?connectionFactory=%23namedRemoteConnectionFactory due to: No bean could be found in the registry for: namedRemoteConnectionFactory of type: javax.jms.ConnectionFactory

                  at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:80)

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]

                  at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]