MQSeries::Message::RFH2 -- Class to send/receive RFH2 messages


  use MQSeries::Message::RFH2;

  # Create an RFH2 message with default settings
  my $msg = MQSeries::Message::RFH2->new('NameValueData' => '<foo>bar</foo>', 'Data' => 'message with mydata');

  # Same while overriding the Flags and NameValue character set id
  my $msg2 = MQSeries::Message::RFH2->
    new('Header' => { 'NameValueCCSID' => 1200, # UCS-2
                      'Flags'          => 1,
                      'NameValueData' => '<foo>bar</foo>',
        'Data'   => $ucs2_data);

  # append another NameValueData Field

  # Same with an array as NameValueData
  my $msg3 = MQSeries::Message::RFH2->new('NameValueData' => ['<foo>bar</foo>','<test>value</test>'], 
                                          'Data' => 'message with mydata');

  # Get RFH2 data
  my $qmgr_obj = MQSeries::QueueManager->new(QueueManager => 'TEST.QM');
  my $queue = MQSeries::Queue->
    new(QueueManager => $qmgr_obj,
        Queue        => 'RFH2.DATA.QUEUE',
        Mode         => 'input');
  my $msg = MQSeries::Message::RFH2->new();
  $queue->Get(Message => $msg);
  my $data = $msg->Data();
  print "Have name-value data '$data'\n";


This is a simple subclass of MQSeries::Message which supports sending and retrieving RFH2 messages. This class is experimental, as it was based on the documentation and a few sample messages; feedback as to how well it works is welcome.

An RFH2 message contains an RFH2 header, followed by a data string with structured name-value data, in XML format.

NOTE: In MQ v7, you may receive what appear to be messages in RFH2 format, when you're really getting a message with message properties. If you're upgrading MQ v7, make sure you rebuild the module to get MQ v7 support; and make sure to set the queue PropertyControl attribute properly.



Add another string as NameValueData to the header or return the stored NameValueData strings

# add a string $msg->NameValueData('<test>another value</test>');

# return the first NameValueData string my $s = $msg->NameValueData();

# return all NameValueStrings my @s = $msg->NameValueData();

PutConvert, GetConvert

Neither of these methods are called by the users application, but are used internally by MQSeries::Queue::Put() and MQSeries::Queue::Get(), as well as MQSeries::QueueManager::Put1().

PutConvert() encodes the data supplied by the programmer into RFH2 format.

GetConvert() decodes the RFH2 header data and name-value pairs. transaction name and body.


An RFH2 message contains a number of numerical fields that are encoded based on the endian-ness of the queue manager. In most cases, that is the same endian-ness as the client (certainly if both run on the same machine), and this module uses that as the default.

If you need to override the guess made by this module, then you can invoke the _setEndianess method with 0 if server is little-endian (Linux/Intel, Windows NT) and 1 if server is big-endian (Solaris/SPARC).

For example, if you run on a Linux/Intel machine, but need to create a message for a queue manager running on Solaris:

  my $message = MQSeries::Message::RFH2->
    new('Data' => '<foo>bar</foo>');


Hildo Biersma, Tim Kimber, Peter Heuchert


MQSeries(3), MQSeries::QueueManager(3), MQSeries::Queue(3), MQSeries::Message(3)