rubywmq 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +10 -0
 - data/Gemfile.lock +37 -0
 - data/LICENSE.txt +1 -1
 - data/README.md +29 -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 +2 -1
 - 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 +115 -108
 - data/lib/wmq/message.rb +36 -34
 - data/lib/wmq/queue_manager.rb +22 -19
 - data/lib/wmq/version.rb +1 -1
 - data/rubywmq.gemspec +38 -0
 - data/test/queue_manager_test.rb +334 -0
 - data/test/test_helper.rb +14 -0
 - metadata +16 -26
 - data/tests/test.rb +0 -318
 
    
        data/examples/get_a.rb
    CHANGED
    
    | 
         @@ -2,14 +2,12 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : get() : Retrieve a single message from a queue
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          If no messages are on the queue, message.data is nil
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       9 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 8 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :input) do |queue|
         
     | 
| 
       11 
9 
     | 
    
         
             
                message = WMQ::Message.new
         
     | 
| 
       12 
     | 
    
         
            -
                if queue.get(: 
     | 
| 
      
 10 
     | 
    
         
            +
                if queue.get(message: message)
         
     | 
| 
       13 
11 
     | 
    
         
             
                  puts "Data Received: #{message.data}"
         
     | 
| 
       14 
12 
     | 
    
         
             
                else
         
     | 
| 
       15 
13 
     | 
    
         
             
                  puts 'No message available'
         
     | 
    
        data/examples/get_client.rb
    CHANGED
    
    | 
         @@ -8,25 +8,24 @@ 
     | 
|
| 
       8 
8 
     | 
    
         
             
            # If :connection_name is not present, a WebSphere MQ Server connection will be used
         
     | 
| 
       9 
9 
     | 
    
         
             
            # I.e. Local server connection
         
     | 
| 
       10 
10 
     | 
    
         
             
            #
         
     | 
| 
       11 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       12 
11 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
            WMQ::QueueManager.connect(
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
      
 14 
     | 
    
         
            +
              connection_name: 'localhost(1414)',    # Use MQ Client Library
         
     | 
| 
      
 15 
     | 
    
         
            +
              channel_name:    'SYSTEM.DEF.SVRCONN', # Optional, since this is the default value
         
     | 
| 
      
 16 
     | 
    
         
            +
              transport_type:  WMQ::MQXPT_TCP        # Optional, since this is the default value
         
     | 
| 
      
 17 
     | 
    
         
            +
            ) do |qmgr|
         
     | 
| 
      
 18 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :input) do |queue|
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
20 
     | 
    
         
             
                message = WMQ::Message.new
         
     | 
| 
       22 
     | 
    
         
            -
                if queue.get(: 
     | 
| 
      
 21 
     | 
    
         
            +
                if queue.get(message: message)
         
     | 
| 
       23 
22 
     | 
    
         
             
                  puts "Data Received: #{message.data}"
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                  puts  
     | 
| 
      
 24 
     | 
    
         
            +
                  puts 'Message Descriptor:'
         
     | 
| 
       26 
25 
     | 
    
         
             
                  p message.descriptor
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                  puts  
     | 
| 
       29 
     | 
    
         
            -
                  message.headers.each {|header| p header}
         
     | 
| 
      
 27 
     | 
    
         
            +
                  puts 'Headers Received:'
         
     | 
| 
      
 28 
     | 
    
         
            +
                  message.headers.each { |header| p header }
         
     | 
| 
       30 
29 
     | 
    
         
             
                else
         
     | 
| 
       31 
30 
     | 
    
         
             
                  puts 'No message available'
         
     | 
| 
       32 
31 
     | 
    
         
             
                end
         
     | 
    
        data/examples/put1_a.rb
    CHANGED
    
    | 
         @@ -1,9 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Sample : put1() : Put a single message to a queue
         
     | 
| 
       3 
3 
     | 
    
         
             
            #
         
     | 
| 
       4 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       5 
4 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       8 
     | 
    
         
            -
              qmgr.put(: 
     | 
| 
      
 6 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 7 
     | 
    
         
            +
              qmgr.put(q_name: 'TEST.QUEUE', data: 'Hello World')
         
     | 
| 
       9 
8 
     | 
    
         
             
            end
         
     | 
    
        data/examples/put1_b.rb
    CHANGED
    
    | 
         @@ -3,15 +3,12 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            #
         
     | 
| 
       4 
4 
     | 
    
         
             
            #          Set the correlation id to a text string
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       7 
6 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              message 
     | 
| 
       12 
     | 
    
         
            -
              message.data = 'Hello World'
         
     | 
| 
      
 8 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 9 
     | 
    
         
            +
              message                        = WMQ::Message.new
         
     | 
| 
      
 10 
     | 
    
         
            +
              message.data                   = 'Hello World'
         
     | 
| 
       13 
11 
     | 
    
         
             
              message.descriptor[:correl_id] = 'My first message'
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              qmgr.put(: 
     | 
| 
      
 13 
     | 
    
         
            +
              qmgr.put(q_name: 'TEST.QUEUE', message: message)
         
     | 
| 
       16 
14 
     | 
    
         
             
            end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
    
        data/examples/put1_c.rb
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a single request message to a queue
         
     | 
| 
       3 
3 
     | 
    
         
             
            #
         
     | 
| 
       4 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       5 
4 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       8 
     | 
    
         
            -
              message 
     | 
| 
      
 6 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 7 
     | 
    
         
            +
              message      = WMQ::Message.new
         
     | 
| 
       9 
8 
     | 
    
         
             
              message.data = 'Hello World'
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
10 
     | 
    
         
             
              message.descriptor = {
         
     | 
| 
       12 
     | 
    
         
            -
                : 
     | 
| 
       13 
     | 
    
         
            -
                : 
     | 
| 
      
 11 
     | 
    
         
            +
                msg_type:   WMQ::MQMT_REQUEST,
         
     | 
| 
      
 12 
     | 
    
         
            +
                reply_to_q: 'TEST.REPLY.QUEUE'
         
     | 
| 
      
 13 
     | 
    
         
            +
              }
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              qmgr.put(: 
     | 
| 
      
 15 
     | 
    
         
            +
              qmgr.put(q_name: 'TEST.QUEUE', message: message)
         
     | 
| 
       16 
16 
     | 
    
         
             
            end
         
     | 
    
        data/examples/put_a.rb
    CHANGED
    
    | 
         @@ -2,7 +2,6 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a single message to a queue
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
            WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
         
     | 
| 
         @@ -16,4 +15,3 @@ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr| 
     | 
|
| 
       16 
15 
     | 
    
         
             
                queue.put(:data => 'Hello Again')
         
     | 
| 
       17 
16 
     | 
    
         
             
              end
         
     | 
| 
       18 
17 
     | 
    
         
             
            end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
    
        data/examples/put_b.rb
    CHANGED
    
    | 
         @@ -3,18 +3,16 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #          Ensure that all messages have the same correlation id
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       7 
6 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       10 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                message = WMQ::Message.new
         
     | 
| 
      
 8 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 9 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 10 
     | 
    
         
            +
                message      = WMQ::Message.new
         
     | 
| 
       13 
11 
     | 
    
         | 
| 
       14 
12 
     | 
    
         
             
                # First message
         
     | 
| 
       15 
13 
     | 
    
         
             
                #   Results in a WMQ generated msg_id and empty correl_id
         
     | 
| 
       16 
14 
     | 
    
         
             
                message.data = 'Hello World'
         
     | 
| 
       17 
     | 
    
         
            -
                queue.put(: 
     | 
| 
      
 15 
     | 
    
         
            +
                queue.put(message: message)
         
     | 
| 
       18 
16 
     | 
    
         | 
| 
       19 
17 
     | 
    
         
             
                # Second message
         
     | 
| 
       20 
18 
     | 
    
         
             
                #   new_msg_id will cause the second message to have a new message id
         
     | 
| 
         @@ -22,6 +20,6 @@ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr| 
     | 
|
| 
       22 
20 
     | 
    
         
             
                #   This message will have the same correlation id as the first message (empty)
         
     | 
| 
       23 
21 
     | 
    
         
             
                message.data = 'Hello Again'
         
     | 
| 
       24 
22 
     | 
    
         
             
                p message.descriptor
         
     | 
| 
       25 
     | 
    
         
            -
                queue.put(: 
     | 
| 
      
 23 
     | 
    
         
            +
                queue.put(message: message, new_msg_id: true)
         
     | 
| 
       26 
24 
     | 
    
         
             
              end
         
     | 
| 
       27 
25 
     | 
    
         
             
            end
         
     | 
    
        data/examples/put_dlh.rb
    CHANGED
    
    | 
         @@ -2,24 +2,23 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a message to a queue with a dead letter header
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       9 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       10 
     | 
    
         
            -
                message 
     | 
| 
       11 
     | 
    
         
            -
                message.data 
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 8 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 9 
     | 
    
         
            +
                message         = WMQ::Message.new
         
     | 
| 
      
 10 
     | 
    
         
            +
                message.data    = 'Hello World'
         
     | 
| 
       13 
11 
     | 
    
         
             
                message.headers = [
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                  {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    header_type:     :dead_letter_header,
         
     | 
| 
      
 14 
     | 
    
         
            +
                    reason:          WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
         
     | 
| 
      
 15 
     | 
    
         
            +
                    dest_q_name:     'ORIGINAL_QUEUE_NAME',
         
     | 
| 
      
 16 
     | 
    
         
            +
                    dest_q_mgr_name: 'BAD_Q_MGR'
         
     | 
| 
      
 17 
     | 
    
         
            +
                  }
         
     | 
| 
       18 
18 
     | 
    
         
             
                ]
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                message.descriptor[:format] = WMQ::MQFMT_STRING
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                queue.put(:message=>message)
         
     | 
| 
      
 22 
     | 
    
         
            +
                queue.put(:message => message)
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         
             
            end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
    
        data/examples/put_dynamic_q.rb
    CHANGED
    
    | 
         @@ -9,14 +9,14 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
            #   That way the queue would remain after termination of this code.
         
     | 
| 
       10 
10 
     | 
    
         
             
            #   In this sample the queue will disappear when this program terminates
         
     | 
| 
       11 
11 
     | 
    
         
             
            #
         
     | 
| 
       12 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       13 
12 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       16 
     | 
    
         
            -
              qmgr.open_queue( 
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 15 
     | 
    
         
            +
              qmgr.open_queue(
         
     | 
| 
      
 16 
     | 
    
         
            +
                q_name:         'SYSTEM.DEFAULT.MODEL.QUEUE',
         
     | 
| 
      
 17 
     | 
    
         
            +
                dynamic_q_name: 'TEST.QUEUE.SAMPLE',
         
     | 
| 
      
 18 
     | 
    
         
            +
                mode:           :output
         
     | 
| 
      
 19 
     | 
    
         
            +
              ) do |queue|
         
     | 
| 
      
 20 
     | 
    
         
            +
                queue.put(data: 'Hello World')
         
     | 
| 
       21 
21 
     | 
    
         
             
              end
         
     | 
| 
       22 
22 
     | 
    
         
             
            end
         
     | 
    
        data/examples/put_group_a.rb
    CHANGED
    
    | 
         @@ -5,14 +5,13 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
            #          Allow MQ to create the unique group id and let it automatically
         
     | 
| 
       6 
6 
     | 
    
         
             
            #          assign message sequence numbers for each message in the group
         
     | 
| 
       7 
7 
     | 
    
         
             
            #
         
     | 
| 
       8 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       9 
8 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
10 
     | 
    
         
             
            # Put 5 messages in a single group onto the queue
         
     | 
| 
       12 
11 
     | 
    
         
             
            total = 5
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       15 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
      
 13 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 14 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
       16 
15 
     | 
    
         
             
                message = WMQ::Message.new
         
     | 
| 
       17 
16 
     | 
    
         
             
                total.times do |count|
         
     | 
| 
       18 
17 
     | 
    
         
             
                  message.data = "Hello:#{count}"
         
     | 
| 
         @@ -28,7 +27,7 @@ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr| 
     | 
|
| 
       28 
27 
     | 
    
         
             
                  #
         
     | 
| 
       29 
28 
     | 
    
         
             
                  # By setting the put :options => WMQ::MQPMO_LOGICAL_ORDER then MQ will supply a unique Group Id
         
     | 
| 
       30 
29 
     | 
    
         
             
                  # and MQ will automatically set the message sequence number for us.
         
     | 
| 
       31 
     | 
    
         
            -
                  queue.put(: 
     | 
| 
      
 30 
     | 
    
         
            +
                  queue.put(message: message, new_id: true, options: WMQ::MQPMO_LOGICAL_ORDER)
         
     | 
| 
       32 
31 
     | 
    
         
             
                  p message.descriptor
         
     | 
| 
       33 
32 
     | 
    
         
             
                end
         
     | 
| 
       34 
33 
     | 
    
         
             
              end
         
     | 
    
        data/examples/put_group_b.rb
    CHANGED
    
    | 
         @@ -5,32 +5,32 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
            #          Supply our own user-defined group Id.
         
     | 
| 
       6 
6 
     | 
    
         
             
            #          We also have to supply the message sequence number which starts at 1
         
     | 
| 
       7 
7 
     | 
    
         
             
            #
         
     | 
| 
       8 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       9 
8 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
10 
     | 
    
         
             
            # Put 5 messages in a single group onto the queue
         
     | 
| 
       12 
11 
     | 
    
         
             
            total = 5
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       15 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       16 
     | 
    
         
            -
                message 
     | 
| 
      
 13 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 14 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 15 
     | 
    
         
            +
                message                       = WMQ::Message.new
         
     | 
| 
       17 
16 
     | 
    
         
             
                # Supply a unique Group Id, truncated to the MQ maximum for Group Id.
         
     | 
| 
       18 
17 
     | 
    
         
             
                message.descriptor[:group_id] = 'MyUniqueGroupId'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       19 
19 
     | 
    
         
             
                total.times do |count|
         
     | 
| 
       20 
20 
     | 
    
         
             
                  #   new_id => true causes subsequent messages to have unique message and
         
     | 
| 
       21 
21 
     | 
    
         
             
                  #   correlation id's. Otherwise all messages will have the same message and
         
     | 
| 
       22 
22 
     | 
    
         
             
                  #   correlation id's since the same message object is being
         
     | 
| 
       23 
23 
     | 
    
         
             
                  #   re-used for all put calls
         
     | 
| 
       24 
     | 
    
         
            -
                  message.data 
     | 
| 
      
 24 
     | 
    
         
            +
                  message.data                        = "Hello:#{count}"
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  # Set the message flag to indicate message is in a group
         
     | 
| 
       27 
27 
     | 
    
         
             
                  # On the last message, set the last message flag
         
     | 
| 
       28 
     | 
    
         
            -
                  message.descriptor[:msg_flags] 
     | 
| 
      
 28 
     | 
    
         
            +
                  message.descriptor[:msg_flags]      = (count < total-1) ? WMQ::MQMF_MSG_IN_GROUP : WMQ::MQMF_LAST_MSG_IN_GROUP
         
     | 
| 
       29 
29 
     | 
    
         
             
                  message.descriptor[:msg_seq_number] = count + 1
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                  # By setting the put :options => WMQ::MQPMO_LOGICAL_ORDER then MQ will supply a unique Group Id
         
     | 
| 
       32 
32 
     | 
    
         
             
                  # and MQ will automatically set the message sequence number for us.
         
     | 
| 
       33 
     | 
    
         
            -
                  queue.put(: 
     | 
| 
      
 33 
     | 
    
         
            +
                  queue.put(message: message, new_id: true)
         
     | 
| 
       34 
34 
     | 
    
         
             
                  p message.descriptor
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
    
        data/examples/put_rfh.rb
    CHANGED
    
    | 
         @@ -2,7 +2,6 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a message to a queue with a Refernce header
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
            # The Rules Format header (MQRFH) allows a list of name value pairs to be sent along
         
     | 
| 
         @@ -31,21 +30,24 @@ require 'wmq' 
     | 
|
| 
       31 
30 
     | 
    
         
             
            #       it out immediately again could result in re-ordering of the name value pairs.
         
     | 
| 
       32 
31 
     | 
    
         
             
            #
         
     | 
| 
       33 
32 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       35 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       36 
     | 
    
         
            -
                message 
     | 
| 
      
 33 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 34 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 35 
     | 
    
         
            +
                message      = WMQ::Message.new
         
     | 
| 
       37 
36 
     | 
    
         
             
                message.data = 'Hello World'
         
     | 
| 
       38 
37 
     | 
    
         | 
| 
       39 
38 
     | 
    
         
             
                message.headers = [
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
                  {
         
     | 
| 
      
 40 
     | 
    
         
            +
                    header_type: :rf_header,
         
     | 
| 
      
 41 
     | 
    
         
            +
                    name_value:  {
         
     | 
| 
      
 42 
     | 
    
         
            +
                      'name1' => 'value1',
         
     | 
| 
      
 43 
     | 
    
         
            +
                      'name2' => 'value2',
         
     | 
| 
      
 44 
     | 
    
         
            +
                      'name3' => ['value 3a', 'value 3b']
         
     | 
| 
      
 45 
     | 
    
         
            +
                    }
         
     | 
| 
      
 46 
     | 
    
         
            +
                  }
         
     | 
| 
      
 47 
     | 
    
         
            +
                ]
         
     | 
| 
       45 
48 
     | 
    
         | 
| 
       46 
49 
     | 
    
         
             
                message.descriptor[:format] = WMQ::MQFMT_STRING
         
     | 
| 
       47 
50 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                queue.put(:message 
     | 
| 
      
 51 
     | 
    
         
            +
                queue.put(message: message)
         
     | 
| 
       49 
52 
     | 
    
         
             
              end
         
     | 
| 
       50 
53 
     | 
    
         
             
            end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
    
        data/examples/put_rfh2_a.rb
    CHANGED
    
    | 
         @@ -2,26 +2,25 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a message to a queue with a Refernce header
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
            # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
         
     | 
| 
       9 
8 
     | 
    
         
             
            # to the data.
         
     | 
| 
       10 
9 
     | 
    
         
             
            #
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                message = WMQ::Message.new
         
     | 
| 
      
 10 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 11 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 12 
     | 
    
         
            +
                message      = WMQ::Message.new
         
     | 
| 
       15 
13 
     | 
    
         
             
                message.data = 'Hello World'
         
     | 
| 
       16 
14 
     | 
    
         | 
| 
       17 
15 
     | 
    
         
             
                message.headers = [
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                  {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    header_type: :rf_header_2,
         
     | 
| 
      
 18 
     | 
    
         
            +
                    xml:         '<hello>to the world</hello>'
         
     | 
| 
      
 19 
     | 
    
         
            +
                  }
         
     | 
| 
      
 20 
     | 
    
         
            +
                ]
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                message.descriptor[:format] = WMQ::MQFMT_STRING
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                queue.put(:message 
     | 
| 
      
 24 
     | 
    
         
            +
                queue.put(message: message)
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         
             
            end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
    
        data/examples/put_rfh2_b.rb
    CHANGED
    
    | 
         @@ -2,26 +2,26 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a message to a queue with a Refernce header
         
     | 
| 
       3 
3 
     | 
    
         
             
            #          Open the queue so that multiple puts can be performed
         
     | 
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
            # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
         
     | 
| 
       9 
8 
     | 
    
         
             
            # to the data.
         
     | 
| 
       10 
9 
     | 
    
         
             
            #
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                message = WMQ::Message.new
         
     | 
| 
      
 10 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 11 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 12 
     | 
    
         
            +
                message      = WMQ::Message.new
         
     | 
| 
       15 
13 
     | 
    
         
             
                message.data = 'Hello World'
         
     | 
| 
       16 
14 
     | 
    
         | 
| 
       17 
15 
     | 
    
         
             
                message.headers = [
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                  {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    header_type: :rf_header_2,
         
     | 
| 
      
 18 
     | 
    
         
            +
                    xml:         ['<hello>to the world</hello>', '<another>xml like string</another>'],
         
     | 
| 
      
 19 
     | 
    
         
            +
                  }
         
     | 
| 
      
 20 
     | 
    
         
            +
                ]
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                message.descriptor[:format] = WMQ::MQFMT_STRING
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                queue.put(:message 
     | 
| 
      
 24 
     | 
    
         
            +
                queue.put(message: message)
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         
             
            end
         
     | 
| 
       27 
27 
     | 
    
         | 
    
        data/examples/put_xmit_q.rb
    CHANGED
    
    | 
         @@ -1,17 +1,72 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Sample : put() : Put a message to a queue with a Transmission header
         
     | 
| 
       3 
3 
     | 
    
         
             
            #
         
     | 
| 
       4 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       5 
4 
     | 
    
         
             
            require 'wmq'
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            WMQ::QueueManager.connect(: 
     | 
| 
       8 
     | 
    
         
            -
              qmgr.open_queue(: 
     | 
| 
       9 
     | 
    
         
            -
                message 
     | 
| 
       10 
     | 
    
         
            -
                message.data 
     | 
| 
       11 
     | 
    
         
            -
                message.descriptor = { 
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
            WMQ::QueueManager.connect(q_mgr_name: 'REID') do |qmgr|
         
     | 
| 
      
 7 
     | 
    
         
            +
              qmgr.open_queue(q_name: 'TEST.QUEUE', mode: :output) do |queue|
         
     | 
| 
      
 8 
     | 
    
         
            +
                message            = WMQ::Message.new
         
     | 
| 
      
 9 
     | 
    
         
            +
                message.data       = "Test message from 'LOCALQMS1'"
         
     | 
| 
      
 10 
     | 
    
         
            +
                message.descriptor = {
         
     | 
| 
      
 11 
     | 
    
         
            +
                  original_length:    -1,
         
     | 
| 
      
 12 
     | 
    
         
            +
                  priority:           0,
         
     | 
| 
      
 13 
     | 
    
         
            +
                  put_time:           '18510170',
         
     | 
| 
      
 14 
     | 
    
         
            +
                  msg_id:             "AMQ LOCALQMS1   E\233\001\237 \000\003\005",
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expiry:             -1,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  persistence:        0,
         
     | 
| 
      
 17 
     | 
    
         
            +
                  reply_to_q:         'MQMON',
         
     | 
| 
      
 18 
     | 
    
         
            +
                  correl_id:          "AMQ LOCALQMS1   E\233\001\237 \000\003\004",
         
     | 
| 
      
 19 
     | 
    
         
            +
                  feedback:           0,
         
     | 
| 
      
 20 
     | 
    
         
            +
                  offset:             0,
         
     | 
| 
      
 21 
     | 
    
         
            +
                  report:             0,
         
     | 
| 
      
 22 
     | 
    
         
            +
                  msg_flags:          0,
         
     | 
| 
      
 23 
     | 
    
         
            +
                  reply_to_q_mgr:     'LOCALQMS1',
         
     | 
| 
      
 24 
     | 
    
         
            +
                  appl_identity_data: '',
         
     | 
| 
      
 25 
     | 
    
         
            +
                  put_appl_name:      'LOCALQMS1',
         
     | 
| 
      
 26 
     | 
    
         
            +
                  user_identifier:    'mqm',
         
     | 
| 
      
 27 
     | 
    
         
            +
                  msg_seq_number:     1,
         
     | 
| 
      
 28 
     | 
    
         
            +
                  appl_origin_data:   '',
         
     | 
| 
      
 29 
     | 
    
         
            +
                  accounting_token:   "\026\001\005\025\000\000\000\271U\305\002\261\022\362\321\021D\3206\357\003\000\000\000\000\000\000\000\000\000\000\v",
         
     | 
| 
      
 30 
     | 
    
         
            +
                  backout_count:      0,
         
     | 
| 
      
 31 
     | 
    
         
            +
                  coded_char_set_id:  437,
         
     | 
| 
      
 32 
     | 
    
         
            +
                  put_appl_type:      7,
         
     | 
| 
      
 33 
     | 
    
         
            +
                  msg_type:           8,
         
     | 
| 
      
 34 
     | 
    
         
            +
                  group_id:           '',
         
     | 
| 
      
 35 
     | 
    
         
            +
                  put_date:           '20070109',
         
     | 
| 
      
 36 
     | 
    
         
            +
                  format:             'MQSTR',
         
     | 
| 
      
 37 
     | 
    
         
            +
                  encoding:           546
         
     | 
| 
      
 38 
     | 
    
         
            +
                }
         
     | 
| 
      
 39 
     | 
    
         
            +
                message.headers    =
         
     | 
| 
      
 40 
     | 
    
         
            +
                  [
         
     | 
| 
      
 41 
     | 
    
         
            +
                    {
         
     | 
| 
      
 42 
     | 
    
         
            +
                      priority:           0,
         
     | 
| 
      
 43 
     | 
    
         
            +
                      remote_q_mgr_name:  'OTHER.QMGR',
         
     | 
| 
      
 44 
     | 
    
         
            +
                      put_time:           '18510170',
         
     | 
| 
      
 45 
     | 
    
         
            +
                      msg_id:             "AMQ LOCALQMS1   E\233\001\237 \000\003\004",
         
     | 
| 
      
 46 
     | 
    
         
            +
                      expiry:             -1,
         
     | 
| 
      
 47 
     | 
    
         
            +
                      persistence:        0,
         
     | 
| 
      
 48 
     | 
    
         
            +
                      remote_q_name:      'OTHER.Q',
         
     | 
| 
      
 49 
     | 
    
         
            +
                      header_type:        :xmit_q_header,
         
     | 
| 
      
 50 
     | 
    
         
            +
                      reply_to_q:         'MQMON',
         
     | 
| 
      
 51 
     | 
    
         
            +
                      correl_id:          '',
         
     | 
| 
      
 52 
     | 
    
         
            +
                      feedback:           0,
         
     | 
| 
      
 53 
     | 
    
         
            +
                      report:             0,
         
     | 
| 
      
 54 
     | 
    
         
            +
                      reply_to_q_mgr:     'LOCALQMS1',
         
     | 
| 
      
 55 
     | 
    
         
            +
                      appl_identity_data: '',
         
     | 
| 
      
 56 
     | 
    
         
            +
                      put_appl_name:      "uments\\MQ\\MQMon\\mqmonntp.exe",
         
     | 
| 
      
 57 
     | 
    
         
            +
                      user_identifier:    'mqm',
         
     | 
| 
      
 58 
     | 
    
         
            +
                      appl_origin_data:   '',
         
     | 
| 
      
 59 
     | 
    
         
            +
                      accounting_token:   "\026\001\005\025\000\000\000\271U\305\002\261\022\362\321\021D\3206\357\003\000\000\000\000\000\000\000\000\000\000\v",
         
     | 
| 
      
 60 
     | 
    
         
            +
                      backout_count:      0,
         
     | 
| 
      
 61 
     | 
    
         
            +
                      coded_char_set_id:  437,
         
     | 
| 
      
 62 
     | 
    
         
            +
                      put_appl_type:      11,
         
     | 
| 
      
 63 
     | 
    
         
            +
                      msg_type:           8,
         
     | 
| 
      
 64 
     | 
    
         
            +
                      put_date:           '20070109',
         
     | 
| 
      
 65 
     | 
    
         
            +
                      encoding:           546
         
     | 
| 
      
 66 
     | 
    
         
            +
                    }
         
     | 
| 
      
 67 
     | 
    
         
            +
                  ]
         
     | 
| 
       13 
68 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                queue.put(:message 
     | 
| 
      
 69 
     | 
    
         
            +
                queue.put(message: message)
         
     | 
| 
       15 
70 
     | 
    
         
             
              end
         
     | 
| 
       16 
71 
     | 
    
         
             
            end
         
     | 
| 
       17 
72 
     | 
    
         |