-
Notifications
You must be signed in to change notification settings - Fork 1
/
MQSeries.pm
714 lines (510 loc) · 24 KB
/
MQSeries.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
#
# $Id: MQSeries.pm,v 33.11 2012/09/26 16:10:13 jettisu Exp $
#
# (c) 1999-2012 Morgan Stanley & Co. Incorporated
# See ..../src/LICENSE for terms of distribution.
#
# This is intended to be a wrapper routine to include either the
# server or client library, based on the machine on which the code is
# running.
#
package MQSeries;
use 5.008;
use strict;
use Carp;
require Exporter;
require DynaLoader;
use MQSeries::Config::Machine;
our @ISA = qw(Exporter DynaLoader);
our $VERSION = '1.34';
our (@EXPORT, %EXPORT_TAGS);
BEGIN {
my $server;
if (exists $INC{"MQServer/MQSeries.pm"}) {
$server = 1;
} elsif (exists $INC{"MQClient/MQSeries.pm"}) {
$server = 0;
} else {
if ( $^O =~ /Win32/i ) { # Windows: check systemdir
no strict;
require "Win32/TieRegistry.pm";
import Win32::TieRegistry;
$Registry->Delimiter('/');
my $CurrentVersion = "LMachine/SOFTWARE/IBM/MQSeries/CurrentVersion/";
$server = 0;
my @sdir = ( $Registry->{"$CurrentVersion/FilePath"},
$Registry->{"$CurrentVersion/WorkPath"},
"C:/Mqm");
foreach my $try (@sdir) {
my $systemdir = $try . q{/qmgrs/@SYSTEM};
if (-d $systemdir) {
$server = 1;
last;
}
}
} else { # Unix: check systemdir and mqs.ini
eval {
my $mqMachine = MQSeries::Config::Machine->new();
if (keys %{$mqMachine->localqmgrs}) { # If any local qmgrs...
$server = 1;
} else {
$server = 0;
}
};
unless (defined $server) {
my $systemdir = q{/var/mqm/qmgrs/@SYSTEM};
if (-d $systemdir) {
$server = 1;
} else {
$server = 0;
}
}
}
}
if ($server) {
require "MQServer/MQSeries.pm";
import MQServer::MQSeries;
*EXPORT = *MQServer::MQSeries::EXPORT;
*EXPORT_TAGS = *MQServer::MQSeries::EXPORT_TAGS;
$MQSeries::Mode = "Server";
} else {
require "MQClient/MQSeries.pm";
import MQClient::MQSeries;
*EXPORT = *MQClient::MQSeries::EXPORT;
*EXPORT_TAGS = *MQClient::MQSeries::EXPORT_TAGS;
$MQSeries::Mode = "Client";
}
}
1;
__END__
=head1 NAME
MQSeries - Perl extension for MQSeries support
=head1 SYNOPSIS
There are two interfaces provided by the MQSeries modules. The first
is a straight forward mapping to all of the individual MQI calls, and
the second is a value-added, OO interface, which provides a simpler
interface to a subset of the full MQI functionality.
The straight MQI mapping is:
use MQSeries;
$Hconn = MQCONN($Name,$CompCode,$Reason);
MQDISC($Hconn,$CompCode,$Reason);
$Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
MQCLOSE($Hconn,$Hobj,$Options,$CompCode,$Reason);
MQBACK($Hconn,$CompCode,$Reason);
MQCMIT($Hconn,$CompCode,$Reason);
$Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);
MQPUT($Hconn,$Hobj,$MsgDesc,$PutMsgOpts,$Msg,$CompCode,$Reason);
MQPUT1($Hconn,$ObjDesc,$MsgDesc,$PutMsgOpts,$Msg,$CompCode,$Reason);
($Attr1,...) = MQINQ($Hconn,$Hobj,$CompCode,$Reason,$Selector1,...);
MQSET($Hconn,$Hobj,$CompCode,$Reason,$Selector1,$Attr1,...);
If the perl5 API is compiled with the version 5 headers and libraries,
then the following MQI calls are also available:
MQBEGIN($Hconn,$BeginOpts,$CompCode,$Reason);
$Hconn = MQCONNX($Name,$ConnectOpts,$CompCode,$Reason);
There are also some additional utility routines provided which
are not part of the MQI, but specific to the perl5 API:
($ReasonText,$ReasonMacro) = MQReasonToStrings($Reason);
($ReasonText) = MQReasonToText($Reason);
($ReasonMacro) = MQReasonToMacro($Reason);
The OO interface is provided in several optional modules. Three of
these make up the core OO interface:
MQSeries::QueueManager
MQSeries::Queue
MQSeries::Message
There are several subclasses of MQSeries::Message which handle special
message formats:
MQSeries::Message::Storable
MQSeries::Message::Event
MQSeries::Message::PCF
MQSeries::Message::DeadLetter
There is also a module which provides an interface to the command
server PCF messages for MQSeries administration:
MQSeries::Command
There are two sets of classes that help you follow (tail C<-f> style) and
parse the two kinds of log-files written by MQSeries: the FDC files
and the error-logs. These classes allow you to write a log monitoring
daemon that feeds into syslog or your system management tools.
MQSeries::ErrorLog::Tail
MQSeries::ErrorLog::Parser
MQSeries::ErrorLog::Entry
MQSeries::FDC::Tail
MQSeries::FDC::Parser
MQSeries::FDC::Entry
There is a set of classes that parses configuration and authority
files (/var/mqm/mqs.ini, /var/mqm/qmgrs/*/qm.ini,
/var/mqm/qmgrs/*/auth/*/*).
MQSeries::Config::Authority
MQSeries::Config::Machine
MQSeries::Config::QMgr
Some internal helper functions are stored in the module:
MQSeries::Utils
See the documentation for each of these individual modules for more
information.
=head1 DESCRIPTION
This module provides a perl language interface to MQSeries
functions. It uses the standard MQSeries interface except where a perl
convention is required or just more useful.
Where data structures are required, this interface uses a hash
reference. The keys in the hash are structure element names. If an
element is not specified in the hash, a default value will be
used. Output elements are updated in the hash as necessary.
=head2 Basic Module Usage
By default, this module will export all functions and MQSeries
constants into the caller's namespace. This may bloat that module's
memory usage by some 400 Kbyte. For that reason, you can also request
to only export the functions. To use macros, you would then either
import them individually or refer to them using the MQSeries:: prefix.
This leads to the following C<use> statements:
=over 4
=item use MQSeries;
The default: export functions and constants.
=item use MQSeries qw(:functions);
Export just the functions. This should be the way most modules
import MQSeries, as it saves 400Kbyte per module importing MQSeries.
In order to use a macro, e.g. C<MQCC_FAILED>, you could either add it to the
list on the C<use> statement, or refer to C<MQSeries::MQCC_FAILED>.
=item use MQSeries qw(:constants);
Export just the constants; not very useful.
=item use MQSeries qw(:all);
The same as the default: export functions and constants.
=back
=head2 Server vs. Client API
Compiled MQSeries applications, such as those written in C or C++,
have to decide at compile/link time which of the two API styles to
use: server (shared memory, same host) or client (TCP/IP, same or
remote host). Perl applications can make this decision at runtime,
dynamically.
By default, the MQSeries module will try to dynamically determine
whether or not the localhost has any queue managers installed, and if
so, use the "server" API, otherwise, it will use the "client" API.
This will Do The Right Thing (tm) for most applications, unless you
want to connect directly to a remote queue manager from a host which
is running other queue managers locally. Since the existence of
locally installed queue managers will result in the use of the
"server" API, attempts to connect to the remote queue managers will
fail with a Reason Code of 2058.
To workaround this problem, you can force the use of either the server
or client API explictly by using one of the following use statements.
=over 4
=item use MQClient::MQSeries;
This will force the use of the client API, regardless of whether or
not there are queue managers on the localhost.
=item use MQServer::MQSeries;
This will force the use of the server API, and thus only allow
connections only to queue managers on the same machine. This normally
is not necessary, since the API should detect existence of local queue
manager and default to this flavor of access.
The author uses this in one and only one special case: the automated
script that installs a queue manager, and then customizes it. When
the script first runs, there is usually no local queue manager, but it
will need to connect to it using the server API once it is created.
=back
Of course, you can combine the various import options, for example the
following is perfectly valid:
use MQClient::MQSeries qw(:functions);
B<NOTE>: The perl API, when compiled and installed, will normally
build both the server and client extensions, but on some platforms one
or the other is not available. For example, we currently only support
the client API on IRIX, and only the server API on OS/390. Whether or
not the server and/or client options are even available depends on how
the MQSeries perl API was compiled and installed. Consult your
administrator (or whoever built this extension) for such details.
=head1 SUBROUTINES
For complete details on each of the following subroutines, please
consult the "MQSeries Application Programming Guide" and "MQSeries
Application Programming Reference". This documentation will merely
document how the perl API and the underlying C API calling and return
code conventions vary.
One way in which all of these calls are identical to the C API is in
the use of the '$CompCode' and '$Reason' conventions. All of the API
calls take these as positional arguments, and the completion code and
reason code are written to those variables, respecitively.
In general, all of the C data structures used to pass or return values
to each API call are passed or returned as a perl hash reference,
specified as a positional argument in the relavent API call.
=head2 MQCONN
$Hconn = MQCONN($Name,$CompCode,$Reason);
This call returns the Hconn value, to be used in subsequent MQI calls.
The C API took the $Hconn as a positional parameter, whereas the perl
API returns it.
=head2 MQCONNX
$Hconn = MQCONNX($Name,$ConnectOpts,$CompCode,$Reason);
NOTE: This MQI call is only available if the perl5 API is compiled
against MQSeries version 5 headers and libraries.
This call returns the Hconn value, to be used in subsequent MQI calls.
The C API took the $Hconn as a positional parameter, whereas the perl
API returns it.
The $ConnectOpts value is a hash reference, with keys corresponding to
the fields of the MQCO structure. This is an input value only.
With the $ConnectOpts, two interior data structures can be provided:
C<ClientConn> and C<SSLConfig>. These provide access to the C<MQCNO>
and C<MQSCO> options. The two data structures can be used
independently; and example of them used in combination is shown below:
$coption = { 'ChannelName' => 'Some.Channel.Name',
'TransportType' => 'TCP',
'ConnectionName' => 'hostname(port)',
};
$ssl_option = { 'KeyRepository' => '/var/mqm/ssl/key' };
$Hconn = MQCONNX($qmgr_name, { 'ClientConn' => $coption,
'SSLConfig' => $ssl_option,
}, $cc, $re);
See the application programming reference for details on the
additional fields available in the C<ClientConn> data structure.
=head2 MQDISC
MQDISC($Hconn,$CompCode,$Reason);
The calling convention of this subroutine is identical to the C API.
=head2 MQOPEN
$Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
In the same way that MQCONN loses one positional parameter, and
returns it to the caller, so does MQOPEN remove the $Hobj parameter
from the argument list and returns the value.
The $ObjDesc parameter should be a hash reference, for example:
$ObjDesc = {
ObjectName => 'SOME.MODEL.QUEUE',
DynamicQName => 'FOOBAR*',
};
The $Options parameter should be a set of ORed options, for example:
$Options = MQOO_INPUT_AS_Q_DEF | MQOO_FAIL_IF_QUIESCING;
If a distribution list is being opened, then the list of queues can be
specified in one of three ways. The list is given via a new key
"ObjectRecs", used to identify the list. This is different from the
C-centric approach in the C API, namely to specify the list using the
RecsPresent, ObjectRecPtr, etc.
The first method is to specify an array of plain queue names:
$ObjDesc = {
ObjectRecs => [qw( QUEUE1 QUEUE2 QUEUE3 )],
};
The second method is to specify an array or array references, each
giving the QName and QMgrName:
$ObjDesc = {
ObjectRecs => [
[qw( QUEUE1 QM1 )],
[qw( QUEUE2 QM2 )],
[qw( QUEUE3 QM3 )],
],
};
Finally, an array of hash references can be specified, each giving the
QName and QMgrName via specific keys:
$ObjDesc = {
ObjectRecs => [
{
ObjectName => 'QUEUE1',
ObjectQMgrName => 'QM1',
},
{
ObjectName => 'QUEUE2',
ObjectQMgrName => 'QM2',
},
{
ObjectName => 'QUEUE3',
ObjectQMgrName => 'QM3',
},
],
};
In the second and third cases, the queue manager names are always
optional. Which method to use is largely a matter of style.
When the Reason Code returned by the API is MQRC_MULTIPLE_REASONS,
then these are encoded into an array of hash references, and that
array is returned as a new key in the ObjDesc hash, "ResponseRecs".
The order of the CompCode/Reason pair in the array corresponds to the
order of the queues listed in the ObjectRecs array.
This is best explained in an example. In this case, we used the
first, simple list of queue names for our distribution list.
if ( $Reason == MQRC_MULTIPLE_REASONS ) {
for ( $index = 0 ; $index <= scalar @{$ObjDesc->{ObjectRecs}} ; $index++ ) {
next if $ObjDesc->{ResponseRecs}->[$index]->{Reason} == MQRC_NONE;
print "QName: " . $ObjDesc->{ObjectRecs}->[$index] . "\n";
print "Reason: " . $ObjDesc->{ResponseRecs}->[$index]->{Reason} . "\n";
print "CompCode: " . $ObjDesc->{ResponseRecs}->[$index]->{CompCode} . "\n";
}
}
=head2 MQCLOSE
MQCLOSE($Hconn,$Hobj,$Options,$CompCode,$Reason);
The calling convention of this subroutine is identical to the C API.
The $Options value is a set of ORed options, for example:
$Options = MQCO_DELETE_PURGE;
=head2 MQBEGIN
MQBEGIN($Hconn,$BeginOpts,$CompCode,$Reason)
NOTE: This MQI call is only available if the perl5 API is compiled
against MQSeries version 5 headers and libraries.
The calling convention of this subroutine is identical to the C API.
The $BeginOpts value is a hash reference, with keys corresponding to
the fields of the MQBO structure. This is both an input and output value.
=head2 MQBACK
MQBACK($Hconn,$CompCode,$Reason);
The calling convention of this subroutine is identical to the C API.
=head2 MQCMIT
MQCMIT($Hconn,$CompCode,$Reason);
The calling convention of this subroutine is identical to the C API.
=head2 MQGET
$Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);
One positional parameter, the $Buffer, is removed from the argument
list. This is the return value of this subroutine. The $MsgDesc and
$GetMsgOpts values are hash references. The $MsgDesc will be
populated with the MQMD structure returned by the MQGET call. This is
also an input value, and the $MsgDesc data can be populated, for
example, with a specific 'CorrelId'.
$MsgDesc = {
CorrelId => $correlid,
};
The $GetMsgOpts hash reference contains the MQGMO data structure
fields, for example:
$GetMsgOpts = {
Options => MQGMO_FAIL_IF_QUIESCING | MQGMO_SYNCPOINT | MQGMO_WAIT,
WaitInterval => MQWI_UNLIMITED,
};
=head2 MQPUT, MQPUT1
MQPUT($Hconn,$Hobj,$MsgDesc,$PutMsgOpts,$Msg,$CompCode,$Reason);
MQPUT1($Hconn,$ObjDesc,$MsgDesc,$PutMsgOpts,$Msg,$CompCode,$Reason);
Both of these calls differ from the C API in the same way as MQGET.
Likewise, the $MsgDesc and $PutMsgOpts values are hash references for
the appropriate data structures.
If MQPUT1() is being used to put a message to a distribution list,
then the $ObjDesc is used in the same way as documented above for
MQOPEN(). In addition, there is a special key to the $PutMsgOpts hash
which can be specified, and the rest of this discussion applies
equally to both MQPUT() and MQPUT1().
The $PutMsgOpts->{PutMsgRecs} value must be an array of hash
references, one for each queue opened in the distribution list,
interpreted in the same order. Each individual hash reference is
interpreted as a single put message record. The keys of each record
can be any of:
MsgId
CorrelId
GroupId
Feedback
AccountingToken
For example, the following sets the CorrelId the same across all of
the messages in a distribution list of three queues.
$PutMsgOpts = {
PutMsgRecs => [
{
MsgId => MQPMO_NEW_MSG_ID,
CorrelId => $SomeCorrelId,
},
{
MsgId => MQPMO_NEW_MSG_ID,
CorrelId => $SomeCorrelId,
},
{
MsgId => MQPMO_NEW_MSG_ID,
CorrelId => $SomeCorrelId,
},
],
};
Note that the following fields of the $PutMsgOpts hash do not need to
be specified:
PutMsgRecFields (calculated automatically)
PutMsgRecOffset
PutMsgRecPtr
ResponseRecPtr
ResponseRecOffset
For the MQPUT() call, if the Reason code returned is
MQRC_MULTIPLE_REASONS, then these are returned as part of the
$PutMsgOpts hash, in the key ResponseRecs. For the MQPUT1() call,
these are returned as part of the $ObjDesc hash.
See the MQOPEN() documentation above for the format of this value.
=head2 MQINQ
($Attr1,...) = MQINQ($Hconn,$Hobj,$CompCode,$Reason,$Selector1,...);
This call differs from the C API significantly. Rather than passing a
list of pairs of selectors and attributes, only a list of selectors is
passed. The return value is a list of attributed. The C API
convention was simply to pass the address for each answer in the
arguments, but in perl, it makes more sense to return this as a list.
=head2 MQSET
MQSET($Hconn,$Hobj,$CompCode,$Reason,$Selector1,$Attr1,...);
This call also differs from the C API significantly. The C API took a
pointer to an array of selectors, with an argument indicating the
length of the array, and a similar pair of values for the attribute
values themselves. The perl convention is to list the selectors and
attributes in pairs, rather than by passing in an array reference.
=head2 MQCRTMH
$Hmsg = MQCRTMH($Hconn,$CrtMsgHOpts,$CompCode,$Reason);
This call is only available if the module has been compiled with MQ
v7. It creates a message handle, which can be used to get/set message
properties.
The $CrtMsgHOpts parameter is a MQCMHO data structure, which for MQ v7
only contains an 'Options' field.
$CrtMsgHOpts = { Options => ( MQSeries::MQCMHO_VALIDATE ) };
The default (listed above) is generally sufficient.
=head2 MQDLTMH
MQDLTMH($Hconn,$Hmsg,$DltMsgHOpts,$CompCode,$Reason)
This call is only available if the module has been compiled with MQ
v7. It deletes a message handle previously created with MQCRTMH.
The $DltMsgHOpts parameter is a MQDMHO data structure, which for MQ v7
only contains an 'Options' field, with no options defined. For MQ v7,
just specify an empty hash reference.
=head2 MQDLTMP
MQDLTMP($Hconn,$Hmsg,$DltPropOpts,$Name,$CompCode,$Reason)
This call is only available if the module has been compiled with MQ
v7. it deletes a message property.
The $DltPropOpts parameter is a MQDMPO parameter, which only contains
an 'Options' field.
$DltPropOpts = { Options => ( MQSeries::MQDMPO_DEL_FIRST ) };
The default (listed above) is generally sufficient.
The $Name parameter is a fully qualified property name.
=head2 MQINQMP
$PropertyValue = MQINQMP($Hconn,$Hmsg,$InqPropOpts,$Name,$PropDesc,$Type,$Length,$CompCode,$Reason)
This call is only available if the module has been compiled with MQ
v7. It retrieves a message property. The return value is the value
of the property retrieved.
The $InqPropOpts parameter is an MQIMPO data structure.
The $Name parameter is a property name, which may contain a wildcard.
The $PropDesc parameter is an MQPD data structure.
The $Type parameter determines the return type if the option
MQSeries::MQIMPO_CONVERT_TYPE is specified as part of the $InqPropOpts
parameter. In either case, it is also an output parameter that
specifies the returned type of the proeprty,
e.g. MQSeries::MQTYPE_STRING.
The $Length parameter is the maximum length of the property value to
return. It is also an output parameter that specifies the length of
the returned value.
=head2 MQSETMP
MQSETMP($Hconn,$Hmsg,$SetPropOpts,$Name,$PropDesc,$Type,$Value,$CompCode,$Reason)
This call is only available if the module has been compiled with MQ
v7. It sets or updates a message property.
The $SetPropOpts parameter is a MQHMSG data structur, which for MQ v7
only contains an 'Options' field.
$SetPropOpts = { Options => ( MQSeries::MQSMPO_SET_FIRST ) };
The default (listed above) is generally sufficient.
The $Name parameter is the property name.
The $PropDesc parameter is an MQPD data structure.
The $Type parameter specifies the data type of the property,
e.g. MQSeries::MQTYPE_STRING or MQSeries::MQTYPE_FLOAT64.
The $Value parameter is the actual proeprty value. It may be C<undef>
for string and byte string properties.
=head2 MQSTAT
MQSTAT($Hconn,$StatType,$Stat,$CompCode,$Reason)
This call is only available if the module has been compiled with MQ
v7. It returns queue manager asynchronous put status information.
The $StatType parameter must always be
MQSeries::MQSTAT_TYPE_ASYNC_ERROR.
The $Stat parameter is a MQSTS data structure must be specified as a
hash reference. On output, it includes the MQSTS fields documented in
the Application Programming Reference for MQ v7.
=head2 MQReasonToStrings
($ReasonText,$ReasonMacro) = MQReasonToStrings($Reason);
This subroutine is specific to the perl API, although similar
functionality is desperately needed in the other programming languages
as well. This takes an MQSeries Reason code, and returns the English
language text explaining the reason code, and the macro name. These
strings are compiled into the perl module, encoded in the XS routines,
after having been extracted from the IBM HTML documentation.
For example, a reason code of 2009 (MQRC_CONNECTION_BROKEN) will return:
"Connection to queue manager lost."
which looks a lot better in error logs and alerts than 2009.
The macro name itself is also returned as a string, so one could use
"MQRC_CONNECTION_BROKEN" in logs, error messages, etc.
In this release, only English language text is returned, but in a
future release, these messages will be locale specific. This will
almost certainly be implemented with locale-specific DBM files, but
you probably do not need to know this just yet....
=head2 MQReasonToText
($ReasonText) = MQReasonToText($Reason);
This is nothing more than a trivial interface to MQReasonToStrings,
returning just the one value (the reason text).
=head2 MQReasonToMacro
($ReasonMacro) = MQReasonToMacro($Reason);
This is nothing more than a trivial interface to MQReasonToStrings,
returning just the one value (the MQRC_* macro as a string).
=cut