ferocia-rubywmq 2.0.2 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +1 -1
- data/README.md +36 -47
- data/Rakefile +12 -76
- data/examples/each_a.rb +2 -3
- data/examples/each_b.rb +4 -5
- data/examples/each_header.rb +5 -6
- data/examples/files_to_q.rb +7 -8
- data/examples/get_a.rb +3 -5
- data/examples/get_client.rb +9 -10
- data/examples/put1_a.rb +2 -3
- data/examples/put1_b.rb +4 -7
- data/examples/put1_c.rb +6 -6
- data/examples/put_a.rb +0 -2
- data/examples/put_b.rb +5 -7
- data/examples/put_dlh.rb +11 -12
- data/examples/put_dynamic_q.rb +7 -7
- data/examples/put_group_a.rb +3 -4
- data/examples/put_group_b.rb +7 -7
- data/examples/put_rfh.rb +13 -11
- data/examples/put_rfh2_a.rb +9 -10
- data/examples/put_rfh2_b.rb +9 -9
- data/examples/put_xmit_q.rb +63 -8
- data/examples/q_to_files.rb +6 -7
- data/examples/request.rb +20 -18
- data/examples/server.rb +19 -16
- data/ext/extconf.rb +36 -26
- data/ext/extconf_client.rb +3 -3
- data/ext/generate/generate_const.rb +30 -23
- data/ext/generate/generate_reason.rb +70 -72
- data/ext/generate/generate_structs.rb +20 -19
- data/ext/generate/wmq_structs.erb +67 -67
- data/ext/wmq.c +0 -16
- data/ext/wmq.h +0 -16
- data/ext/wmq_message.c +8 -24
- data/ext/wmq_mq_load.c +5 -17
- data/ext/wmq_queue.c +73 -90
- data/ext/wmq_queue_manager.c +78 -88
- data/lib/wmq.rb +17 -11
- data/lib/wmq/message.rb +36 -34
- data/lib/wmq/queue_manager.rb +30 -23
- data/lib/wmq/version.rb +1 -1
- data/rubywmq.gemspec +44 -0
- data/test/queue_manager_test.rb +334 -0
- data/test/test_helper.rb +14 -0
- metadata +23 -34
- data/tests/test.rb +0 -318
data/ext/wmq_queue_manager.c
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2006 J. Reid Morrison
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
1
|
#include "wmq.h"
|
18
2
|
|
19
3
|
static ID ID_open;
|
@@ -256,7 +240,7 @@ VALUE QueueManager_initialize(VALUE self, VALUE hash)
|
|
256
240
|
{
|
257
241
|
/*
|
258
242
|
* Use system defined connection data rather than explicitly providing a
|
259
|
-
* connection name. This is used with CCDT, the MQSERVER
|
243
|
+
* connection name. This is used with CCDT, the MQSERVER ENV var or the
|
260
244
|
* mqclient.ini file
|
261
245
|
*/
|
262
246
|
pqm->connect_options.ClientConnPtr = NULL;
|
@@ -401,7 +385,7 @@ VALUE QueueManager_initialize(VALUE self, VALUE hash)
|
|
401
385
|
*
|
402
386
|
* Throws:
|
403
387
|
* * WMQ::WMQException if comp_code != MQCC_OK
|
404
|
-
* * Except if :
|
388
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
405
389
|
* to QueueManager.new
|
406
390
|
*/
|
407
391
|
VALUE QueueManager_connect(VALUE self)
|
@@ -476,7 +460,7 @@ VALUE QueueManager_connect(VALUE self)
|
|
476
460
|
*
|
477
461
|
* Throws:
|
478
462
|
* * WMQ::WMQException if comp_code != MQCC_OK
|
479
|
-
* * Except if :
|
463
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
480
464
|
* to QueueManager.new
|
481
465
|
*/
|
482
466
|
VALUE QueueManager_disconnect(VALUE self)
|
@@ -526,7 +510,7 @@ VALUE QueueManager_disconnect(VALUE self)
|
|
526
510
|
*
|
527
511
|
* Note:
|
528
512
|
* * commit will have no effect if all put and get operations were performed
|
529
|
-
* without specifying :
|
513
|
+
* without specifying sync: true
|
530
514
|
*
|
531
515
|
* Returns:
|
532
516
|
* * true : On Success
|
@@ -537,7 +521,7 @@ VALUE QueueManager_disconnect(VALUE self)
|
|
537
521
|
*
|
538
522
|
* Throws:
|
539
523
|
* * WMQ::WMQException if comp_code != MQCC_OK
|
540
|
-
* * Except if :
|
524
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
541
525
|
* to QueueManager.new
|
542
526
|
*/
|
543
527
|
VALUE QueueManager_commit(VALUE self)
|
@@ -578,7 +562,7 @@ VALUE QueueManager_commit(VALUE self)
|
|
578
562
|
*
|
579
563
|
* Note:
|
580
564
|
* * backout will have no effect if all put and get operations were performed
|
581
|
-
* without specifying :
|
565
|
+
* without specifying sync: true
|
582
566
|
*
|
583
567
|
* Returns:
|
584
568
|
* * true : On Success
|
@@ -589,7 +573,7 @@ VALUE QueueManager_commit(VALUE self)
|
|
589
573
|
*
|
590
574
|
* Throws:
|
591
575
|
* * WMQ::WMQException if comp_code != MQCC_OK
|
592
|
-
* * Except if :
|
576
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
593
577
|
* to QueueManager.new
|
594
578
|
*/
|
595
579
|
VALUE QueueManager_backout(VALUE self)
|
@@ -628,7 +612,7 @@ VALUE QueueManager_backout(VALUE self)
|
|
628
612
|
* resource such as a Database
|
629
613
|
*
|
630
614
|
* Starts a new unit of work under which put and get can be called with
|
631
|
-
* with the parameter :
|
615
|
+
* with the parameter sync: true
|
632
616
|
*
|
633
617
|
* Returns:
|
634
618
|
* * true : On Success
|
@@ -639,7 +623,7 @@ VALUE QueueManager_backout(VALUE self)
|
|
639
623
|
*
|
640
624
|
* Throws:
|
641
625
|
* * WMQ::WMQException if comp_code != MQCC_OK
|
642
|
-
* * Except if :
|
626
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
643
627
|
* to QueueManager.new
|
644
628
|
*/
|
645
629
|
VALUE QueueManager_begin(VALUE self)
|
@@ -682,17 +666,17 @@ VALUE QueueManager_begin(VALUE self)
|
|
682
666
|
*
|
683
667
|
* Summary of parameters and their WebSphere MQ equivalents
|
684
668
|
* queue.get( # WebSphere MQ Equivalents:
|
685
|
-
*
|
686
|
-
*
|
687
|
-
*
|
688
|
-
*
|
689
|
-
*
|
690
|
-
*
|
691
|
-
*
|
692
|
-
*
|
693
|
-
*
|
694
|
-
*
|
695
|
-
*
|
669
|
+
* q_name: 'Queue Name', # MQOD.ObjectName
|
670
|
+
* q_name: { queue_manager=>'QMGR_name', # MQOD.ObjectQMgrName
|
671
|
+
* q_name =>'q_name'}
|
672
|
+
* message: my_message, # n/a : Instance of Message
|
673
|
+
* data: "Hello World", # n/a : Data to send
|
674
|
+
* sync: false, # MQGMO_SYNCPOINT
|
675
|
+
* new_id: true, # MQPMO_NEW_MSG_ID & MQPMO_NEW_CORREL_ID
|
676
|
+
* new_msg_id: true, # MQPMO_NEW_MSG_ID
|
677
|
+
* new_correl_id: true, # MQPMO_NEW_CORREL_ID
|
678
|
+
* fail_if_quiescing: true, # MQOO_FAIL_IF_QUIESCING
|
679
|
+
* options: WMQ::MQPMO_FAIL_IF_QUIESCING # MQPMO_*
|
696
680
|
* )
|
697
681
|
*
|
698
682
|
* Mandatory Parameters
|
@@ -768,7 +752,7 @@ VALUE QueueManager_begin(VALUE self)
|
|
768
752
|
*
|
769
753
|
* * :options => Fixnum (Advanced MQ Use only)
|
770
754
|
* * Numeric field containing any of the MQ Put message options or'd together
|
771
|
-
* * E.g. :
|
755
|
+
* * E.g. options: WMQ::MQPMO_PASS_IDENTITY_CONTEXT | WMQ::MQPMO_ALTERNATE_USER_AUTHORITY
|
772
756
|
* * Note: If :options is supplied, it is applied first, then the above parameters are
|
773
757
|
* applied afterwards.
|
774
758
|
* * One or more of the following values:
|
@@ -795,7 +779,7 @@ VALUE QueueManager_begin(VALUE self)
|
|
795
779
|
*
|
796
780
|
* Throws:
|
797
781
|
* * WMQ::WMQException if comp_code == MQCC_FAILED
|
798
|
-
* * Except if :
|
782
|
+
* * Except if exception_on_error: false was supplied as a parameter
|
799
783
|
* to QueueManager.new
|
800
784
|
*/
|
801
785
|
VALUE QueueManager_put(VALUE self, VALUE hash)
|
@@ -831,7 +815,7 @@ VALUE QueueManager_put(VALUE self, VALUE hash)
|
|
831
815
|
{
|
832
816
|
WMQ_HASH2MQCHARS(q_name, q_mgr_name, od.ObjectQMgrName)
|
833
817
|
|
834
|
-
q_name = rb_hash_aref(
|
818
|
+
q_name = rb_hash_aref(q_name, ID2SYM(ID_q_name));
|
835
819
|
if (NIL_P(q_name))
|
836
820
|
{
|
837
821
|
rb_raise(rb_eArgError,
|
@@ -1018,9 +1002,9 @@ static VALUE QueueManager_open_queue_each(VALUE parameters)
|
|
1018
1002
|
* Example:
|
1019
1003
|
* require 'wmq/wmq_client'
|
1020
1004
|
*
|
1021
|
-
* WMQ::QueueManager.connect(:
|
1022
|
-
* qmgr.open_queue(:
|
1023
|
-
* queue.put(:
|
1005
|
+
* WMQ::QueueManager.connect(q_mgr_name: 'REID', connection_name: 'localhost(1414)') do |qmgr|
|
1006
|
+
* qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
|
1007
|
+
* queue.put(data: 'Hello World')
|
1024
1008
|
* end
|
1025
1009
|
* end
|
1026
1010
|
*/
|
@@ -1086,43 +1070,43 @@ static VALUE QueueManager_singleton_connect_ensure(VALUE self)
|
|
1086
1070
|
* * Since the number of parameters can vary dramatically, all parameters are passed by name in a hash
|
1087
1071
|
* * Summary of parameters and their WebSphere MQ equivalents:
|
1088
1072
|
* WMQ::QueueManager.connect( # WebSphere MQ Equivalents:
|
1089
|
-
* :
|
1090
|
-
* :
|
1091
|
-
* :
|
1073
|
+
* q_mgr_name: 'queue_manager name',
|
1074
|
+
* exception_on_error: true, # n/a
|
1075
|
+
* connect_options: WMQ::MQCNO_FASTBATH_BINDING # MQCNO.Options
|
1092
1076
|
*
|
1093
|
-
* :
|
1077
|
+
* trace_level: 0, # n/a
|
1094
1078
|
*
|
1095
1079
|
* # Common client connection parameters
|
1096
|
-
* :
|
1097
|
-
* :
|
1098
|
-
* :
|
1080
|
+
* channel_name: 'svrconn channel name', # MQCD.ChannelName
|
1081
|
+
* connection_name: 'localhost(1414)', # MQCD.ConnectionName
|
1082
|
+
* transport_type: WMQ::MQXPT_TCP, # MQCD.TransportType
|
1099
1083
|
*
|
1100
1084
|
* # Advanced client connections parameters
|
1101
|
-
* :
|
1102
|
-
* :
|
1103
|
-
* :
|
1104
|
-
* :
|
1105
|
-
* :
|
1106
|
-
* :
|
1107
|
-
* :
|
1108
|
-
* :
|
1109
|
-
* :
|
1110
|
-
* :
|
1111
|
-
* :
|
1112
|
-
* :
|
1113
|
-
* :
|
1114
|
-
* :
|
1115
|
-
* :
|
1116
|
-
* :
|
1117
|
-
* :
|
1085
|
+
* max_msg_length: 65535, # MQCD.MaxMsgLength
|
1086
|
+
* security_exit: 'Name of security exit', # MQCD.SecurityExit
|
1087
|
+
* send_exit: 'Name of send exit', # MQCD.SendExit
|
1088
|
+
* receive_exit: 'Name of receive exit', # MQCD.ReceiveExit
|
1089
|
+
* security_user_data: 'Security exit User data', # MQCD.SecurityUserData
|
1090
|
+
* send_user_data: 'Send exit user data', # MQCD.SendUserData
|
1091
|
+
* receive_user_data: 'Receive exit user data', # MQCD.ReceiveUserData
|
1092
|
+
* heartbeat_interval: 1, # MQCD.HeartbeatInterval
|
1093
|
+
* remote_security_id: 'Remote Security id', # MQCD.RemoteSecurityId
|
1094
|
+
* ssl_cipher_spec: 'SSL Cipher Spec', # MQCD.SSLCipherSpec
|
1095
|
+
* keep_alive_interval: -1, # MQCD.KeepAliveInterval
|
1096
|
+
* mode_name: 'LU6.2 Mode Name', # MQCD.ModeName
|
1097
|
+
* tp_name: 'LU6.2 Transaction pgm name', # MQCD.TpName
|
1098
|
+
* user_identifier: 'LU 6.2 Userid', # MQCD.UserIdentifier
|
1099
|
+
* password: 'LU6.2 Password', # MQCD.Password
|
1100
|
+
* long_remote_user_id: 'Long remote user identifier', # MQCD.LongRemoteUserId (Ptr, Length)
|
1101
|
+
* ssl_peer_name: 'SSL Peer name', # MQCD.SSLPeerName (Ptr, Length)
|
1118
1102
|
*
|
1119
1103
|
* # SSL Options
|
1120
|
-
* :
|
1121
|
-
* :
|
1104
|
+
* key_repository: '/var/mqm/qmgrs/.../key', # MQSCO.KeyRepository
|
1105
|
+
* crypto_hardware: 'GSK_ACCELERATOR_NCIPHER_NF_ON', # MQSCO.CryptoHardware
|
1122
1106
|
* )
|
1123
1107
|
*
|
1124
1108
|
* Optional Parameters
|
1125
|
-
* * :
|
1109
|
+
* * q_mgr_name: String
|
1126
1110
|
* * Name of the existing WebSphere MQ Queue Manager to connect to
|
1127
1111
|
*
|
1128
1112
|
* * Default:
|
@@ -1188,6 +1172,12 @@ static VALUE QueueManager_singleton_connect_ensure(VALUE self)
|
|
1188
1172
|
* * Default Value:
|
1189
1173
|
* WMQ::MQXPT_TCP
|
1190
1174
|
*
|
1175
|
+
* * :use_system_connection_data => Boolean
|
1176
|
+
* * Used when you want to initialise a client connection, but you want
|
1177
|
+
* * to obtain the connection_name and channel_name from one of the system
|
1178
|
+
* * configuration methods. These being: mqclient.ini file, MQSERVER ENV
|
1179
|
+
* * variable or CCDT.
|
1180
|
+
*
|
1191
1181
|
* For the Advanced Client Connection parameters, please see the WebSphere MQ documentation
|
1192
1182
|
*
|
1193
1183
|
* Note:
|
@@ -1205,13 +1195,13 @@ static VALUE QueueManager_singleton_connect_ensure(VALUE self)
|
|
1205
1195
|
* require 'wmq/wmq_client'
|
1206
1196
|
*
|
1207
1197
|
* WMQ::QueueManager.connect(
|
1208
|
-
* :
|
1209
|
-
* :
|
1210
|
-
* :
|
1211
|
-
* qmgr.open_queue(:
|
1198
|
+
* channel_name: 'SYSTEM.DEF.SVRCONN',
|
1199
|
+
* transport_type: WMQ::MQXPT_TCP,
|
1200
|
+
* connection_name: 'localhost(1414)' ) do |qmgr|
|
1201
|
+
* qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :input) do |queue|
|
1212
1202
|
*
|
1213
1203
|
* message = WMQ::Message.new
|
1214
|
-
* if queue.get(:message
|
1204
|
+
* if queue.get(message: message)
|
1215
1205
|
* puts "Data Received: #{message.data}"
|
1216
1206
|
* else
|
1217
1207
|
* puts 'No message available'
|
@@ -1342,41 +1332,41 @@ static int QueueManager_execute_each (VALUE key, VALUE value, PQUEUE_MANAGER pqm
|
|
1342
1332
|
* Example
|
1343
1333
|
* WMQ::QueueManager.connect do |qmgr|
|
1344
1334
|
* result = qmgr.execute(
|
1345
|
-
*
|
1346
|
-
* :
|
1347
|
-
* :
|
1348
|
-
* :
|
1335
|
+
* command: :inquire_q,
|
1336
|
+
* q_name: 'MY.LOCAL.QUEUE',
|
1337
|
+
* q_type: WMQ::MQQT_LOCAL,
|
1338
|
+
* current_q_depth: nil
|
1349
1339
|
* )
|
1350
1340
|
* # OR, we can replace the method name execute with the MQAI command:
|
1351
1341
|
* result = qmgr.inquire_q(
|
1352
|
-
* :
|
1353
|
-
* :
|
1354
|
-
* :
|
1342
|
+
* q_name: 'MY.LOCAL.QUEUE',
|
1343
|
+
* q_type: WMQ::MQQT_LOCAL,
|
1344
|
+
* current_q_depth: nil
|
1355
1345
|
* )
|
1356
1346
|
*
|
1357
1347
|
* Complete Example:
|
1358
1348
|
* require 'wmq/wmq'
|
1359
1349
|
* require 'wmq/wmq_const_admin'
|
1360
|
-
* WMQ::QueueManager.connect(:
|
1361
|
-
* qmgr.reset_q_stats(:
|
1350
|
+
* WMQ::QueueManager.connect(q_mgr_name: 'REID', connection_name: 'localhost(1414)') do |qmgr|
|
1351
|
+
* qmgr.reset_q_stats(q_name: '*').each {|item| p item }
|
1362
1352
|
* end
|
1363
1353
|
*
|
1364
1354
|
* Some one line examples
|
1365
|
-
* qmgr.inquire_q(:
|
1355
|
+
* qmgr.inquire_q(q_name: 'TEST*').each {|item| p item }
|
1366
1356
|
*
|
1367
|
-
* qmgr.inquire_q(:
|
1357
|
+
* qmgr.inquire_q(q_name: 'TEST*', q_type: WMQ::MQQT_LOCAL, current_q_depth: nil).each {|item| p item }
|
1368
1358
|
*
|
1369
|
-
* qmgr.inquire_process(:
|
1359
|
+
* qmgr.inquire_process(process_name:'*').each {|item| p item }
|
1370
1360
|
*
|
1371
1361
|
* qmgr.ping_q_mgr.each {|item| p item }
|
1372
1362
|
*
|
1373
1363
|
* qmgr.refresh_security.each {|item| p item }
|
1374
1364
|
*
|
1375
|
-
* qmgr.inquire_q_status(:
|
1365
|
+
* qmgr.inquire_q_status(q_name: 'TEST*', q_status_type: :q_status, q_status_attrs: :process_id).each {|item| p item }
|
1376
1366
|
*
|
1377
1367
|
* qmgr.start_channel_listener.each {|item| p item }
|
1378
1368
|
*
|
1379
|
-
* qmgr.inquire_channel_status(:
|
1369
|
+
* qmgr.inquire_channel_status(channel_name: '*').each {|item| p item }
|
1380
1370
|
*/
|
1381
1371
|
VALUE QueueManager_execute(VALUE self, VALUE hash)
|
1382
1372
|
{
|
data/lib/wmq.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require 'wmq/version'
|
2
|
-
require 'wmq/constants'
|
3
|
-
require 'wmq/constants_admin'
|
4
2
|
require 'wmq/queue_manager'
|
5
3
|
require 'wmq/message'
|
6
4
|
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
unless RUBY_PLATFORM =~ /darwin/ || ENV['DISABLE_RUBYWMQ']
|
6
|
+
# don't try and require any of these on a mac as they do not exist, they
|
7
|
+
# required the gem extensions to have been compiled.
|
8
|
+
|
9
|
+
require 'wmq/constants'
|
10
|
+
require 'wmq/constants_admin'
|
11
|
+
|
12
|
+
# Load wmq using the auto-load library.
|
13
|
+
#
|
14
|
+
# If it fails, then it is most likely since this platform is not supported
|
15
|
+
# by the auto load facility in Ruby WMQ, so try to load client linked library
|
16
|
+
# For Example AIX does not support Autoload whereas Windows and Linux are supported
|
17
|
+
begin
|
18
|
+
require 'wmq/wmq'
|
19
|
+
rescue LoadError
|
20
|
+
require 'wmq/wmq_client'
|
21
|
+
end
|
16
22
|
end
|
data/lib/wmq/message.rb
CHANGED
@@ -17,45 +17,47 @@ module WMQ
|
|
17
17
|
# * The format of any header should not be supplied in the descriptor or any header
|
18
18
|
#
|
19
19
|
# Message has the following attributes:
|
20
|
+
#
|
20
21
|
# * descriptor = {
|
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
|
-
# *
|
22
|
+
# # WebSphere MQ Equivalent
|
23
|
+
# format: WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
|
24
|
+
# WMQ::MQFMT_NONE # Do not supply header formats here
|
25
|
+
# original_length: Number, # MQMD.OriginalLength
|
26
|
+
# priority: 0 .. 9, # MQMD.Priority
|
27
|
+
# put_time: String, # MQMD.PutTime
|
28
|
+
# msg_id: String, # ...
|
29
|
+
# expiry: Number,
|
30
|
+
# persistence: Number,
|
31
|
+
# reply_to_q: String,
|
32
|
+
# correl_id: String,
|
33
|
+
# feedback: Number,
|
34
|
+
# offset: Number,
|
35
|
+
# report: Number,
|
36
|
+
# msg_flags: Number,
|
37
|
+
# reply_to_q_mgr: String,
|
38
|
+
# appl_identity_data: String,
|
39
|
+
# put_appl_name: String,
|
40
|
+
# user_identifier: String,
|
41
|
+
# msg_seq_number: Number,
|
42
|
+
# appl_origin_data: String,
|
43
|
+
# accounting_token: String,
|
44
|
+
# backout_count: Number,
|
45
|
+
# coded_char_set_id: Number,
|
46
|
+
# put_appl_type: Number,
|
47
|
+
# msg_type: Number,
|
48
|
+
# group_id: String,
|
49
|
+
# put_date: String,
|
50
|
+
# encoding: Number
|
51
|
+
# }
|
52
|
+
#
|
53
|
+
# * data: String
|
54
|
+
# * headers: Array<Hash>
|
53
55
|
# * Note: Do not supply the format of any header. Ruby WMQ does this for you.
|
54
56
|
#
|
55
57
|
# The following headers are supported:
|
56
58
|
# * Rules And Formatting Header (RFH)
|
57
|
-
# :
|
58
|
-
#
|
59
|
+
# header_type: :rf_header
|
60
|
+
# ....
|
59
61
|
# * Rules and Formatting V2 Header (RFH2)
|
60
62
|
# ....
|
61
63
|
# * Dead Letter Header
|
data/lib/wmq/queue_manager.rb
CHANGED
@@ -6,11 +6,11 @@ module WMQ
|
|
6
6
|
# Example
|
7
7
|
# require 'wmq/wmq'
|
8
8
|
# require 'wmq/wmq_const_admin'
|
9
|
-
# WMQ::QueueManager.connect(:
|
9
|
+
# WMQ::QueueManager.connect(q_mgr_name: 'REID', connection_name: 'localhost(1414)') do |qmgr|
|
10
10
|
# qmgr.mqsc('dis ql(*)').each {|item| p item }
|
11
11
|
# end
|
12
12
|
def mqsc(mqsc_text)
|
13
|
-
|
13
|
+
execute(command: :escape, escape_type: WMQ::MQET_MQSC, escape_text: mqsc_text).collect { |item| item[:escape_text] }
|
14
14
|
end
|
15
15
|
|
16
16
|
# Put a reply message back to the sender
|
@@ -44,30 +44,35 @@ module WMQ
|
|
44
44
|
if parms[:request_message].descriptor[:msg_type] == WMQ::MQMT_REQUEST
|
45
45
|
request = parms.delete(:request_message)
|
46
46
|
|
47
|
-
reply
|
47
|
+
reply = parms[:message] ||= Message.new(data: parms[:data])
|
48
48
|
reply.descriptor[:msg_type] = WMQ::MQMT_REPLY
|
49
49
|
reply.descriptor[:expiry] = request.descriptor[:expiry]
|
50
50
|
reply.descriptor[:priority] = request.descriptor[:priority]
|
51
51
|
reply.descriptor[:persistence]= request.descriptor[:persistence]
|
52
|
-
reply.descriptor[:format]
|
52
|
+
reply.descriptor[:format] = request.descriptor[:format]
|
53
53
|
|
54
54
|
# Set Correlation Id based on report options supplied
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
reply.descriptor[:correl_id] =
|
56
|
+
if request.descriptor[:report] & WMQ::MQRO_PASS_CORREL_ID != 0
|
57
|
+
request.descriptor[:correl_id]
|
58
|
+
else
|
59
|
+
request.descriptor[:msg_id]
|
60
|
+
end
|
60
61
|
|
61
62
|
# Set Message Id based on report options supplied
|
62
63
|
if request.descriptor[:report] & WMQ::MQRO_PASS_MSG_ID != 0
|
63
64
|
reply.descriptor[:msg_id] = request.descriptor[:msg_id]
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
q_name = {
|
68
|
+
q_name: request.descriptor[:reply_to_q],
|
69
|
+
q_mgr_name: request.descriptor[:reply_to_q_mgr]
|
70
|
+
}
|
71
|
+
|
72
|
+
parms[:q_name] = q_name
|
73
|
+
put(parms)
|
69
74
|
else
|
70
|
-
|
75
|
+
false
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
@@ -83,24 +88,26 @@ module WMQ
|
|
83
88
|
# are retained.
|
84
89
|
#
|
85
90
|
def put_to_dead_letter_q(parms)
|
86
|
-
message = parms[:message] ||= Message.new(:
|
87
|
-
dlh
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
91
|
+
message = parms[:message] ||= Message.new(data: parms[:data])
|
92
|
+
dlh = {
|
93
|
+
header_type: :dead_letter_header,
|
94
|
+
reason: parms.delete(:reason),
|
95
|
+
dest_q_name: parms.delete(:q_name),
|
96
|
+
dest_q_mgr_name: name
|
97
|
+
}
|
92
98
|
|
93
99
|
message.headers.unshift(dlh)
|
94
|
-
parms[:q_name]='SYSTEM.DEAD.LETTER.QUEUE'
|
95
|
-
|
100
|
+
parms[:q_name] = 'SYSTEM.DEAD.LETTER.QUEUE' #TODO Should be obtained from QMGR config
|
101
|
+
|
102
|
+
put(parms)
|
96
103
|
end
|
97
104
|
|
98
105
|
# Expose Commands directly as Queue Manager methods
|
99
106
|
def method_missing(name, *args)
|
100
107
|
if args.size == 1
|
101
|
-
|
108
|
+
execute({ command: name }.merge(args[0]))
|
102
109
|
elsif args.size == 0
|
103
|
-
|
110
|
+
execute(command: name)
|
104
111
|
else
|
105
112
|
raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
|
106
113
|
end
|