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 API Support » Send values to MQMD: error

Post new topic  Reply to topic
 Send values to MQMD: error « View previous topic :: View next topic » 
Author Message
krustyelpayaso
PostPosted: Wed Jun 14, 2006 1:23 am    Post subject: Send values to MQMD: error Reply with quote

Apprentice

Joined: 24 Oct 2005
Posts: 26

Hi everybody ,

I'm newer into the "world of Java MQ" and i have a problem.
I have the next code:

Code:

try {
   long messageLength = xmlByteArray.length;


   // Set connection options...
   MQEnvironment.hostname = queueInfo.getHost();
   MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES_CLIENT);
   MQEnvironment.channel = queueInfo.getChannel();
   try {
      MQEnvironment.port = queueInfo.getPort();
   } catch (NumberFormatException e) {
      log.warn("Cannot parse mq port: using " + HxmQueueInfo.DEFAULT_PORT);
      MQEnvironment.port = HxmQueueInfo.DEFAULT_PORT;
   }
   try {
      MQEnvironment.CCSID = queueInfo.getCSSID();
      log.info("Set CCSID to " + queueInfo.getCSSID());
   } catch (NumberFormatException e) {
      log.warn("Cannot parse 'cssid': using " + HxmQueueInfo.DEFAULT_CSSID);
      MQEnvironment.CCSID = HxmQueueInfo.DEFAULT_CSSID;
   }

   // Open queue manager for writing...
   MQQueueManager qMgr = new MQQueueManager(queueInfo.getManager());
   int openOptions = MQC.MQOO_OUTPUT;
   MQQueue mqQueue = qMgr.accessQueue(queueInfo.getName(), openOptions, null, null, null);
   MQPutMessageOptions pmo = new MQPutMessageOptions();

   // Prepare message
   MQMessage message = new MQMessage();
   message.clearMessage();
   message.correlationId = MQC.MQCI_NONE; // Reset MessageID & CorrelationID
   message.messageId = MQC.MQMI_NONE;
   message.format = MQC.MQFMT_STRING;     // Set format to STRING
   
   String ApplicationName = "TOTO";
   message.putApplicationName = ApplicationName ;  // MQCHAR28      
   message.applicationIdData =  ApplicationName ;
   message.userId = ApplicationName;
   message.applicationOriginData = ApplicationName;
         
   message.priority = 0;                  // Set priority=0
   try {
      message.encoding = queueInfo.getEncoding();
      log.info("Set Encoding to " + queueInfo.getEncoding());
   } catch (NumberFormatException e) {
      log.warn("Cannot parse 'encoding': using " + HxmQueueInfo.DEFAULT_ENCODING);
      message.encoding = HxmQueueInfo.DEFAULT_ENCODING;
   }
   try {
      message.characterSet = queueInfo.getCSSID();
   } catch (NumberFormatException e) {
      log.warn("Cannot parse 'cssid': using " + HxmQueueInfo.DEFAULT_CSSID);
      message.characterSet = HxmQueueInfo.DEFAULT_CSSID;
   }
   message.write(xmlByteArray);
   xmlByteArray = null;
   System.gc();

   // Send message & close queue manager
   log.info("Put into queue a " + (messageLength / 1024) + " Kb message");

   //--pmo.options = MQC.MQPMO_NONE;         
   pmo.options = MQC.MQPMO_SET_ALL_CONTEXT;
         
   mqQueue.put(message, pmo);
   mqQueue.close();
   qMgr.disconnect();
         
   log.info("XML successfully sent to queue!");      

   } catch (MQException x) {
      throw new IOException(
         "Connection to MQSeries is broken on queue(manager/channel)@host:port\n"
                     + queueInfo.getName() + "(" + queueInfo.getManager() + "/"
                     + MQEnvironment.channel + ")@"
                     + MQEnvironment.hostname + ":" + MQEnvironment.port);
   }

}



I try to send to the MQMD header the value "TOTO". I've tried it with this code into differents variables.

String ApplicationName = "TOTO";
message.putApplicationName = ApplicationName ;
message.applicationIdData = ApplicationName ;
message.userId = ApplicationName;
message.applicationOriginData = ApplicationName;

I've read at the forum that i must change the options with the value MQC.MQPMO_SET_ALL_CONTEXT, because if i don't modify it (MQC.MQPMO_NONE) the differents variables will not be modify.

//--pmo.options = MQC.MQPMO_NONE;

pmo.options = MQC.MQPMO_SET_ALL_CONTEXT;

I run the code and an error appears

MQJE001: Completion Code 2, Reason 2095

If i change the code like this it goes OK: there's no error but the variables aren't changed

pmo.options = MQC.MQPMO_NONE;

//--pmo.options = MQC.MQPMO_SET_ALL_CONTEXT;

Can anybody help me?

A lot of thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jun 14, 2006 1:33 am    Post subject: Reply with quote

Grand High Poobah

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

If you look up Reason Code 2095 in any of the many & various places it can be looked up, you'll see it means MQRC_NOT_OPEN_FOR_SET_ALL.

From this you can deduce there's something wrong with the way the queue's been opened that inhibits the use of MQPMO_SET_ALL etc

Further hint - check out the context open options!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
krustyelpayaso
PostPosted: Wed Jun 14, 2006 5:01 am    Post subject: Reply with quote

Apprentice

Joined: 24 Oct 2005
Posts: 26

OK. I've found the trouble. Seems to work. Thanks very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Send values to MQMD: error
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.