rubywmq 0.3.0-i386-mswin32-mq6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/LICENSE +13 -0
  2. data/README +73 -0
  3. data/doc/classes/WMQ.html +6300 -0
  4. data/doc/classes/WMQ/Message.html +376 -0
  5. data/doc/classes/WMQ/Message.src/M000001.html +77 -0
  6. data/doc/classes/WMQ/Message.src/M000002.html +27 -0
  7. data/doc/classes/WMQ/Queue.html +1459 -0
  8. data/doc/classes/WMQ/Queue.src/M000003.html +205 -0
  9. data/doc/classes/WMQ/Queue.src/M000004.html +107 -0
  10. data/doc/classes/WMQ/Queue.src/M000005.html +198 -0
  11. data/doc/classes/WMQ/Queue.src/M000006.html +66 -0
  12. data/doc/classes/WMQ/Queue.src/M000007.html +203 -0
  13. data/doc/classes/WMQ/Queue.src/M000008.html +265 -0
  14. data/doc/classes/WMQ/Queue.src/M000009.html +120 -0
  15. data/doc/classes/WMQ/Queue.src/M000010.html +28 -0
  16. data/doc/classes/WMQ/Queue.src/M000011.html +30 -0
  17. data/doc/classes/WMQ/Queue.src/M000012.html +31 -0
  18. data/doc/classes/WMQ/Queue.src/M000013.html +31 -0
  19. data/doc/classes/WMQ/Queue.src/M000014.html +31 -0
  20. data/doc/classes/WMQ/QueueManager.html +1529 -0
  21. data/doc/classes/WMQ/QueueManager.src/M000015.html +182 -0
  22. data/doc/classes/WMQ/QueueManager.src/M000016.html +194 -0
  23. data/doc/classes/WMQ/QueueManager.src/M000017.html +92 -0
  24. data/doc/classes/WMQ/QueueManager.src/M000018.html +70 -0
  25. data/doc/classes/WMQ/QueueManager.src/M000019.html +49 -0
  26. data/doc/classes/WMQ/QueueManager.src/M000020.html +49 -0
  27. data/doc/classes/WMQ/QueueManager.src/M000021.html +63 -0
  28. data/doc/classes/WMQ/QueueManager.src/M000022.html +61 -0
  29. data/doc/classes/WMQ/QueueManager.src/M000023.html +65 -0
  30. data/doc/classes/WMQ/QueueManager.src/M000024.html +232 -0
  31. data/doc/classes/WMQ/QueueManager.src/M000025.html +30 -0
  32. data/doc/classes/WMQ/QueueManager.src/M000026.html +31 -0
  33. data/doc/classes/WMQ/QueueManager.src/M000027.html +31 -0
  34. data/doc/classes/WMQ/QueueManager.src/M000028.html +38 -0
  35. data/doc/classes/WMQ/QueueManager.src/M000029.html +33 -0
  36. data/doc/classes/WMQ/QueueManager.src/M000030.html +21 -0
  37. data/doc/classes/WMQ/QueueManager.src/M000031.html +284 -0
  38. data/doc/classes/WMQ/QueueManager.src/M000032.html +24 -0
  39. data/doc/classes/WMQ/QueueManager.src/M000033.html +18 -0
  40. data/doc/classes/WMQ/QueueManager.src/M000034.html +46 -0
  41. data/doc/classes/WMQ/QueueManager.src/M000035.html +27 -0
  42. data/doc/classes/WMQ/WMQException.html +111 -0
  43. data/doc/created.rid +1 -0
  44. data/doc/files/ext/lib/wmq_const_admin_rb.html +128 -0
  45. data/doc/files/ext/lib/wmq_const_rb.html +128 -0
  46. data/doc/files/ext/lib/wmq_temp_rb.html +122 -0
  47. data/doc/files/ext/wmq_c.html +101 -0
  48. data/doc/files/ext/wmq_message_c.html +101 -0
  49. data/doc/files/ext/wmq_queue_c.html +101 -0
  50. data/doc/files/ext/wmq_queue_manager_c.html +101 -0
  51. data/doc/fr_class_index.html +31 -0
  52. data/doc/fr_file_index.html +33 -0
  53. data/doc/fr_method_index.html +61 -0
  54. data/doc/index.html +24 -0
  55. data/doc/rdoc-style.css +208 -0
  56. data/examples/each_a.rb +31 -0
  57. data/examples/each_b.rb +40 -0
  58. data/examples/each_header.rb +37 -0
  59. data/examples/files_to_q.cfg +24 -0
  60. data/examples/files_to_q.rb +46 -0
  61. data/examples/get_a.rb +34 -0
  62. data/examples/get_client.rb +50 -0
  63. data/examples/put1_a.rb +24 -0
  64. data/examples/put1_b.rb +32 -0
  65. data/examples/put1_c.rb +31 -0
  66. data/examples/put_a.rb +34 -0
  67. data/examples/put_b.rb +42 -0
  68. data/examples/put_dlh.rb +40 -0
  69. data/examples/put_dynamic_q.rb +37 -0
  70. data/examples/put_rfh.rb +66 -0
  71. data/examples/put_rfh2_a.rb +42 -0
  72. data/examples/put_rfh2_b.rb +42 -0
  73. data/examples/put_xmit_q.rb +32 -0
  74. data/examples/q_to_files.cfg +17 -0
  75. data/examples/q_to_files.rb +47 -0
  76. data/examples/request.rb +59 -0
  77. data/examples/server.rb +96 -0
  78. data/lib/wmq.rb +25 -0
  79. data/lib/wmq/wmq.so +0 -0
  80. data/lib/wmq/wmq_const.rb +745 -0
  81. data/lib/wmq/wmq_const_admin.rb +555 -0
  82. data/lib/wmq/wmq_temp.rb +197 -0
  83. data/tests/test.rb +299 -0
  84. metadata +131 -0
@@ -0,0 +1,66 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>close (WMQ::Queue)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/*
14
+ * Close the queue
15
+ *
16
+ * Returns:
17
+ * * true : On Success
18
+ * * false: On Failure
19
+ *
20
+ * comp_code and reason_code are also updated.
21
+ * reason will return a text description of the reason_code
22
+ *
23
+ * Throws:
24
+ * * WMQ::WMQException if comp_code == MQCC_FAILED
25
+ * * Except if :exception_on_error =&gt; false was supplied as a parameter
26
+ * to QueueManager.new
27
+ */
28
+ VALUE Queue_close(VALUE self)
29
+ {
30
+ PQUEUE pq;
31
+ Data_Get_Struct(self, QUEUE, pq);
32
+
33
+ /* Check if queue is open */
34
+ if (!pq-&gt;hcon)
35
+ {
36
+ if(pq-&gt;trace_level) printf (&quot;WMQ::Queue#close() Queue not open\n&quot;);
37
+ return Qtrue;
38
+ }
39
+
40
+ if(pq-&gt;trace_level) printf (&quot;WMQ::Queue#close() Queue Handle:%ld, Queue Manager Handle:%ld\n&quot;, pq-&gt;hobj, pq-&gt;hcon);
41
+
42
+ pq-&gt;MQCLOSE(pq-&gt;hcon, &amp;pq-&gt;hobj, pq-&gt;close_options, &amp;pq-&gt;comp_code, &amp;pq-&gt;reason_code);
43
+
44
+ pq-&gt;hcon = 0; /* Every time the queue is opened, the qmgr handle must be fetched again! */
45
+ pq-&gt;hobj = 0;
46
+
47
+ if(pq-&gt;trace_level) printf(&quot;WMQ::Queue#close() MQCLOSE ended with reason:%s\n&quot;, wmq_reason(pq-&gt;reason_code));
48
+
49
+ if (pq-&gt;comp_code == MQCC_FAILED)
50
+ {
51
+ if (pq-&gt;exception_on_error)
52
+ {
53
+ VALUE name = Queue_name(self);
54
+
55
+ rb_raise(wmq_exception,
56
+ &quot;WMQ::Queue#close(). Error closing Queue:%s, reason:%s&quot;,
57
+ RSTRING(name)-&gt;ptr,
58
+ wmq_reason(pq-&gt;reason_code));
59
+ }
60
+ return Qfalse;
61
+ }
62
+
63
+ return Qtrue;
64
+ }</pre>
65
+ </body>
66
+ </html>
@@ -0,0 +1,203 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>put (WMQ::Queue)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/*
14
+ * call-seq:
15
+ * put(...)
16
+ *
17
+ * Put a message to the WebSphere MQ queue
18
+ *
19
+ * Parameters:
20
+ * * A Hash consisting of one or more of the named parameters
21
+ * * Summary of parameters and their WebSphere MQ equivalents
22
+ * queue.put( # WebSphere MQ Equivalents:
23
+ * :message =&gt; my_message, # n/a : Instance of Message
24
+ * :data =&gt; &quot;Hello World&quot;, # n/a : Data to send
25
+ * :sync =&gt; false, # MQGMO_SYNCPOINT
26
+ * :new_id =&gt; true, # MQPMO_NEW_MSG_ID &amp; MQPMO_NEW_CORREL_ID
27
+ * :new_msg_id =&gt; true, # MQPMO_NEW_MSG_ID
28
+ * :new_correl_id =&gt; true, # MQPMO_NEW_CORREL_ID
29
+ * :fail_if_quiescing =&gt; true, # MQOO_FAIL_IF_QUIESCING
30
+ * :options =&gt; WMQ::MQPMO_FAIL_IF_QUIESCING # MQPMO_*
31
+ * )
32
+ *
33
+ * Mandatory Parameters:
34
+ *
35
+ * * Either :message or :data must be supplied
36
+ * * If both are supplied, then :data will be written to the queue. The data in :message
37
+ * will be ignored
38
+ *
39
+ * Optional Parameters:
40
+ * * :data =&gt; String
41
+ * * Data to be written to the queue. Can be binary or text data
42
+ * * Takes precendence over the data in :message
43
+ *
44
+ * * :message =&gt; Message
45
+ * * An instance of the WMQ::Message
46
+ * * The Message descriptor, headers and data is retrieved from :message
47
+ * * message.data is ignored if :data is supplied
48
+ *
49
+ * * :sync =&gt; true or false
50
+ * * Determines whether the get is performed under synchpoint.
51
+ * I.e. Under the current unit of work
52
+ * Default: false
53
+ *
54
+ * * :new_id =&gt; true or false
55
+ * * Generate a new message id and correlation id for this
56
+ * message. :new_msg_id and :new_correl_id will be ignored
57
+ * if this parameter is true
58
+ * Default: false
59
+ *
60
+ * * :new_msg_id =&gt; true or false
61
+ * * Generate a new message id for this message
62
+ * * Note: A blank message id will result in a new message id anyway.
63
+ * However, for subsequent puts using the same message descriptor, the same
64
+ * message id will be used.
65
+ * Default: false
66
+ *
67
+ * * :new_correl_id =&gt; true or false
68
+ * * Generate a new correlation id for this message
69
+ * Default: false
70
+ *
71
+ * * :fail_if_quiescing =&gt; true or false
72
+ * * Determines whether the WMQ::Queue#put call will fail if the queue manager is
73
+ * in the process of being quiesced.
74
+ * * Note: This interface differs from other WebSphere MQ interfaces,
75
+ * they do not default to true.
76
+ * Default: true
77
+ * Equivalent to: MQGMO_FAIL_IF_QUIESCING
78
+ *
79
+ * * Note: As part of the application design, carefull consideration
80
+ * should be given as to when to allow a transaction or
81
+ * unit of work to complete or fail under this condition.
82
+ * As such it is important to include this option where
83
+ * appropriate so that MQ Administrators can shutdown the
84
+ * queue managers without having to resort to the 'immediate'
85
+ * shutdown option.
86
+ *
87
+ * * :options =&gt; Fixnum (Advanced MQ Use only)
88
+ * * Numeric field containing any of the MQ Put message options or'd together
89
+ * * E.g. :options =&gt; WMQ::MQPMO_PASS_IDENTITY_CONTEXT | WMQ::MQPMO_ALTERNATE_USER_AUTHORITY
90
+ * * Note: If :options is supplied, it is applied first, then the above parameters are
91
+ * applied afterwards.
92
+ * * One or more of the following values:
93
+ * WMQ::MQPMO_NO_SYNCPOINT
94
+ * WMQ::MQPMO_LOGICAL_ORDER
95
+ * WMQ::MQPMO_NO_CONTEXT
96
+ * WMQ::MQPMO_DEFAULT_CONTEXT
97
+ * WMQ::MQPMO_PASS_IDENTITY_CONTEXT
98
+ * WMQ::MQPMO_PASS_ALL_CONTEXT
99
+ * WMQ::MQPMO_SET_IDENTITY_CONTEXT
100
+ * WMQ::MQPMO_SET_ALL_CONTEXT
101
+ * WMQ::MQPMO_ALTERNATE_USER_AUTHORITY
102
+ * WMQ::MQPMO_RESOLVE_LOCAL_Q
103
+ * WMQ::MQPMO_NONE
104
+ * * Please see the WebSphere MQ documentation for more details on the above options
105
+ * Default: WMQ::MQPMO_NONE
106
+ *
107
+ * Returns:
108
+ * * true : On Success
109
+ * * false: On Failure
110
+ *
111
+ * comp_code and reason_code are also updated.
112
+ * reason will return a text description of the reason_code
113
+ *
114
+ * Throws:
115
+ * * WMQ::WMQException if comp_code == MQCC_FAILED
116
+ * * Except if :exception_on_error =&gt; false was supplied as a parameter
117
+ * to QueueManager.new
118
+ *
119
+ * Example:
120
+ * require 'wmq/wmq_client'
121
+ *
122
+ * WMQ::QueueManager.connect(:q_mgr_name=&gt;'REID', :connection_name=&gt;'localhost(1414)') do |qmgr|
123
+ * qmgr.open_queue(:q_name=&gt;'TEST.QUEUE', :mode=&gt;:output) do |queue|
124
+ *
125
+ * # First message
126
+ * queue.put(:data =&gt; 'Hello World')
127
+ *
128
+ * # Set Format of message to string
129
+ * message = WMQ::Message.new
130
+ * message.descriptor[:format] = WMQ::MQFMT_STRING
131
+ * queue.put(:message=&gt;message, :data =&gt; 'Hello Again')
132
+ *
133
+ * # Or, pass the data in the message
134
+ * message = WMQ::Message.new
135
+ * message.descriptor[:format] = WMQ::MQFMT_STRING
136
+ * message.data = 'Hello Again'
137
+ * queue.put(:message=&gt;message)
138
+ * end
139
+ * end
140
+ */
141
+ VALUE Queue_put(VALUE self, VALUE hash)
142
+ {
143
+ MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */
144
+ MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
145
+ PQUEUE pq;
146
+ MQLONG BufferLength = 0; /* Length of the message in Buffer */
147
+ PMQVOID pBuffer = 0; /* Message data */
148
+
149
+ Check_Type(hash, T_HASH);
150
+
151
+ Data_Get_Struct(self, QUEUE, pq);
152
+
153
+ /* Automatically open the queue if not already open */
154
+ if (!pq-&gt;hcon &amp;&amp; (Queue_open(self) == Qfalse))
155
+ {
156
+ return Qfalse;
157
+ }
158
+
159
+ Queue_extract_put_message_options(hash, &amp;pmo);
160
+ Message_build(&amp;pq-&gt;p_buffer, &amp;pq-&gt;buffer_size, pq-&gt;trace_level,
161
+ hash, &amp;pBuffer, &amp;BufferLength, &amp;md);
162
+
163
+ if(pq-&gt;trace_level) printf(&quot;WMQ::Queue#put() Queue Handle:%ld, Queue Manager Handle:%ld\n&quot;, pq-&gt;hobj, pq-&gt;hcon);
164
+
165
+ pq-&gt;MQPUT(
166
+ pq-&gt;hcon, /* connection handle */
167
+ pq-&gt;hobj, /* object handle */
168
+ &amp;md, /* message descriptor */
169
+ &amp;pmo, /* put message options */
170
+ BufferLength, /* message length */
171
+ pBuffer, /* message buffer */
172
+ &amp;pq-&gt;comp_code, /* completion code */
173
+ &amp;pq-&gt;reason_code); /* reason code */
174
+
175
+ if(pq-&gt;trace_level) printf(&quot;WMQ::Queue#put() MQPUT ended with reason:%s\n&quot;, wmq_reason(pq-&gt;reason_code));
176
+
177
+ if (pq-&gt;reason_code != MQRC_NONE)
178
+ {
179
+ if (pq-&gt;exception_on_error)
180
+ {
181
+ VALUE name = Queue_name(self);
182
+
183
+ rb_raise(wmq_exception,
184
+ &quot;WMQ::Queue#put(). Error writing a message to Queue:%s, reason:%s&quot;,
185
+ RSTRING(name)-&gt;ptr,
186
+ wmq_reason(pq-&gt;reason_code));
187
+ }
188
+ return Qfalse;
189
+ }
190
+ else
191
+ {
192
+ VALUE message = rb_hash_aref(hash, ID2SYM(ID_message));
193
+ if(!NIL_P(message))
194
+ {
195
+ VALUE descriptor = rb_funcall(message, ID_descriptor, 0);
196
+ Message_from_mqmd(descriptor, &amp;md); /* This should be optimized to output only fields */
197
+ }
198
+ }
199
+
200
+ return Qtrue;
201
+ }</pre>
202
+ </body>
203
+ </html>
@@ -0,0 +1,265 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>get (WMQ::Queue)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/*
14
+ * call-seq:
15
+ * get(...)
16
+ *
17
+ * Get a message from the opened queue
18
+ *
19
+ * Parameters:
20
+ * * a Hash consisting of one or more of the named parameters
21
+ * * Summary of parameters and their WebSphere MQ equivalents:
22
+ * queue.get( # WebSphere MQ Equivalents:
23
+ * :message =&gt; my_message, # n/a : Instance of Message
24
+ * :sync =&gt; false, # MQGMO_SYNCPOINT
25
+ * :wait =&gt; 0, # MQGMO_WAIT, duration in ms
26
+ * :match =&gt; WMQ::MQMO_NONE, # MQMO_*
27
+ * :convert =&gt; false, # MQGMO_CONVERT
28
+ * :fail_if_quiescing =&gt; true # MQOO_FAIL_IF_QUIESCING
29
+ * :options =&gt; WMQ::MQGMO_FAIL_IF_QUIESCING # MQGMO_*
30
+ * )
31
+ *
32
+ * Mandatory Parameters
33
+ * * :message =&gt; Message
34
+ * * An instance of the WMQ::Message
35
+ *
36
+ * Optional Parameters
37
+ * * :sync =&gt; true or false
38
+ * * Determines whether the get is performed under synchpoint.
39
+ * I.e. Under the current unit of work
40
+ * Default: false
41
+ *
42
+ * * :wait =&gt; FixNum
43
+ * * The time in milli-seconds to wait for a message if one is not immediately available
44
+ * on the queue
45
+ * * Note: Under the covers the put option MQGMO_WAIT is automatically set when :wait
46
+ * is supplied
47
+ * Default: Wait forever
48
+ *
49
+ * * :match =&gt; FixNum
50
+ * * One or more of the following values:
51
+ * WMQ::MQMO_MATCH_MSG_ID
52
+ * WMQ::MQMO_MATCH_CORREL_ID
53
+ * WMQ::MQMO_MATCH_GROUP_ID
54
+ * WMQ::MQMO_MATCH_MSG_SEQ_NUMBER
55
+ * WMQ::MQMO_MATCH_OFFSET
56
+ * WMQ::MQMO_MATCH_MSG_TOKEN
57
+ * WMQ::MQMO_NONE
58
+ * * Multiple values can be or'd together. E.g.
59
+ * :match=&gt;WMQ::MQMO_MATCH_MSG_ID | WMQ::MQMO_MATCH_CORREL_ID
60
+ * * Please see the WebSphere MQ documentation for more details on the above options
61
+ * Default: WMQ::MQMO_MATCH_MSG_ID | WMQ::MQMO_MATCH_CORREL_ID
62
+ *
63
+ * * :convert =&gt; true or false
64
+ * * When true, convert results in messages being converted to the local code page.
65
+ * E.g. When an EBCDIC text message from a mainframe is received, it will be converted
66
+ * to ASCII before passing the message data to the application.
67
+ * Default: false
68
+ *
69
+ * * :fail_if_quiescing =&gt; true or false
70
+ * * Determines whether the WMQ::Queue#get call will fail if the queue manager is
71
+ * in the process of being quiesced.
72
+ * * Note: This interface differs from other WebSphere MQ interfaces,
73
+ * they do not default to true.
74
+ * Default: true
75
+ *
76
+ * * :options =&gt; Fixnum (Advanced MQ Use only)
77
+ * * Numeric field containing any of the MQ Get message options or'd together
78
+ * * E.g. :options =&gt; WMQ::MQGMO_SYNCPOINT_IF_PERSISTENT | WMQ::MQGMO_MARK_SKIP_BACKOUT
79
+ * * Note: If :options is supplied, it is applied first, then the above parameters are
80
+ * applied afterwards.
81
+ * * One or more of the following values:
82
+ * WMQ::MQGMO_SYNCPOINT_IF_PERSISTENT
83
+ * WMQ::MQGMO_NO_SYNCPOINT
84
+ * WMQ::MQGMO_MARK_SKIP_BACKOUT
85
+ * WMQ::MQGMO_BROWSE_FIRST
86
+ * WMQ::MQGMO_BROWSE_NEXT
87
+ * WMQ::MQGMO_BROWSE_MSG_UNDER_CURSOR
88
+ * WMQ::MQGMO_MSG_UNDER_CURSOR
89
+ * WMQ::MQGMO_LOCK
90
+ * WMQ::MQGMO_UNLOCK
91
+ * WMQ::MQGMO_LOGICAL_ORDER
92
+ * WMQ::MQGMO_COMPLETE_MSG
93
+ * WMQ::MQGMO_ALL_MSGS_AVAILABLE
94
+ * WMQ::MQGMO_ALL_SEGMENTS_AVAILABLE
95
+ * WMQ::MQGMO_DELETE_MSG
96
+ * WMQ::MQGMO_NONE
97
+ * * Please see the WebSphere MQ documentation for more details on the above options
98
+ * Default: WMQ::MQGMO_NONE
99
+ *
100
+ * Returns:
101
+ * * true : On Success
102
+ * * false: On Failure, or if no message was found on the queue during the wait interval
103
+ *
104
+ * comp_code and reason_code are also updated.
105
+ * reason will return a text description of the reason_code
106
+ *
107
+ * Throws:
108
+ * * WMQ::WMQException if comp_code == MQCC_FAILED
109
+ * * Except if :exception_on_error =&gt; false was supplied as a parameter
110
+ * to QueueManager.new
111
+ *
112
+ * Example:
113
+ * require 'wmq/wmq'
114
+ *
115
+ * WMQ::QueueManager.connect(:q_mgr_name=&gt;'REID') do |qmgr|
116
+ * qmgr.open_queue(:q_name=&gt;'TEST.QUEUE', :mode=&gt;:input) do |queue|
117
+ * message = WMQ::Message.new
118
+ * if queue.get(:message =&gt; message)
119
+ * puts &quot;Data Received: #{message.data}&quot;
120
+ * else
121
+ * puts 'No message available'
122
+ * end
123
+ * end
124
+ * end
125
+ */
126
+ VALUE Queue_get(VALUE self, VALUE hash)
127
+ {
128
+ VALUE handle;
129
+ VALUE val;
130
+ VALUE str;
131
+ VALUE descriptor;
132
+ VALUE data;
133
+ VALUE message;
134
+ PQUEUE pq;
135
+ MQLONG flag;
136
+ MQLONG messlen; /* message length received */
137
+
138
+ MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
139
+ MQGMO gmo = {MQGMO_DEFAULT}; /* get message options */
140
+
141
+ gmo.Version = MQGMO_CURRENT_VERSION; /* Allow MatchOptions */
142
+
143
+ Check_Type(hash, T_HASH);
144
+
145
+ Data_Get_Struct(self, QUEUE, pq);
146
+
147
+ /* Automatically open the queue if not already open */
148
+ if (!pq-&gt;hcon &amp;&amp; (Queue_open(self) == Qfalse))
149
+ {
150
+ return Qfalse;
151
+ }
152
+
153
+ message = rb_hash_aref(hash, ID2SYM(ID_message));
154
+ if (NIL_P(message))
155
+ {
156
+ VALUE name = Queue_name(self);
157
+
158
+ rb_raise(rb_eArgError,
159
+ &quot;Mandatory key :message is missing from hash passed to get() for Queue: %s&quot;,
160
+ RSTRING(name)-&gt;ptr);
161
+ }
162
+
163
+ Message_build_mqmd(message, &amp;md);
164
+
165
+ WMQ_HASH2MQLONG(hash,options, gmo.Options) /* :options */
166
+
167
+ IF_TRUE(sync, 0) /* :sync defaults to false */
168
+ {
169
+ gmo.Options |= MQGMO_SYNCPOINT;
170
+ }
171
+
172
+ IF_TRUE(fail_if_quiescing, 1) /* :fail_if_quiescing defaults to true */
173
+ {
174
+ gmo.Options |= MQGMO_FAIL_IF_QUIESCING;
175
+ }
176
+
177
+ IF_TRUE(convert, 0) /* :convert defaults to false */
178
+ {
179
+ gmo.Options |= MQGMO_CONVERT;
180
+ }
181
+
182
+ val = rb_hash_aref(hash, ID2SYM(ID_wait)); /* :wait */
183
+ if (!NIL_P(val))
184
+ {
185
+ gmo.Options |= MQGMO_WAIT;
186
+ gmo.WaitInterval = NUM2LONG(val);
187
+ }
188
+
189
+ WMQ_HASH2MQLONG(hash,match, gmo.MatchOptions) /* :match */
190
+
191
+ if(pq-&gt;trace_level &gt; 1) printf(&quot;WMQ::Queue#get() Get Message Option: MatchOptions=%ld\n&quot;, gmo.MatchOptions);
192
+ if(pq-&gt;trace_level) printf(&quot;WMQ::Queue#get() Queue Handle:%ld, Queue Manager Handle:%ld\n&quot;, pq-&gt;hobj, pq-&gt;hcon);
193
+
194
+ /* If descriptor is re-used
195
+
196
+ md.Encoding = MQENC_NATIVE;
197
+ md.CodedCharSetId = MQCCSI_Q_MGR;
198
+ */
199
+
200
+ /*
201
+ * Auto-Grow buffer size
202
+ *
203
+ * Note: If msg size is 70,000, we grow to 70,000, but then another program gets that
204
+ * message. The next message could be say 80,000 bytes in size, we need to
205
+ * grow the buffer again.
206
+ */
207
+ do
208
+ {
209
+ pq-&gt;MQGET(
210
+ pq-&gt;hcon, /* connection handle */
211
+ pq-&gt;hobj, /* object handle */
212
+ &amp;md, /* message descriptor */
213
+ &amp;gmo, /* get message options */
214
+ pq-&gt;buffer_size, /* message buffer size */
215
+ pq-&gt;p_buffer, /* message buffer */
216
+ &amp;messlen, /* message length */
217
+ &amp;pq-&gt;comp_code, /* completion code */
218
+ &amp;pq-&gt;reason_code); /* reason code */
219
+
220
+ /* report reason, if any */
221
+ if (pq-&gt;reason_code != MQRC_NONE)
222
+ {
223
+ if(pq-&gt;trace_level&gt;1) printf(&quot;WMQ::Queue#get() Growing buffer size from %ld to %ld\n&quot;, pq-&gt;buffer_size, messlen);
224
+ /* TODO: Add support for autogrow buffer here */
225
+ if (pq-&gt;reason_code == MQRC_TRUNCATED_MSG_FAILED)
226
+ {
227
+ if(pq-&gt;trace_level&gt;2)
228
+ printf (&quot;WMQ::Queue#reallocate Resizing buffer from %ld to %ld bytes\n&quot;, pq-&gt;buffer_size, messlen);
229
+
230
+ free(pq-&gt;p_buffer);
231
+ pq-&gt;buffer_size = messlen;
232
+ pq-&gt;p_buffer = ALLOC_N(char, messlen);
233
+ }
234
+ }
235
+ }
236
+ while (pq-&gt;reason_code == MQRC_TRUNCATED_MSG_FAILED);
237
+
238
+ if(pq-&gt;trace_level) printf(&quot;WMQ::Queue#get() MQGET ended with reason:%s\n&quot;, wmq_reason(pq-&gt;reason_code));
239
+
240
+ if (pq-&gt;comp_code != MQCC_FAILED)
241
+ {
242
+ Message_deblock(message, &amp;md, pq-&gt;p_buffer, messlen, pq-&gt;trace_level); /* Extract MQMD and any other known MQ headers */
243
+ return Qtrue;
244
+ }
245
+ else
246
+ {
247
+ Message_clear(message);
248
+
249
+ /* --------------------------------------------------
250
+ * Do not throw exception when no more messages to be read
251
+ * --------------------------------------------------*/
252
+ if (pq-&gt;exception_on_error &amp;&amp; (pq-&gt;reason_code != MQRC_NO_MSG_AVAILABLE))
253
+ {
254
+ VALUE name = Queue_name(self);
255
+
256
+ rb_raise(wmq_exception,
257
+ &quot;WMQ::Queue#get(). Error reading a message from Queue:%s, reason:%s&quot;,
258
+ RSTRING(name)-&gt;ptr,
259
+ wmq_reason(pq-&gt;reason_code));
260
+ }
261
+ return Qfalse;
262
+ }
263
+ }</pre>
264
+ </body>
265
+ </html>