| Author | 
		  Message
		 | 
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 9:55 am    Post subject: Using MQ properties | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				I've been doing MQ for many years but trying to use message properties for the first time and I'm just trying to put a simple test case together.  The question here is where I set the property on the message.  I can set the property and put the message to the queue without any problems.  The problem is when I try to read it.
 
 
I get this exception:
 
java.io.IOException: MQJE088: Decoding failed ('MQMessag2.readConvertedString():MALFORMED[1]').
 
	at com.ibm.mq.MQMessage.readConvertedString(MQMessage.java:3030)
 
	at com.ibm.mq.MQMessage.readStringOfCharLength(MQMessage.java:1240)
 
	at com.mycompany.HeaderTest.receiveMessage(HeaderTest.java:71)
 
	at com.mycompany.HeaderTest.simpleTest(HeaderTest.java:2 
 
 
I'm sure I'm just missing something simple, but I cannot find any documentation on this online - I don't find a single legitimate hit for MQJE088 on Google.
 
 
 
   
	| Code: | 
   
  
	
 
   public void simpleTest() throws Exception {
 
      initialize();
 
      sendMessage();
 
      while(true) {
 
         receiveMessage();
 
      }
 
   }
 
   
 
   private void initialize() throws Exception {
 
   
 
      MQEnvironment.hostname = "myhostname";
 
      MQEnvironment.port = 1234;
 
      MQEnvironment.channel = "myChannel"; 
 
   
 
      qm = new MQQueueManager( "mqQmgr" );
 
      sendQueue = qm.accessQueue( 
 
               "myQueueName", 
 
               CMQC.MQOO_OUTPUT | CMQC.MQOO_FAIL_IF_QUIESCING );
 
      
 
      receiveQueue = qm.accessQueue(
 
               "myQueueName",
 
               CMQC.MQOO_INPUT_SHARED | 
 
               CMQC.MQOO_FAIL_IF_QUIESCING );
 
   }
 
   
 
   private void sendMessage() throws Exception {
 
      MQMessage mqMessage = new MQMessage();
 
      mqMessage.format = CMQC.MQFMT_STRING;
 
      mqMessage.messageId = CMQC.MQMI_NONE;
 
      
 
      MQPutMessageOptions pmo = new MQPutMessageOptions();
 
      pmo.options = CMQC.MQPMO_NO_SYNCPOINT;
 
      
 
 
      //  ------- THE OFFENDING LINE OF CODE ------------
 
      mqMessage.setStringProperty("headerName", "value");
 
      //  ------------------
 
 
      mqMessage.writeString( "This is a test");
 
      sendQueue.put(mqMessage, pmo);
 
   }
 
   
 
   private void receiveMessage() throws Exception {
 
      MQMessage mqMessage = new MQMessage();
 
      MQGetMessageOptions gmo = new MQGetMessageOptions();
 
      gmo.options = MQConstants.MQGMO_FAIL_IF_QUIESCING | MQConstants.MQGMO_NO_SYNCPOINT;
 
      gmo.options |= MQConstants.MQGMO_NO_WAIT;
 
      gmo.options |= MQConstants.MQGMO_PROPERTIES_IN_HANDLE;
 
      
 
      receiveQueue.get( mqMessage );
 
      
 
      String result = mqMessage.readStringOfCharLength(mqMessage.getTotalMessageLength());
 
      
 
      System.out.println( "message = " + result);
 
      Enumeration<String> props = mqMessage.getPropertyNames("%");
 
      while (props.hasMoreElements()) {
 
         String propertyName = props.nextElement();
 
         Object propValue = mqMessage.getObjectProperty(propertyName);
 
         System.out.println( 
 
            propertyName + 
 
            "(" + propValue.getClass().getName() + "): " + 
 
            propValue );
 
      }   
 
   }
 
 | 
   
 
[/code] | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| Code: | 
   
  
	 System.out.print( propertyName +
 
            "(" + propValue.getClass().getName() + ")"; 
 
System.out.println(": " + propValue ); | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:07 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				| I never get that far - it can't even get the message off the queue. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:23 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| ShagVT wrote: | 
   
  
	| I never get that far - it can't even get the message off the queue. | 
   
 
 
I couldn't tell which one was line 71.
 
 
if 
   
	| Code: | 
   
  
	| receiveQueue.get( mqMessage );  | 
   
 
 is actually the line that is failing,  then you need to (and should anyway) wrap that in something that explicitly catches an MQException.   Then you can get the MQCC and MQRC. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:42 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				| Sure - but this is just a test case, just trying to make this work at all.  It's not throwing an MQException though ... it's throwing an IOException, so there is no MQCC/MQRC. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:45 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| ShagVT wrote: | 
   
  
	| Sure - but this is just a test case, just trying to make this work at all.  It's not throwing an MQException though ... it's throwing an IOException, so there is no MQCC/MQRC. | 
   
 
 
 
Yes, ok.
 
 
WHERE?
 
 
Is it on the receiveQueue.get(), or is it 
   
	| Code: | 
   
  
	| String result = mqMessage.readStringOfCharLength(mqMessage.getTotalMessageLength());  | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 10:50 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				java.io.IOException: MQJE088: Decoding failed ('MQMessag2.readConvertedString():MALFORMED[1]'). 
 
 at com.ibm.mq.MQMessage.readConvertedString(MQMessage.java:3030) 
 
 at com.ibm.mq.MQMessage.readStringOfCharLength(MQMessage.java:1240) 
 
 at com.mycompany.HeaderTest.receiveMessage(HeaderTest.java:71) 
 
 at com.mycompany.HeaderTest.simpleTest(HeaderTest.java:2 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:01 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:09 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				Better!    
 
 
But still not quite right.     
 
 
   
	| Code: | 
   
  
	
 
      receiveQueue.get( mqMessage, gmo );
 
      
 
      String result = mqMessage.readStringOfCharLength(mqMessage.getTotalMessageLength());
 
      
 
      System.out.println( "message = [" + URLEncoder.encode(result) + "]");
 
 | 
   
 
 
 
I added the URLEncoder so I could paste the result.  I'm looking for "This is a test" (which what I get without setting the property).  However, with the property on there, I get this:
 
 
RFH+%00%00%00%02%00%00%00%60%00%00%01%11%00%00%033MQSTR+++%00%00%00%00%00%00%04%B8%00%00%008%3Cusr%3E%3CheaderName+dt%3D%22string%22%3Evalue%3C%2FheaderName%3E%3C%2Fusr%3E+++This+is+a+test | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:18 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				| Use getMessageLength() instead of getTotalMessageLength() | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:21 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				Same result ...
 
 
message = [RFH+%00%00%00%02%00%00%00%60%00%00%01%11%00%00%033MQSTR+++%00%00%00%00%00%00%04%B8%00%00%008%3Cusr%3E%3CheaderName+dt%3D%22string%22%3Evalue%3C%2FheaderName%3E%3C%2Fusr%3E+++This+is+a+test]
 
 
And then the while loop for the properties never executes.
 
 
Side note:  thank you for taking so much time to help with this! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:24 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				What you are seeing is that, for some reason, the message is coming back with an MQRFH2 header rather than message properties.
 
 
This could be for a few reasons.  Presumably you're not trying to talk to a queue manager that doesn't support message properties??
 
 
I would otherwise try reading the message data *after* you have printed out the properties. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 11:27 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| Presumably you're not trying to talk to a queue manager that doesn't support message properties?? | 
   
 
 
 
Well, how would I verify that?  It's WebsphereMQ ... I'm not sure if the QM is 6 or 7.  I'm using the 7.5.0.3 driver.[/quote] | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Tue Mar 10, 2015 12:51 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| ShagVT wrote: | 
   
  
	
   
	| Quote: | 
   
  
	| Presumably you're not trying to talk to a queue manager that doesn't support message properties?? | 
   
 
 
 
Well, how would I verify that?  It's WebsphereMQ ... I'm not sure if the QM is 6 or 7.  I'm using the 7.5.0.3 driver. | 
   
 
[/quote]
 
 
Look up the PROPCTL attribute, both in the settings and the v7.5 InfoCenter. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ShagVT | 
		  
		    
			  
				 Posted: Wed Mar 11, 2015 6:24 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 10 Mar 2015 Posts: 10
  
  | 
		  
		    
			  
				Name:        WebSphere MQ
 
Version:     6.0.2.8
 
CMVC level:  p600-208-090930
 
BuildType:   IKAP - (Production)
 
 
Does MQ 6.0 support message properties?  IBM documentation is so weak on things like this. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |