ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Send RFH2 message from JMS Example (with usr tags)

Post new topic  Reply to topic Goto page 1, 2  Next
 Send RFH2 message from JMS Example (with usr tags) « View previous topic :: View next topic » 
Author Message
espin
PostPosted: Fri Feb 18, 2011 12:20 am    Post subject: Send RFH2 message from JMS Example (with usr tags) Reply with quote

Newbie

Joined: 17 Feb 2011
Posts: 9

Hi friends, help me please.
I send RFH2 message from JMS:

Code:

            TextMessage outMessage = queueSession.createTextMessage();
 
                             
             outMessage.setStringProperty(WMQConstants.JMS_IBM_MQMD_FORMAT,"MQHRF2  ");
             outMessage.setStringProperty(WMQConstants.JMS_IBM_FORMAT,"MQSTR");
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_CODEDCHARSETID ,1208);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_ENCODING,273);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_EXPIRY,-1);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_MSGFLAGS,0);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_PRIORITY,4);
             outMessage.setStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET,"UTF8");
             outMessage.setIntProperty(WMQConstants.JMS_IBM_ENCODING,273);

             outMessage.setStringProperty("StrucId","RFH ");
             outMessage.setLongProperty("Version",2);
             outMessage.setLongProperty("StrucLength",0);
             outMessage.setLongProperty("Encoding",546);
             outMessage.setLongProperty( "CodedCharSetId",1208);

             outMessage.setStringProperty("Format","MQSTR");
             outMessage.setLongProperty("Flags",0);
             outMessage.setLongProperty("NameValueCCSID",1208);


            outMessage.setText(messsage.getBody());

            outMessage.setStringProperty("ID", messsage.getHandle());
            outMessage.setObjectProperty(WMQConstants.JMS_IBM_MQMD_MSGID, messsage.getHandle().getBytes());
            outMessage.setStringProperty("MessageId", messsage.getMsgId());
            outMessage.setStringProperty("SourceMessageType", "MType");
            outMessage.setStringProperty("SourceSystemCode", "System1");
            outMessage.setStringProperty("TargetSystemCode","System2");
            outMessage.setStringProperty("MessageRoute", "route1");

            queueSender.send(outMessage);


but java return error:
Code:

ERROR - JMS Error while transferring message

javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue

                at com.ibm.msg.client.wmq.v6.jms.internal.ConfigEnvironment.newException(ConfigEnvironment.java:374)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.sendInternal(MQMessageProducer.java:1236)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.send(MQMessageProducer.java:770)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.send(MQMessageProducer.java:2622)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.sendMessage(JmsMessageProducerImpl.java:893)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.send_(JmsMessageProducerImpl.java:748)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.send(JmsMessageProducerImpl.java:407)

                at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:300)

                at ru.croc.ursa.ibsoadapter.reader.AQReader.transferMessages(AQReader.java:99)

                at ru.croc.ursa.ibsoadapter.reader.AbstractReader.run(AbstractReader.java:305)

ERROR - Linked MQ exception

com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2334.

                at com.ibm.msg.client.wmq.v6.base.internal.MQQueue.putMsg2(MQQueue.java:2098)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.sendInternal(MQMessageProducer.java:1202)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.send(MQMessageProducer.java:770)

                at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageProducer.send(MQMessageProducer.java:2622)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.sendMessage(JmsMessageProducerImpl.java:893)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.send_(JmsMessageProducerImpl.java:748)

                at com.ibm.msg.client.jms.internal.JmsMessageProducerImpl.send(JmsMessageProducerImpl.java:407)

                at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:300)

                at ru.croc.ursa.ibsoadapter.reader.AQReader.transferMessages(AQReader.java:99)

                at ru.croc.ursa.ibsoadapter.reader.AbstractReader.run(AbstractReader.java:305)


Reason 2334 is MQRC_RFH_ERROR.

I read the book "WebSphere MQUsing Java Version 7.0 SC34" and not to understand what the problem is.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 18, 2011 2:01 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

JMS will build an RFH header for you. it's not clear why you're trying to build one yourself.

You also appear to have used setXXXProperty in several cases where you probably needed to use writeXXX instead.

And a few other things, probably, are wrong with your code.
Back to top
View user's profile Send private message
espin
PostPosted: Fri Feb 18, 2011 3:36 am    Post subject: Reply with quote

Newbie

Joined: 17 Feb 2011
Posts: 9

The same problem with BytesMessage

Code:

            BytesMessage outMessage = queueSession.createBytesMessage();
     
                                               

             outMessage.setStringProperty(WMQConstants.JMS_IBM_MQMD_FORMAT,"MQHRF2");
             outMessage.setStringProperty(WMQConstants.JMS_IBM_FORMAT,"MQSTR");
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_CODEDCHARSETID ,1208);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_ENCODING,273);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_EXPIRY,-1);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_MSGFLAGS,0);
             outMessage.setIntProperty(WMQConstants.JMS_IBM_MQMD_PRIORITY,4);
             outMessage.setStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET,"UTF8");
            outMessage.setIntProperty(WMQConstants.JMS_IBM_ENCODING,273);

           outMessage.setObjectProperty(WMQConstants.JMS_IBM_MQMD_MSGID, messsage.getHandle().getBytes());


            outMessage.writeBytes(messsage.getBody().getBytes());
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 18, 2011 4:00 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I repeat.

You do not need to build an RFH2 header in JMS.

You would not build an RFH2 header, that actually sits in the message body, by setting properties on the message. You would have to do it by writing data.

But, again, you do not need to build an RFH2 header in JMS.
Back to top
View user's profile Send private message
espin
PostPosted: Fri Feb 18, 2011 4:36 am    Post subject: Reply with quote

Newbie

Joined: 17 Feb 2011
Posts: 9

But IBM's documentation there is a picture which shows how to set the properties of "usr".

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj25430_.htm

Unfortunately there is no working example.
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Fri Feb 18, 2011 5:17 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

This picture shows what user properties on a JMSMessage map to 'automatically' - it in no way suggests that you build that header yourself.

Try removing all your other properties other than e.g. MessageRoute and see what happens.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Feb 18, 2011 5:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

espin wrote:
But IBM's documentation there is a picture which shows how to set the properties of "usr".


That link shows shows how JMS information is mapped onto the physical structure of the WMQ message; it's intended for the assistance of a non-Java application that's not using XMS to unwrap the message.

It has nothing to do with building a message. As my most worthy associate points out you don't need or want to build headers in a JMS application; the point of JMS is it does all this for you. The fact that some or all of the properties you're setting are being physically moved round in an RFH2 is irrelevant to you, but might be of interest to whoever's receiving the message.

Unless that's a JMS or XMS application in which case they won't care either.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
espin
PostPosted: Fri Feb 18, 2011 5:52 am    Post subject: Send simple RFH2 message from JMS Reply with quote

Newbie

Joined: 17 Feb 2011
Posts: 9

Then please give me a simple example of the formation of a very simple RFH2 message.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Feb 18, 2011 5:56 am    Post subject: Re: Send simple RFH2 message from JMS Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

espin wrote:
Then please give me a simple example of the formation of a very simple message.


There's a tool you might want to look into that a lot of people of this forum find useful. It's called "Google".

I tried "JMS setting user properties" and got a page full of hits. If you want something a bit more targetted, use the focused Google top right of this page.

You're asking a JMS question I know the answer to. That's how basic it is.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 18, 2011 5:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Code:
TextMessage outMessage = queueSession.createTextMessage();
outMessage.setStringProperty("hello","World");
outMessage.setText(messsage.getBody());
queueSender.send(outMessage);


Back to top
View user's profile Send private message
espin
PostPosted: Fri Feb 18, 2011 6:44 am    Post subject: Reply with quote

Newbie

Joined: 17 Feb 2011
Posts: 9

But since I get no MQHRF2 Message, and simply MQSTR
That is to send a message in a format RFH2 from JAVA to use JMS not.

If I found on Google just one example of the correct formation RFH2 tagged <usr> ....</ usr>, I would not ask this question here
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Feb 18, 2011 6:53 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20703
Location: LI,NY

espin wrote:
But since I get no MQHRF2 Message, and simply MQSTR
That is to send a message in a format RFH2 from JAVA to use JMS not.

If I found on Google just one example of the correct formation RFH2 tagged <usr> ....</ usr>, I would not ask this question here


Again this is basic JMS and WMQ. Look at the targetClient property of the Destination! (and set it to 0 or the appropriate constant)
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Fri Feb 18, 2011 6:55 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

espin wrote:
That is to send a message in a format RFH2 from JAVA to use JMS not.


If what you're trying to do is generate a message from a Java app, with an RFH2, using the native MQ Java methods not JMS then this a) explains why you're having problems and b) means you're crazy.

The reason you can't find any examples of this, and why we keep banging on about JMS, is that it's really tricky to do in native so most people don't. The RFH2 has specific formatting rules (which you'll find described in detail in the Application Programming Reference) and if you don't follow them all you end up with the 2334 header error you've encountered. This is one of the key reasons that XMS was developed for non-Java; it's no easier to manipulate the header in C++.

If you're determined to reinvent the wheel and produce an RFH2 in native Java, read the APR carefully, ensure all the fomatting rules are followed (especially the alignment) and good luck to you.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Feb 18, 2011 7:00 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

And both TextMessage and BytesMessage are JMS classes, so it's not clear why you're trying to use them if you're trying not to use JMS.

There is an old example of Java source code to build an MQRFH2 in the archives of this forum somewhere - it's probably about five years old by now.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Feb 18, 2011 7:06 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20703
Location: LI,NY

espin wrote:
I send RFH2 message from JMS:


And apparently unable to do so. So did you check the targetClient property on the Destination you are sending this message to?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » Send RFH2 message from JMS Example (with usr tags)
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.