|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  JPLUGIN creating RFH2 header? | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | ThomasTieke | 
		  
		    
			  
				 Posted: Thu Sep 25, 2003 1:19 am    Post subject: JPLUGIN creating RFH2 header? | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 25 Sep 2003 Posts: 2 Location: Germany, Frankfurt am Main 
  | 
		  
		    
			  
				Hello all!
 
 
I successfully built a plugin node that creates a message including "normal" MQMD and body elements. When I add the code for the RFH2 header, the MQPUT of the MQOutput node that takes the output of my plugin node fails with Reason Code = 2334 - "MQRC_RFH_ERROR
 
(2334, X’91E’) MQRFH or MQRFH2 structure not valid."
 
 
My code looks like this:
 
 
   
	| Code: | 
   
  
	
 
MbElement elemOut = elemOutRoot.getFirstElementByPath("/MQMD/Format");
 
elemOut.setValue("MQHRF2  ");
 
 
MbElement   rfh2 = elemOutRoot.getFirstElementByPath("/MQMD");
 
rfh2 = rfh2.createElementAfter(MbElement.TYPE_NAME);
 
rfh2.setName("MQRFH2");
 
setProperty(rfh2, "Version", 2);
 
setProperty(rfh2, "Format", "MQSTR   ");
 
setProperty(rfh2, "Encoding", encoding.intValue());
 
setProperty(rfh2, "CodedCharSetId", ccsid.intValue());
 
setProperty(rfh2, "Flags", 0);
 
setProperty(rfh2, "NameValueCCSID", 1208);
 
 
// helper methods ...
 
 
protected   MbElement   getcreateLastChild(MbElement elem, String name)
 
      throws   MbException
 
{
 
   return   getcreateLastChild(elem, name, MbElement.TYPE_NAME);
 
}
 
 
protected   MbElement   getcreateLastChild(MbElement elem, String name, int flag)
 
      throws   MbException
 
{
 
   MbElement   elemChild = elem.getFirstElementByPath("./" + name);
 
   if (null != elemChild)
 
      return   elemChild;
 
         
 
   elemChild = elem.createElementAsLastChild(flag);
 
   elemChild.setName(name);
 
 
   return   elemChild;
 
}
 
   
 
protected   MbElement   setProperty(MbElement elem, String name, byte[] value)
 
   throws   MbException
 
{
 
   MbElement   attribute = getcreateLastChild(elem, name, MbElement.TYPE_NAME_VALUE);
 
   attribute.setValue(value);
 
   return   attribute;
 
}
 
   
 
protected   MbElement   setProperty(MbElement elem, String name, String value)
 
   throws   MbException
 
{
 
   MbElement   attribute = getcreateLastChild(elem, name, MbElement.TYPE_NAME_VALUE);
 
   attribute.setValue(value);
 
   return   attribute;
 
}
 
   
 
protected   MbElement   setProperty(MbElement elem, String name, int value)
 
   throws   MbException
 
{
 
   MbElement   attribute = getcreateLastChild(elem, name, MbElement.TYPE_NAME_VALUE);
 
   attribute.setValue(new Integer(value));
 
   return   attribute;
 
}
 
 | 
   
 
 
 
I dumped the generated message tree (structure and values) and it looks exactly like the tree my custom node receives if the input message includes an RFH2 header.
 
 
-- Any ideas?
 
 
Thanks and _________________ Best Regards,
 
 
Thomas Tieke
 
Senior Consultant
 
 
Mummert Consulting AG | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Donald MacFarlane | 
		  
		    
			  
				 Posted: Wed Aug 04, 2004 2:57 am    Post subject: RFH2 header and jplugin | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 04 Aug 2004 Posts: 5 Location: Scotland 
  | 
		  
		    
			  
				Have you managed to fix this as I'm getting the same error and can't find out what is wrong with it. Have tried loads of things but am just about at the end of my tether.
 
 
Cheers Donald | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | ThomasTieke | 
		  
		    
			  
				 Posted: Wed Aug 04, 2004 3:46 am    Post subject: RFH2 header and jplugin | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 25 Sep 2003 Posts: 2 Location: Germany, Frankfurt am Main 
  | 
		  
		    
			  
				Hello Donald
 
 
Yes, I managed to get this running.
 
Maybe this code snippets will help you:
 
 
   
	| Code: | 
   
  
	
 
MbElement elemOut = elemOutRoot.getFirstElementByPath("/MQMD/Format");
 
elemOut.setValue("MQHRF2  "); // Note: not MQRFH2
 
 
MbElement rfh2 = elemOutRoot.getFirstElementByPath("/MQMD");
 
rfh2 = rfh2.createElementAfter("MQHRF2");   
 
 
// set version = 2 and so on
 
 
 | 
   
 
 
 
If you have a java plugin INPUT node, you'll probably have to add an ESQL node that fills all the mandatory MQMD fields like CorrelationID and so on.
 
 
Regards
 
Thomas Tieke | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Donald MacFarlane | 
		  
		    
			  
				 Posted: Wed Aug 04, 2004 5:19 am    Post subject: RFH2 header and jplugin | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 04 Aug 2004 Posts: 5 Location: Scotland 
  | 
		  
		    
			  
				Thanks for the info. I didn't know about being able to create other types of element so had just as MbElement.TYPE_NAME. Changing this to MQHRF2
 
has made all the difference. Would have been good if this had been documented somewhere
 
 
 
Thanks again 
 
 
Donald       | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	Page 1 of 1 | 
   
 
 
 
  
  	
	  
		
		  
 
  | 
		  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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |