3 Replies Latest reply on Dec 27, 2007 3:55 AM by beve

    sending outbound message using NotifyQueues

    vikas_sm

      Hello All,

      I am trying to send an outbound message (ESB aware message)to Websphere MQ using NotifyQueues. All incoming message are sent to jboss messaging and are converted to ESB aware message by the gateway.


      After going through forums i found that there is no direct support to send outbound message using gateway in jbossesb-4.2.1GA(correct me if i am wrong) hence i am using notifier to send outbound message

      I am getting following exception :-



      org.jboss.soa.esb.notification.NotificationException: javax.jms.JMSException: MQJMS1044: String is not a valid hexadecimal number - JBM-53251
      at org.jboss.soa.esb.notification.NotifyJMS.sendNotification(NotifyJMS.java:302)
      at org.jboss.soa.esb.notification.NotificationList.notifyAll(NotificationList.java:164)
      at org.jboss.soa.esb.actions.Notifier.notifyOK(Notifier.java:93)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processSuccess(ActionProcessorMethodInfo.java:154)
      at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.processSuccess(OverriddenActionLifecycleProcessor.java:108)
      at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.notifySuccess(ActionProcessingPipeline.java:610)


      The reason for this exception from the MQCode is as followed

      MQJMS1044 String is not a valid hexadecimal number - {0}.

      Explanation: An attempt was made to specify a group ID or correlation ID which starts with the prefix "ID:" but is not followed by a well-formed hex value; or an attempt was made to receive a message which contains an RFH2 property of type bin.hex that does not have a well-formed hex value.
      User Response: Ensure that a valid hex value always follows the "ID:" prefix when setting group ID or correlation ID values. Ensure that any RFH2 headers generated by non-JMS applications are well-formed.


      I can see that the correlation Id generated by the gateway is not a valid hexidecimal value: . Please check the text in bold.

      header: [ To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/quickstart_helloworld_Request_esb/>, <wsa:ReferenceProperties jbossesb:java.nam
      ing.factory.initial : org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : jnp://127.0.0.1:1099/>, <ws
      a:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jboss.naming:org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type :
      queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ClusteredConnectionFact
      ory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : 1/> > ] MessageID: ID:JBM-53251 Relate
      sTo: jms:correlationID#ID:JBM-53760


      What is going wrong here?
      Any help will be appreciated.

      Thanks/Vikas

        • 1. Re: sending outbound message using NotifyQueues
          beve

          Hi Vikas,

          This is what the JMS Specification says about JMSCorrelationID and JMSMessageID message header field:


          3.4.5 JMSCorrelationID
          JMSCorrelationID can hold one of the following:
          * A provider-specific message ID
          * An application-specific String
          * A provider-native byte[] value
          ...
          Since each message sent by a JMS provider is assigned a message ID value, it is
          convenient to link messages via message ID. All message ID values must start
          with the 'ID:' prefix.


          3.4.3 JMSMessageID
          ...
          A JMSMessageID is a String value which should function as a unique key for
          identifying messages in a historical repository. The exact scope of uniqueness is
          provider defined. It should at least cover all messages for a specific installation
          of a provider where an installation is some connected set of message routers.
          All JMSMessageID values must start with the prefix 'ID:'. Uniqueness of
          message ID values across different providers is not required.


          So, what the ESB is doing is taking the JMSMessageID and setting it as the JMSCorrelationID of the outbound JMS Message.
          This is the default behaviour for the ESB but this can be overridden. I'll post back about how to override this, but I need to test this as I have only tried it for the JMSRouter.

          I can't find any referens in the spec that the field must be a valid hexadecimal number, but it seems that WebSphere expects the JMSCorrelationID to be a valid hexadecimal value. I found the following http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj25470_.htm:

          JMSCorrelationID to MQMD CorrelId, MQRFH2
          The JMSCorrelationID can hold one of the following:

          A provider specific message ID
          This is a message identifier from a message previously sent or received, and so should be a string of 48 hexadecimal digits that are prefixed with ID:. The prefix is removed, the remaining characters are converted into binary, and then they are set into the MQMD CorrelId field. No CorrelId value is encoded in the MQRFH2.


          Regards,

          Daniel

          • 2. Re: sending outbound message using NotifyQueues
            vikas_sm

            Hi Daniel,
            Thanks for detailed information and making the picture more clear.
            Could you send me the code changes that are required as mentioned by you?

            Any idea when will this change be avaialble in JBoss-ESB ?

            • 3. Re: sending outbound message using NotifyQueues
              beve

              Hey Vikas,

              I've tested this now and I used the helloworld_action quickstart.

              First step is to subclass NotifyQueues or NotifyTopics:

              public class NotifyQueuesCustom extends NotifyQueues
              {
               private Logger log = Logger.getLogger( NotifyQueuesCustom.class );
              
               public NotifyQueuesCustom (ConfigTree config)
               throws ConfigurationException, JMSException, ConnectionException
               {
               super(config);
               }
              
               @Override
               protected void setJMSProperties(
               org.jboss.soa.esb.message.Message fromESBMessage,
               Message toJMSMessage ) throws JMSException {
               log.debug(" setJMSProperties...do nothing.");
               }
              
              }
              

              Notice the overridden method setJMSProperties which just contains a log statement. By overriding this method the default behaviour is overridden.
              You can set any properties you wish on the outbound JMS Message object (toJMSMessage). So if you need to specify a custom JMSCorrelationID you can do that in this method.

              Next you need to specify that the above subclass should be used, which is specified in jboss-esb.xml:
              <NotificationList type="OK">
               <target class="NotifyConsole" />
               <target class="org.jboss.soa.esb.notification.NotifyQueuesCustom">
               <messageProp name="quickstart" value="hello_world_action" />
               <queue jndiName="queue/quickstart_helloworld_action_Response"/>
              </target>
              


              No code changes are needed for this to work.

              Let us know if you have any trouble getting this to work for you.

              Thanks,

              Daniel