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 » Passing MQMD parameters using JMS.

Post new topic  Reply to topic Goto page 1, 2  Next
 Passing MQMD parameters using JMS. « View previous topic :: View next topic » 
Author Message
exp
PostPosted: Thu May 13, 2004 8:45 am    Post subject: Passing MQMD parameters using JMS. Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

We have a problem passing some MQMD header parameters,
"Format" specifically, as part of the JMS message.

The sender:
WebSphere 5.0 using JMS and WebSphere MQ.
The receiver:
A mainframe system with MQ but no JMS support..

Assuming 'message' is of type javax.jms.TextMessage:
1) message.setJMS* methods (that usually update the MQMD header)
don't support the "Format" feature as it's vendor-specific for IBM MQ.
2) when using
message.setStringProperty("Format", MQC.MQFMT_CICS);
the message is sent ok, received by the mainframe, but the Format
attribute is not what it's supposed to be (uses default).
3) when using
message.setStringProperty("JMS_IBM_Format", MQC.MQFMT_CICS);
the message doesn't even get sent (send() fails).

Any ideas on how to pass the "Format" parameter to the MQ ?

Thanks in advance.
Back to top
View user's profile Send private message
leongor
PostPosted: Tue May 18, 2004 11:53 pm    Post subject: Reply with quote

Master

Joined: 13 May 2002
Posts: 264
Location: Israel

You need to set property TARGCLIENT=MQ.
Also it's not enough to set MQMD.Format to MQC.MQFMT_CICS,
but you need to build it manually at the beginning of your message (MQCIH header).
_________________
Regards.
Leonid.

IBM Certified MQSeries Specialist.
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed May 19, 2004 5:05 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Take a look at the JmsIMSBridge.java program at

http://www.developer.ibm.com/tech/sampmq.html

It isn't quite what you are looking for, but I imagine that the concepts are the same between the two types of messages.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
shogan2003
PostPosted: Wed May 19, 2004 7:44 am    Post subject: Reply with quote

Centurion

Joined: 03 Jul 2003
Posts: 133
Location: London

Have you had any luck ? Seems no-one else knows; I'm in the same position and have yet to pin down a concrete example despite hours on Google.
_________________
MQSI2 certified specialist
MQSeries certified specialist
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu May 20, 2004 3:01 pm    Post subject: Reply with quote

Grand High Poobah

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

For the Format part : really easy:
Use a TextMessage in JMS and you have nothing to do.

Next part of the message:
Setup the JMSDestination property of your queue in JMS setup:
TargetClient="MQ"

Now if you have problems with translation try setting this JMS setup on the Remote queue to the Mainframe
JMSDestination property:
CCSID=500

Your java code does not change a iota.

If you don't want to use the JMS context lookup
but still want to use JMS add com.ibm.mqjms.jar to your classpath
use an MQQueueConnectionFactory (set qmgr attributes) and
try casting your queues to:
Queue myqueue = queueSession.createQueue("MQQNAME")
//from memory next 2 lines
((MQQueue) myqueue).setTargetClient(JMSC.>>>MQ_NONJMS);
((MQQueue) myqueue).setCSSID(500)

Enjoy
F.J.
Back to top
View user's profile Send private message Send e-mail
exp
PostPosted: Sat May 22, 2004 11:47 pm    Post subject: Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

First of all,
thanks to everyone who spent time addressing the problem.

Answer to leongor:
1)In admin console I'm already setting
WebSphere MQ JMS Provider > WebSphere MQ Queue Destinations > MyRequestQueue
Target Client: MQ
2)I'm aware of the fact that the Format property alone is not enough
for mainfame invocation.
However the CICS header is passed as part of the JMS message body
and not as part of MQMD.
The mainframe doesn't start reading the CICS header
unless specifically directed to do so by the MQMD Format value
(passing which - is my problem).

Answer to bower5932:
I've looked at the sample.
Their message.setStringProperty("JMS_IBM_Format", "MQIMS")
is very much like my message.setStringProperty("JMS_IBM_Format", MQC.MQFMT_CICS)

Answer to shogan2003:
I've spent hours with Google as well. Also opened a support request in IBM.
Hope to find a solution no less than you do.

Answer to fjb_saper:
1) I am already using TextMessage.
2) The Target Client is already set to MQ in the WebSphere destination queue configuration.
3) No problem with translation at this point as the mainframe is not even trying
to analyze the message body.
4) I thoght that after setting JMS/MQ configuration in the WebSphere
there's no need to do it in the code (setTargetClient(), ...)


//Used code sample:
//ASSUME queueConnectionFactoryJndi, requestQueueJndi,
// replyQueueJndi and requestText are defined.

InitialContext initialContext;
//WebSphere administered resources to be looked up in the InitialContext.
QueueConnectionFactory queueConnectionFactory;
Queue requestQueue, replyQueue;
//other variables:
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
TextMessage requestMessage;

initialContext = new javax.naming.InitialContext();
//init the factory using jndi:
queueConnectionFactory =
(QueueConnectionFactory)initialContext.lookup(
queueConnectionFactoryJndi));
//init the request queue:
requestQueue =
(Queue)initialContext.lookup(requestQueueJndi));
replyQueue =
(Queue)initialContext.lookup(replyQueueJndi));

//send the message:
//init the connection:
queueConnection = queueConnectionFactoryWork.createQueueConnection();
//init the session:
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
//init the sender:
queueSender = queueSession.createSender(requestQueueWork);
//init the request message beforoe sending it:
requestMessage = queueSession.createTextMessage();
requestMessage.setJMSReplyTo(replyQueueWork);//set the replyQueueWork as the queue from which we expect to receive the answer.
//compose requestMessage:
requestMessage.setJMSCorrelationIDAsBytes(MQC.MQCI_NEW_SESSION);

//PROBLEM {
requestMessage.setStringProperty("JMS_IBM_Format", MQC.MQFMT_CICS);
//or:
// requestMessage.setStringProperty("Format", MQC.MQFMT_CICS);
//} PROBLEM (neither way works)

requestMessage.setText(requestText);
//actually send the message:
queueSender.send(requestMessage);

//cleanup goes in here

////////////////////////////////////////////////////
Sending the message using "Format" works, but the Format received is not MQCICS.
Sending the message using "JMS_IBM_Format" fails. Relevant error parts are attached:

[11:43:35:028 IDT 18/05/04] 26d026d JMSManagedCon > connectionErrorOccurred
javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2142

[11:43:35:075 IDT 18/05/04] 26d026d ConnectionEve A J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adaptor for resource JMS$PdsQueueConnectionFactory. The exception which was received is javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun May 23, 2004 5:26 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Well,
Quote:
2142 X'085E' MQRC_HEADER_ERROR
An MQPUT or MQPUT1 call was issued, but the message data contains an MQ header structure that is not valid. Possible errors include the following:

The StrucId field is not valid.
The Version field is not valid.
The StrucLength field specifies a value that is too small.
The CodedCharSetId field is zero, or a negative value that is not valid.
The BufferLength parameter of the call has a value that is too small to accommodate the structure (the structure extends beyond the end of the message).
This reason code occurs in the following environments: AIX, HP-UX, Linux, z/OS, OS/2, OS/400, Solaris, Windows, plus WebSphere MQ clients connected to these systems.

Corrective action: Correct the definition of the WebSphere MQ header structure. Ensure that the fields are set correctly.


That's 2142 - as I'm sure you know.

So can we see the code where you are building the rest of the MQCICS header?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
exp
PostPosted: Tue May 25, 2004 11:41 am    Post subject: Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

Answer to jefflowrey:
Hi.
Here's the CICS header generated as part of the JMS message body.

//////////////////////////////////////////////////////////////////////
final static String S4 = " "; // 4 spaces
final static String S8 = " "; // 8 spaces
ByteArrayOutputStream outBytes = new ByteArrayOutputStream(180 + text.length());
DataOutputStream outData = new DataOutputStream(outBytes);

outData.writeBytes("CIH "); //MQCHAR strucId
outData.writeInt(2); //MQLONG version
outData.writeInt(180); //MQLONG strucLength
outData.writeInt(0); //MQLONG encoding
outData.writeInt(0); //MQLONG codedCharSetId
outData.writeBytes(S8); // MQCHAR format
outData.writeInt(0); //MQLONG flags
outData.writeInt(0); //MQLONG returnCode
outData.writeInt(0); //MQLONG compCode
outData.writeInt(0); //MQLONG reason
outData.writeInt(273); //MQLONG uOWControl
outData.writeInt(0); //MQLONG getWaitInterval
outData.writeInt(2); //MQLONG linkType
outData.writeInt(0); //MQLONG outputDataLength
outData.writeInt(0); //MQLONG facilityKeepTime
outData.writeInt(0); //MQLONG aDSDescriptor
outData.writeInt(0); //MQLONG conversationalTask
outData.writeInt(0); //MQLONG taskEndStatus
outData.writeBytes(S8); //MQBYTE facility
outData.writeBytes(S4); // MQCHAR function
outData.writeBytes(S4); // MQCHAR abendCode
outData.writeBytes(S8); // MQCHAR authenticator
outData.writeBytes(S8); // MQCHAR reserved1
outData.writeBytes(S8); // MQCHAR replyToFormat
outData.writeBytes(S4); // MQCHAR remoteSysId
outData.writeBytes("NR80"); // MQCHAR remoteTransId
outData.writeBytes(S4); // MQCHAR transactionId
outData.writeBytes(S4); // MQCHAR facilityLike
outData.writeBytes(S4); // MQCHAR attentionId
outData.writeBytes(S4); // MQCHAR startCode
outData.writeBytes(S4); // MQCHAR cancelCode
outData.writeBytes(S4); // MQCHAR nextTransactionId
outData.writeBytes(S8); // MQCHAR reserved2
outData.writeBytes(S8); // MQCHAR reserved3
//
outData.writeInt(0); //MQLONG cursorPosition
outData.writeInt(0); //MQLONG errorOffset
outData.writeInt(0); //MQLONG inputItem
outData.writeInt(0); //MQLONG reserved4
//
//
outData.writeString("SOME MESSAGE BODY");
outData.writeBytes(text);
outData.flush();

//Send the message using the inner (byte) stream:
send(outBytes.toString("8859_1"));
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue May 25, 2004 1:12 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
The CodedCharSetId field is zero, or a negative value that is not valid.

Quote:
outData.writeInt(0); //MQLONG codedCharSetId

Not sure about anything else, but that's a no-no.

Also, you aren't filling in a Format, so the recipent system won't be able to convert it to EBCDIC.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
exp
PostPosted: Wed May 26, 2004 2:40 am    Post subject: Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

Answer to EddieA:
Hi.
Thanks for a speedy reply.
You are probably right - I simply assumed MQ would take
default values for the CICS "codedCharSetId" and "format".
Till now I set ony application-critical CICS properties (relevant either to the sender component or the receiver one).
My assumption was that I can rely on the infrastructure to provide defaults for the rest.
Apparently not.
I'll give it a shot.
Thanks.
//
Thanks to jefflowrey as well.
Sorry I didn't read the MQRC_HEADER_ERROR with enough attention.
Back to top
View user's profile Send private message
EddieA
PostPosted: Wed May 26, 2004 4:52 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Look into: MQCCSI_INHERIT

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
exp
PostPosted: Wed Jun 02, 2004 5:59 am    Post subject: Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

Hi, everybody.
//
I've tried setting the CICS attributes as suggested:
codedCharSetId = -2; //MQCCSI_INHERIT
format = MQC.MQC.MQFMT_STRING;
It didn't help, message wasn't sent, same error (Reason 2142).
//
Then I tried changing the MQMD format to MQC.MQFMT_NONE
and sending the same message.
It worked. So MQMD is ok, CICS is not.
//
The only reasonable explanation: something is wrong or missing
in the CICS header.
Any ideas what should be done ?
Thanks in advance.
Back to top
View user's profile Send private message
EddieA
PostPosted: Wed Jun 02, 2004 7:06 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
I've tried setting the CICS attributes as suggested:
codedCharSetId = -2; //MQCCSI_INHERIT
format = MQC.MQC.MQFMT_STRING;

Where are you setting these.

You set the CCSID in the MQMD to MQCCSI_Q_MGR and Format to MQFMT_CICS. You then set the values you mention to the relevant fields in the CIH header.

Also, isn't it just: MQC.MQFMT_STRING.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jun 02, 2004 11:04 am    Post subject: Reply with quote

Grand High Poobah

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

As good practice, and I know JMS does not have much of helper classes for the different MQ Structures (DLQ, TMC2, etc...), I would suggest that you build your own helper class to format your header.
<br>Create your structure as a byte array, initialize it and provide setter and getter methods. When you are done you can just write the byte array to the message. It should make it more manageable for changes and easier on the eyes, + reusable ?
It will allow you as well to inspect it byte by byte in debug mode.

<br>The problem you are encountering here however is that for all purposes this is no longer a JMS Text message but becomes a BytesMessage as it needs the additionnal CICS header.
<br>
<br>The fact that the payload is text does not change the spec. I believe that JMS only recognizes the MQMD and RFH2 headers as being part of the JMS TextMessage..
Back to top
View user's profile Send private message Send e-mail
exp
PostPosted: Wed Jun 02, 2004 11:32 am    Post subject: Reply with quote

Newbie

Joined: 13 May 2004
Posts: 9

Answer to EddieA:
Hi.
1) I'm setting the MQMD "format" this way:
message.setStringProperty("JMS_IBM_Format", MQC.MQFMT_CICS);
where message is of type TextMessage.
2) I'm setting CICS "codedCharSetId" by writing an int value to the CICS part of the JMS message body:
outData.writeInt(-2); //MQLONG codedCharSetId
3) I'm setting CICS "format" by writing a String value to the CICS part of the JMS message body:
outData.writeBytes(MQC.MQFMT_STRING); // MQCHAR format
//
Now the question:
Did you mean CodedCharacterSetId (in jms: JMS_IBM_Character_Set)
when you suggested setting CCSID in the MQMD to MQCCSI_Q_MGR ?
This attribute is not set by our sender (so far).
I'll give it a shot, of course, but why is it important ?
What's wrong with the default value of CCSID in the MQMD header?
//
Thanks.
Back to top
View user's profile Send private message
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 » Passing MQMD parameters using JMS.
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.