1 2 Previous Next 26 Replies Latest reply on Dec 4, 2013 11:32 AM by patrickawilson Go to original post
      • 15. Re: External JMS Reference - How?
        patrickawilson

        Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: ConsertGSConnectionFactory of type: javax.jms.ConnectionFactory

         

         

        In standalone-full.xml:

        <connection-factory name="ConsertGSConnectionFactory">

          <connectors>

            <connector-ref connector-name="netty"/>

          </connectors>

          <entries>

            <entry name="java:jboss/exported/jms/ConsertGSConnectionFactory"/>

          </entries>

        </connection-factory>

         

        So I do have something in standalone-full.xml in the <jms-connection-factories> section.

         

        I am running this over JBoss.  It looks like Switchyard wants to resolve this to a bean. 

        • 16. Re: Re: External JMS Reference - How?
          igarashitm

          I'm guessing you configured connectionFactory for the camel JMS binding like this:

          <connectionFactory>ConsertGSConnectionFactory</connectionFactory>
          

           

          where it should be (don't forget the "#" character):

          <connectionFactory>#jboss/exported/jms/ConsertGSConnectionFactory</connectionFactory>
          

           

          Please attach your application here if my guess is not legit.

          • 17. Re: External JMS Reference - How?
            patrickawilson

            Finally had a bit of a breakthrough.  I got the message to land on a local HornetQ queue.  This is valuable because it is something we had to do anyway and it proves that I have the Switchyard configs and injection correct.  Still need to get to an external queue.

             

            Some notes that might help[ others ...

            1. Thanks for the insight on the syntax: #jboss/exported/jms/ConsertGSConnectionFactory.  Now a question: how would I know that - i.e. what piece of documentation would tell me this?

             

            2. In the HornetQ manual I read that JCA is required for interaction with HornetQ in a container managed environment.  Since Switchyard runs on JBoss and HornetQ is running within JBoss, that would seem to indicate that JCA should be used and not JMS directly.  Is that correct or does the Switchyard framework take care of that if I specify a JMS binding on a reference?  Am using JCA but just curious.

             

            3. Does hornetq-jms.xml need to be deployed or is standalone-full.xml adequate?

            Answer: specifying the connection factory and queue under the HornetQ section in standalone-full.xml adequate is fine.  Do not specify in both or a duplicate definition error will result.  Have not yet tried using hornetq-jms.xml and not standalone-full.xml

             

            4. Syntax of hornetq-jms.xml is incorrect in docs.  The examples don't even parse properly.

            Answer: Format seems to have changed and is not properly defined in the HornetQ docs.  Found limited correct format on StackOverflow.

             

            5. Specifying a JMS queue in JBoss CLI:

            Again, docs seem out of date.

            [standalone@localhost:9999 /] jms-queue add --name=ConsertGSQueue --entries=queues/ConsertGSQueue

            Required argument '--queue-address' is missing.

             

            So what is queue-address?  This is what help says:

            --queue-address - corresponds to a property of the resource which is used to identify the resource against which the command should be executed.

             

            Based on more Googling it looks like --queue-address replaces --name.   Okay. 

            This works:

            jms-queue add --queue-address=ConsertGSQueue --entries=queues/ConsertGSQueue

             

            Thanks as always for your continued assistance.  Now to try to do what the topic says, connect to an external queue.

            • 18. Re: Re: External JMS Reference - How?
              igarashitm

              Congrats!

              1. Thanks for the insight on the syntax: #jboss/exported/jms/ConsertGSConnectionFactory.  Now a question: how would I know that - i.e. what piece of documentation would tell me this?

              Using '#' character for JNDI reference is the rule come from Apache Camel - Now I completely forget where it's described, sorry

              Note that JCA doesn't need '#' character.

               

              2. In the HornetQ manual I read that JCA is required for interaction with HornetQ in a container managed environment.  Since Switchyard runs on JBoss and HornetQ is running within JBoss, that would seem to indicate that JCA should be used and not JMS directly.  Is that correct or does the Switchyard framework take care of that if I specify a JMS binding on a reference?  Am using JCA but just curious.

              You can still use Camel JMS binding. ResourceAdapter for the JMS broker usually provides JNDI reference to the ConnectionFactory and Destination, which can be used with Camel JMS as well.

              • 19. Re: Re: External JMS Reference - How?
                patrickawilson

                Still trying to get past the last hurdle - sending a message to an external IBM MQ queue.

                 

                The fact that the target queue is IBM MQ should be completely meaningless.  A standard JMS message should be sufficient.  I am still trying to figure out the ins and outs of configuring a connection factory and queue definition that will connect to the target location.

                 

                Example:

                The host is defines as foo.bar.machine in our DNS which resolves to IP address 111.11.1111

                The port number is 12345

                The name of the queue is jms/queue_myqueue

                So I want to connect to 11.11.11.111:12345 and put a message onto jms/queue_myqueue

                 

                In standalone-full.xml

                Create a connector:

                                <connectors>

                                    <netty-connector name="ConsertOpsCenterConnector" socket-binding="messaging">

                                        <param key="host" value="11.11.11.1111"/>

                                        <param key="port" value="12345"/>

                                    </netty-connector>

                                </connectors>

                 

                Bind the connector to a connection factory:

                                    <connection-factory name="#jboss/exported/jms/ConsertOpsCenterConnectionFactory">

                                        <connectors>

                                            <connector-ref connector-name="ConsertOpsCenterConnector"/>

                                        </connectors>

                                        <entries>

                                            <entry name="java:jboss/exported/jms/ConsertOpsCenterConnectionFactory"/>

                                        </entries>

                                    </connection-factory>

                 

                Define the queue

                                    <jms-queue name="ConsertOpsCenterQueue">

                                        <entry name="jms/queue_myqueue"/>

                                    </jms-queue>

                 

                 

                In Switchyard.xml

                    <sca:reference name="ConsertOpsCenterService" multiplicity="0..1" promote="GenericGSCIMServiceBean/ConsertOpsCenterService">

                      <sca:interface.java interface="com.consert.switchyard.GSCIMSwitchyard.IConsertMQService"/>

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

                        <jms:contextMapper/>

                        <jms:queue>ConsertOpsCenterQueue</jms:queue>

                        <jms:connectionFactory>#jboss/exported/jms/ConsertOpsCenterConnectionFactory</jms:connectionFactory>

                        <jms:requestTimeout>2000</jms:requestTimeout>

                      </jms:binding.jms>

                    </sca:reference>

                • 20. Re: External JMS Reference - How?
                  igarashitm

                  Above configurations in the standalone-full.xml are HornetQ specific settings and do nothing against WebsphereMQ. You need to use WebsphereMQ ResourceAdapter. See the comment I posted before:

                  Re: External JMS Reference - How?

                  1 of 1 people found this helpful
                  • 21. Re: External JMS Reference - How?
                    patrickawilson

                    I guess I am surprised by that.  JMS is supposed to be a standard.  If I have a JMS client it should be able to send a JMS message to any JMS server - or at least that was my impression.  Surprised that I would need an adapter for each implementation.

                     

                    Anyhow looking into WebSphere MQ Resource adapter. 

                    • 22. Re: External JMS Reference - How?
                      igarashitm

                      JMS is just an API. The implementation detail and the communication protocol are vendor specific. You can switch the JMS provider without changing your application code, but you always need to use the client adapter which is dedicated to the JMS provider you are supposed to connect.

                      • 23. Re: External JMS Reference - How?
                        patrickawilson

                        Eight years ago when I was actively involved in JMS I thought that there was all sorts of talk about standardization of the underlying communications.  My recollection must be mistaken.  Oh well.

                         

                        As always, appreciate the help.  Any further tips on incorporating WebsphereMQ ResourceAdapter into Switchyard are appreciated.  Obviously I will be busy Googling but sometimes a good link can save a thousand clicks.  I have wmq.jmsra.rar extracted and deployed into my JBoss installation.  Not it's a matter of linking it all together.

                        • 24. Re: External JMS Reference - How?
                          patrickawilson

                          Edit:

                          Answer:

                          You only define a realm if you are creating an MDB to receive messages.  If you want to supply outgoing credentials you can set username and password as properties in the connection factory.

                           

                          Question (Answer above):

                          I have downloaded Websphere MQ resource Adapter.  Executing the jar unwraps it to give access to wmq.jmsra.rar.  I have wmq.jmsra.rar deployed in JBoss.

                           

                          I scrapped my JMS binding on the reference and went with JCA.  Inside the bean some good things are happening.  I am connecting to the proper host/port and the queue manager reference is being resolved.  It now fails due to an authentication error.  After working with our sys-admin to get a new set of credentials for the target queue I  am now trying to get the format of the authentication correct.

                           

                          In the <connection-definition>

                           

                          <security>
                          <security-domain>MyRealm</security-domain>
                          </security>

                           

                          Now I have to figure out how to configure MyRealm in standalone-full.xml.

                          • 25. Re: External JMS Reference - How?
                            patrickawilson

                            Edit: the answer to this one was relatively easy:

                            JCA - SwitchYard - Project Documentation Editor

                             

                            <jca:property name="messageType" value="Bytes"/>

                             

                            In context in switchyard.xml:

                            <sca:reference name="MyOutboundReference" multiplicity="0..1"

                            promote="MyBean/MyOutboundReference">

                            <sca:interface.java interface="com.consert.switchyard.MyDomain.iMyInterface"/>
                            <jca:binding.jca>
                            <jca:outboundConnection>
                            <jca:resourceAdapter name="wmq.jmsra.rar"/>
                            <jca:connection jndiName="java:jboss/MyConnectionFactory"/>
                            </jca:outboundConnection>
                            <jca:outboundInteraction>
                            <jca:processor type="org.switchyard.component.jca.processor.JMSProcessor">
                            <jca:property name="destination" value="java:jboss/MyQueue"/>
                            <jca:property name="messageType" value="Bytes"/>
                            </jca:processor>
                            </jca:outboundInteraction>
                            </jca:binding.jca>
                            </sca:reference>

                              </sca:composite>

                             

                             

                             

                             

                            Question (answer above)

                            Messages are being sent and received.  However, there is a class cast exception on the receiving side.  An object message is being sent instead of the expected bytes message.  The reason becomes apparent when I look at my interface:

                             

                            public interface MyInterface

                            {

                                public void send(byte[] payload);

                            }

                             

                            byte[] is an object, thus the ObjectMessage.

                             

                            What is not as readily apparent is how to get a BytesMessage out of Switchyard.  One cannot simply instantiate a BytesMessage.  It has to be created from the session which is generated from the connection ... which are both hidden by the Switchyard framework and WebSphere MQ resource Adapter.


                            So how does one do this?  I can see two possible options.

                            1. Change the interface:

                            public interface MyInterface

                            {

                                public void send(BytesMessage payload);

                            }

                             

                            In this scenario the interface changes fro bytes[] to a BytesMessage.  But how to create the BytesMessage?

                             

                            2. Somehow configure Switchyard to create a BytesMessage.

                             

                            3. Somehow configure WebSphere MQ resource Adapter to create a Bytes Message.

                            • 26. Re: External JMS Reference - How?
                              patrickawilson

                              Posting my Websphere MQ resource Adapter connection spec just in case it helps

                               

                              <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1"> 

                                  <resource-adapters>

                                      <resource-adapter>

                                          <archive>wmq.jmsra.rar</archive>

                                          <transaction-support>NoTransaction</transaction-support>

                                          <connection-definitions>

                                              <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl"

                                                  jndi-name="java:jboss/MyConnectionFactory"

                                                  pool-name="MyConnectionFactory">

                                                  <config-property name="hostName"> 

                                                      11.11.11.1111

                                                  </config-property> 

                                                  <config-property name="port"> 

                                                      12345

                                                  </config-property>

                                                  <config-property name="CCSID"> 

                                                      1208 

                                                  </config-property> 

                                                  <config-property name="channel">

                                                      MyQueueChannel

                                                  </config-property>

                                                  <config-property name="transportType">

                                                      CLIENT

                                                  </config-property>

                                                  <config-property name="queueManager">

                                                      MyQueueManager

                                                  </config-property>

                                                  <config-property name="username">

                                                      myMqUsename

                                                  </config-property>

                                                  <config-property name="password">

                                                      myMqPassword

                                                  </config-property>

                               

                                              </connection-definition>

                                          </connection-definitions>

                               

                                          <admin-objects>

                                               <admin-object

                                                  class-name="com.ibm.mq.connector.outbound.MQQueueProxy"

                                                  jndi-name="java:jboss/MyQueue"

                                                  pool-name="MyQueue">

                               

                                                  <config-property name="baseQueueName">

                                                      MyQueue

                                                  </config-property>

                                              </admin-object>

                                         </admin-objects>

                               

                                      </resource-adapter>

                                  </resource-adapters>

                              </subsystem> 

                              1 2 Previous Next