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,205 @@
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>open (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
+ * open(...)
16
+ *
17
+ * Open a queue, then close the queue once the supplied code block completes
18
+ *
19
+ * Parameters:
20
+ * * Since the number of parameters can vary dramatically, all parameters are passed by name in a hash
21
+ * * Summary of parameters and their WebSphere MQ equivalents:
22
+ * queue = Queue.new( # WebSphere MQ Equivalents:
23
+ * :queue_manager =&gt; queue_manager, # n/a : Instance of QueueManager
24
+ * :q_name =&gt; 'Queue Name', # MQOD.ObjectName
25
+ * :q_name =&gt; { queue_manager=&gt;'QMGR_name', # MQOD.ObjectQMgrName
26
+ * q_name =&gt;'q_name'}
27
+ * :mode =&gt; :input or :input_shared or :input_exclusive or :output,
28
+ * :fail_if_quiescing =&gt; true # MQOO_FAIL_IF_QUIESCING
29
+ * :fail_if_exists =&gt; true, # For dynamic queues, fail if it already exists
30
+ * :open_options =&gt; WMQ::MQOO_BIND_ON_OPEN | ... # MQOO_*
31
+ * :close_options =&gt; WMQ::MQCO_DELETE_PURGE # MQCO_*
32
+ * :dynamic_q_name =&gt; 'Name of Dynamic Queue' # MQOD.DynamicQName
33
+ * :alternate_user_id =&gt; 'userid', # MQOD.AlternateUserId
34
+ * :alternate_security_id =&gt; '' # MQOD.AlternateSecurityId
35
+ * )
36
+ *
37
+ * Mandatory Parameters
38
+ * * :queue_manager
39
+ * * An instance of the WMQ::QueueManager class. E.g. QueueManager.new
40
+ * * Note: This is _not_ the queue manager name!
41
+ *
42
+ * * :q_name =&gt; String
43
+ * * Name of the existing WebSphere MQ local queue, model queue or remote queue to open
44
+ * * To open remote queues for which a local remote queue definition is not available
45
+ * pass a Hash as q_name (see q_name =&gt; Hash)
46
+ * OR
47
+ * * :q_name =&gt; Hash
48
+ * * q_name =&gt; String
49
+ * * Name of the existing WebSphere MQ local queue, model queue or remote queue to open
50
+ * * :q_mgr_name =&gt; String
51
+ * * Name of the remote WebSphere MQ queue manager to send the message to.
52
+ * * This allows a message to be written to a queue on a remote queue manager
53
+ * where a remote queue definition is not defined locally
54
+ * * Commonly used to reply to messages from remote systems
55
+ * * If q_mgr_name is the same as the local queue manager name then the message
56
+ * is merely written to the local queue.
57
+ * * Note: q_mgr_name should only be supplied when putting messages to the queue.
58
+ * It is not possible to get messages from a queue on a queue manager other
59
+ * than the currently connected queue manager
60
+ *
61
+ * * :mode =&gt; Symbol
62
+ * * Specify how the queue is to be opened
63
+ * * :output
64
+ * * Open the queue for output. I.e. WMQ::Queue#put will be called
65
+ * Equivalent to: MQOO_OUTPUT
66
+ * * :input
67
+ * * Open the queue for input. I.e. WMQ::Queue#get will be called.
68
+ * * Queue sharing for reading from the queue is defined by the queue itself.
69
+ * By default most queues are set to shared. I.e. Multiple applications
70
+ * can read and/or write from the queue at the same time
71
+ * Equivalent to: MQOO_INPUT_AS_Q_DEF
72
+ * * :input_shared
73
+ * * Open the queue for input. I.e. WMQ::Queue#get will be called.
74
+ * * Explicitly open the queue so that other applications can read or write
75
+ * from the same queue
76
+ * Equivalent to: MQOO_INPUT_SHARED
77
+ * * :input_exclusive
78
+ * * Open the queue for input. I.e. WMQ::Queue#get will be called.
79
+ * * Explicitly open the queue so that other applications cannot read
80
+ * from the same queue. Does _not_ affect applications writing to the queue.
81
+ * * Note: If :input_exclusive is used and connectivity the queue manager is lost.
82
+ * Upon restart the queue can still be &quot;locked&quot;. The application should retry
83
+ * every minute or so until the queue becomes available. Otherwise, of course,
84
+ * another application has the queue open exclusively.
85
+ * Equivalent to: MQOO_INPUT_EXCLUSIVE
86
+ * * :browse
87
+ * * Browse the messages on the queue _without_ removing them from the queue
88
+ * * Open the queue for input. I.e. WMQ::Queue#get will be called.
89
+ * * Note: It is necessary to specify WMQ::MQGMO_BROWSE_FIRST before the
90
+ * first get, then set WMQ::MQGMO_BROWSE_NEXT for subsequent calls.
91
+ * * Note: For now it is also necessary to specify these options when calling
92
+ * WMQ::Queue#each. A change will be made to each to address this.
93
+ * Equivalent to: MQOO_BROWSE
94
+ *
95
+ * Optional Parameters
96
+ * * :fail_if_quiescing =&gt; true or false
97
+ * * Determines whether the WMQ::Queue#open call will fail if the queue manager is
98
+ * in the process of being quiesced.
99
+ * * Note: If set to false, the MQOO_FAIL_IF_QUIESCING flag will not be removed if
100
+ * it was also supplied in :open_options. However, if set to true it will override
101
+ * this value in :open_options
102
+ * * Note: This interface differs from other WebSphere MQ interfaces,
103
+ * they do not default to true.
104
+ * Default: true
105
+ * Equivalent to: MQOO_FAIL_IF_QUIESCING
106
+ *
107
+ * * :open_options =&gt; FixNum
108
+ * * One or more of the following values:
109
+ * WMQ::MQOO_INQUIRE
110
+ * WMQ::MQOO_SET
111
+ * WMQ::MQOO_BIND_ON_OPEN
112
+ * WMQ::MQOO_BIND_NOT_FIXED
113
+ * WMQ::MQOO_BIND_AS_Q_DEF
114
+ * WMQ::MQOO_SAVE_ALL_CONTEXT
115
+ * WMQ::MQOO_PASS_IDENTITY_CONTEXT
116
+ * WMQ::MQOO_PASS_ALL_CONTEXT
117
+ * WMQ::MQOO_SET_IDENTITY_CONTEXT
118
+ * WMQ::MQOO_SET_ALL_CONTEXT
119
+ * * Multiple values can be or'd together. E.g.
120
+ * :open_options=&gt;WMQ::MQOO_BIND_ON_OPEN | WMQ::MQOO_SAVE_ALL_CONTEXT
121
+ * * Please see the WebSphere MQ documentation for more details on the above options
122
+ *
123
+ * * :close_options =&gt; FixNum
124
+ * * One of the following values:
125
+ * WMQ::MQCO_DELETE
126
+ * WMQ::MQCO_DELETE_PURGE
127
+ * * Please see the WebSphere MQ documentation for more details on the above options
128
+ *
129
+ * * :dynamic_q_name =&gt; String
130
+ * * If a model queue name is supplied to :q_name then the final queue name that is
131
+ * created is specified using :dynamic_q_name
132
+ * * A complete queue name can be specified. E.g. 'MY.LOCAL.QUEUE'
133
+ * * Or, a partial queue name can be supplied. E.g. 'MY.REPLY.QUEUE.*'
134
+ * In this case WebSphere MQ will automatically add numbers to the end
135
+ * of 'MY.REPLY.QUEUE.' to ensure this queue name is unique.
136
+ * * The most common use of :dynamic_q_name is to create a temporary dynamic queue
137
+ * to which replies can be posted for this instance of the program
138
+ * * When opening a model queue, :dynamic_q_name is optional. However it's use is
139
+ * recommended in order to make it easier to identify which application a
140
+ * dynamic queue belongs to.
141
+ *
142
+ * * :fail_if_exists =&gt; true or false
143
+ * * Only applicable when opening a model queue
144
+ * * When opening a queue dynamically, sometimes the :dynamic_q_name already
145
+ * exists. Under this condition, if :fail_if_exists is false, the queue is
146
+ * automatically re-opened using the :dynamic_q_name. The :q_name field is ignored.
147
+ * * This feature is usefull when creating _permanent_ dynamic queues.
148
+ * (The model queue has the definition type set to Permanent: DEFTYPE(PERMDYN) ).
149
+ * * In this way it is not necessary to create the queues before running the program.
150
+ * Default: true
151
+ *
152
+ * * :alternate_user_id [String]
153
+ * * Sets the alternate userid to use when messages are put to the queue
154
+ * * Note: It is not necessary to supply WMQ::MQOO_ALTERNATE_USER_AUTHORITY
155
+ * since it is automatically added to the :open_options when :alternate_user_id
156
+ * is supplied
157
+ * * See WebSphere MQ Application Programming Reference: MQOD.AlternateUserId
158
+ *
159
+ * * :alternate_security_id [String]
160
+ * * Sets the alternate security id to use when messages are put to the queue
161
+ * * See WebSphere MQ Application Programming Reference: MQOD.AlternateSecurityId
162
+ *
163
+ * Note:
164
+ * * It is more convenient to use WMQ::QueueManager#open_queue, since it automatically supplies
165
+ * the parameter :queue_manager
166
+ * * That way :queue_manager parameter is _not_ required
167
+ *
168
+ * Example:
169
+ * # Put 10 Hello World messages onto a queue
170
+ * require 'wmq/wmq_client'
171
+ *
172
+ * WMQ::QueueManager.connect(:q_mgr_name=&gt;'REID', :connection_name=&gt;'localhost(1414)') do |qmgr|
173
+ * WMQ::Queue.open(:queue_manager=&gt;qmgr,
174
+ * :q_name =&gt;'TEST.QUEUE',
175
+ * :mode =&gt;:output) do |queue|
176
+ * 10.times { |counter| queue.put(:data =&gt; &quot;Hello World #{counter}&quot;) }
177
+ * end
178
+ * end
179
+ */
180
+ VALUE Queue_singleton_open(int argc, VALUE *argv, VALUE self)
181
+ {
182
+ VALUE proc, parameters, queue;
183
+
184
+ /* Extract parameters and code block (Proc) */
185
+ rb_scan_args(argc, argv, &quot;1&amp;&quot;, &amp;parameters, &amp;proc);
186
+
187
+ queue = rb_funcall(wmq_queue, ID_new, 1, parameters);
188
+ if(!NIL_P(proc))
189
+ {
190
+ if(Qtrue == Queue_open(queue))
191
+ {
192
+ struct Queue_singleton_open_arg arg;
193
+ arg.queue = queue;
194
+ arg.proc = proc;
195
+ rb_ensure(Queue_singleton_open_body, (VALUE)&amp;arg, Queue_singleton_open_ensure, queue);
196
+ }
197
+ else
198
+ {
199
+ return Qfalse;
200
+ }
201
+ }
202
+ return queue;
203
+ }</pre>
204
+ </body>
205
+ </html>
@@ -0,0 +1,107 @@
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>new (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
+ * new(...)
16
+ *
17
+ * Note:
18
+ * * It is _not_ recommended to create instances of Queue directly, rather user Queue.open. Which
19
+ * creates the queue, opens the queue, executes a supplied code block and then ensures the queue
20
+ * is closed.
21
+ *
22
+ * Parameters:
23
+ * * Since the number of parameters can vary dramatically, all parameters are passed by name in a hash
24
+ * * See Queue.open for details on all parameters
25
+ *
26
+ */
27
+ VALUE Queue_initialize(VALUE self, VALUE hash)
28
+ {
29
+ VALUE str;
30
+ size_t size;
31
+ size_t length;
32
+ VALUE val;
33
+ VALUE q_name;
34
+ PQUEUE pq;
35
+
36
+ Check_Type(hash, T_HASH);
37
+
38
+ Data_Get_Struct(self, QUEUE, pq);
39
+
40
+ val = rb_hash_aref(hash, ID2SYM(ID_queue_manager)); /* :queue_manager */
41
+ if (NIL_P(val))
42
+ {
43
+ rb_raise(rb_eArgError, &quot;Mandatory parameter :queue_manager missing from WMQ::Queue::new&quot;);
44
+ }
45
+ else
46
+ {
47
+ PQUEUE_MANAGER pqm;
48
+ Data_Get_Struct(val, QUEUE_MANAGER, pqm);
49
+ pq-&gt;exception_on_error = pqm-&gt;exception_on_error; /* Copy exception_on_error from Queue Manager setting */
50
+ pq-&gt;trace_level = pqm-&gt;trace_level; /* Copy trace_level from Queue Manager setting */
51
+
52
+ rb_iv_set(self, &quot;@queue_manager&quot;, val);
53
+ }
54
+
55
+ q_name = rb_hash_aref(hash, ID2SYM(ID_q_name)); /* :q_name */
56
+ if (NIL_P(q_name))
57
+ {
58
+ rb_raise(rb_eArgError, &quot;Mandatory parameter :q_name missing from WMQ::Queue::new&quot;);
59
+ }
60
+
61
+ /* --------------------------------------------------
62
+ * If :q_name is a hash, extract :q_name and :q_mgr_name
63
+ * --------------------------------------------------*/
64
+ if(TYPE(q_name) == T_HASH)
65
+ {
66
+ if(pq-&gt;trace_level)
67
+ printf (&quot;WMQ::Queue::new q_name is a hash\n&quot;);
68
+
69
+ WMQ_HASH2MQCHARS(q_name,q_mgr_name, pq-&gt;od.ObjectQMgrName)
70
+
71
+ q_name = rb_hash_aref(q_name, ID2SYM(ID_q_name));
72
+ if (NIL_P(q_name))
73
+ {
74
+ rb_raise(rb_eArgError,
75
+ &quot;Mandatory parameter :q_name missing from :q_name hash passed to WMQ::Queue::new&quot;);
76
+ }
77
+ }
78
+
79
+ str = StringValue(q_name);
80
+ rb_iv_set(self, &quot;@original_name&quot;, str); /* Store original queue name */
81
+ strncpy(pq-&gt;q_name, RSTRING(str)-&gt;ptr, sizeof(pq-&gt;q_name));
82
+
83
+ pq-&gt;open_options = Queue_extract_open_options(hash, q_name);
84
+
85
+ if(pq-&gt;trace_level &gt; 1) printf(&quot;WMQ::Queue::new Queue:%s\n&quot;, pq-&gt;q_name);
86
+
87
+ val = rb_hash_aref(hash, ID2SYM(ID_dynamic_q_name)); /* :dynamic_q_name */
88
+ if (!NIL_P(val))
89
+ {
90
+ rb_iv_set(self, &quot;@dynamic_q_name&quot;, val);
91
+ }
92
+
93
+ WMQ_HASH2MQBYTES(hash,alternate_security_id, pq-&gt;od.AlternateSecurityId)
94
+ WMQ_HASH2MQLONG(hash,close_options, pq-&gt;close_options)
95
+ WMQ_HASH2BOOL(hash,fail_if_exists, pq-&gt;fail_if_exists)
96
+
97
+ val = rb_hash_aref(hash, ID2SYM(ID_alternate_user_id)); /* :alternate_user_id */
98
+ if (!NIL_P(val))
99
+ {
100
+ WMQ_HASH2MQCHARS(hash,alternate_user_id, pq-&gt;od.AlternateUserId)
101
+ pq-&gt;open_options |= MQOO_ALTERNATE_USER_AUTHORITY;
102
+ }
103
+
104
+ return Qnil;
105
+ }</pre>
106
+ </body>
107
+ </html>
@@ -0,0 +1,198 @@
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>open (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
+ * open()
16
+ *
17
+ * Open the queue
18
+ *
19
+ * Note:
20
+ * * It is not recommended to use this method to open a queue, since the queue will
21
+ * have to be closed explicitly.
22
+ * * Rather use WMQ::QueueManager#open_queue
23
+ * * If the queue is already open, it will be closed and re-opened.
24
+ * Any errors that occur while closing the queue are ignored.
25
+ * * Custom behavior for Dynamic Queues:
26
+ * When :dynamic_q_name is supplied and MQ fails to
27
+ * open the queue with MQRC_OBJECT_ALREADY_EXISTS,
28
+ * this method will automatically open the existing
29
+ * queue by replacing the queue name with :dynamic_q_name
30
+ *
31
+ * This technique allows programs to dynamically create
32
+ * queues, without being concerned with first checking if
33
+ * the queue is already defined.
34
+ * I.e. Removes the need to have to explicitly create
35
+ * required queues in advance
36
+ * However, in order for this approach to work a
37
+ * Permanent model queue must be used. A Temporary
38
+ * model queue is automatically erased by WMQ when the
39
+ * queue is closed.
40
+ *
41
+ * Persistent messages cannot be put to a
42
+ * temporary dynamic queue!
43
+ *
44
+ * Returns:
45
+ * * true : On Success
46
+ * * false: On Failure
47
+ *
48
+ * comp_code and reason_code are also updated.
49
+ * reason will return a text description of the reason_code
50
+ *
51
+ * Throws:
52
+ * * WMQ::WMQException if comp_code == MQCC_FAILED
53
+ * * Except if :exception_on_error =&gt; false was supplied as a parameter
54
+ * to QueueManager.new
55
+ *
56
+ * Example:
57
+ * require 'wmq/wmq_client'
58
+ * queue_manager = WMQ::QueueManager.new(:q_mgr_name =&gt;'REID',
59
+ * :connection_name=&gt;'localhost(1414)')
60
+ * begin
61
+ * queue_manager.connect
62
+ *
63
+ * # Create Queue and clear any messages from the queue
64
+ * in_queue = WMQ::Queue.new(:queue_manager =&gt;queue_manager,
65
+ * :mode =&gt;:input,
66
+ * :dynamic_q_name=&gt;'UNIT.TEST',
67
+ * :q_name =&gt;'SYSTEM.DEFAULT.MODEL.QUEUE',
68
+ * :fail_if_exists=&gt;false)
69
+ * begin
70
+ * in_queue.open
71
+ * in_queue.each { |message| p message.data }
72
+ * ensure
73
+ * # Note: Very important: Must close the queue explicitly
74
+ * in_queue.close
75
+ * end
76
+ * rescue =&gt; exc
77
+ * queue_manager.backout
78
+ * raise exc
79
+ * ensure
80
+ * # Note: Very important: Must disconnect from the queue manager explicitly
81
+ * queue_manager.disconnect
82
+ * end
83
+ */
84
+ VALUE Queue_open(VALUE self)
85
+ {
86
+ VALUE name;
87
+ VALUE val;
88
+ VALUE dynamic_q_name;
89
+ MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
90
+ VALUE queue_manager;
91
+ PQUEUE_MANAGER pqm;
92
+ PQUEUE pq;
93
+ Data_Get_Struct(self, QUEUE, pq);
94
+
95
+ name = rb_iv_get(self,&quot;@original_name&quot;); /* Always open original name */
96
+ if (NIL_P(name))
97
+ {
98
+ rb_raise(rb_eRuntimeError, &quot;Fatal: Queue Name not found in Queue instance&quot;);
99
+ }
100
+ name = StringValue(name);
101
+
102
+ strncpy(od.ObjectName, RSTRING(name)-&gt;ptr, (size_t)MQ_Q_NAME_LENGTH);
103
+
104
+ dynamic_q_name = rb_iv_get(self,&quot;@dynamic_q_name&quot;);
105
+ if (!NIL_P(dynamic_q_name))
106
+ {
107
+ val = StringValue(dynamic_q_name);
108
+ strncpy(od.DynamicQName, RSTRING(dynamic_q_name)-&gt;ptr, (size_t) MQ_Q_NAME_LENGTH);
109
+ if(pq-&gt;trace_level&gt;1) printf(&quot;WMQ::Queue#open() Using dynamic queue name:%s\n&quot;, RSTRING(dynamic_q_name)-&gt;ptr);
110
+ }
111
+
112
+ queue_manager = rb_iv_get(self,&quot;@queue_manager&quot;);
113
+ if (NIL_P(queue_manager))
114
+ {
115
+ rb_raise(rb_eRuntimeError, &quot;Fatal: Queue Manager object not found in Queue instance&quot;);
116
+ }
117
+ Data_Get_Struct(queue_manager, QUEUE_MANAGER, pqm);
118
+ pq-&gt;MQCLOSE= pqm-&gt;MQCLOSE;
119
+ pq-&gt;MQGET = pqm-&gt;MQGET;
120
+ pq-&gt;MQPUT = pqm-&gt;MQPUT;
121
+
122
+ pq-&gt;hcon = pqm-&gt;hcon; /* Store Queue Manager handle for subsequent calls */
123
+
124
+ if(pq-&gt;trace_level)
125
+ printf (&quot;WMQ::Queue#open() Opening Queue:%s, Queue Manager Handle:%d\n&quot;, RSTRING(name)-&gt;ptr, pq-&gt;hcon);
126
+
127
+ if(pq-&gt;hobj) /* Close queue if already open, ignore errors */
128
+ {
129
+ if(pq-&gt;trace_level)
130
+ printf (&quot;WMQ::Queue#open() Queue:%s Already open, closing it!\n&quot;, RSTRING(name)-&gt;ptr);
131
+
132
+ pqm-&gt;MQCLOSE(pq-&gt;hcon, &amp;pq-&gt;hobj, pq-&gt;close_options, &amp;pq-&gt;comp_code, &amp;pq-&gt;reason_code);
133
+ }
134
+
135
+ pqm-&gt;MQOPEN(pq-&gt;hcon, &amp;od, pq-&gt;open_options, &amp;pq-&gt;hobj, &amp;pq-&gt;comp_code, &amp;pq-&gt;reason_code);
136
+
137
+ /* --------------------------------------------------
138
+ * If the Dynamic Queue already exists, just open the
139
+ * dynamic queue name directly
140
+ * --------------------------------------------------*/
141
+ if (pq-&gt;reason_code == MQRC_OBJECT_ALREADY_EXISTS &amp;&amp;
142
+ !pq-&gt;fail_if_exists &amp;&amp;
143
+ !NIL_P(dynamic_q_name))
144
+ {
145
+ strncpy(od.ObjectName, od.DynamicQName, (size_t) MQ_Q_MGR_NAME_LENGTH);
146
+ od.DynamicQName[0] = 0;
147
+
148
+ if(pq-&gt;trace_level)
149
+ printf(&quot;WMQ::Queue#open() Queue already exists, re-trying with queue name:%s\n&quot;,
150
+ RSTRING(dynamic_q_name)-&gt;ptr);
151
+
152
+ pqm-&gt;MQOPEN(pq-&gt;hcon, &amp;od, pq-&gt;open_options, &amp;pq-&gt;hobj, &amp;pq-&gt;comp_code, &amp;pq-&gt;reason_code);
153
+ }
154
+
155
+ if(pq-&gt;trace_level)
156
+ printf(&quot;WMQ::Queue#open() MQOPEN completed with reason:%s, Handle:%d\n&quot;,
157
+ wmq_reason(pq-&gt;reason_code),
158
+ pq-&gt;hobj);
159
+
160
+ if (pq-&gt;comp_code == MQCC_FAILED)
161
+ {
162
+ pq-&gt;hobj = 0;
163
+ pq-&gt;hcon = 0;
164
+
165
+ if (pq-&gt;exception_on_error)
166
+ {
167
+ VALUE name = rb_iv_get(self,&quot;@original_name&quot;);
168
+ name = StringValue(name);
169
+
170
+ rb_raise(wmq_exception,
171
+ &quot;WMQ::Queue#open(). Error opening Queue:%s, reason:%s&quot;,
172
+ RSTRING(name)-&gt;ptr,
173
+ wmq_reason(pq-&gt;reason_code));
174
+ }
175
+ return Qfalse;
176
+ }
177
+ else
178
+ {
179
+ size_t size;
180
+ size_t length;
181
+ size_t i;
182
+ char* pChar;
183
+
184
+ WMQ_MQCHARS2STR(od.ObjectName, val)
185
+ rb_iv_set(self, &quot;@name&quot;, val); /* Store actual queue name E.g. Dynamic Queue */
186
+
187
+ if(pq-&gt;trace_level&gt;1) printf(&quot;WMQ::Queue#open() Actual Queue Name opened:%s\n&quot;, RSTRING(val)-&gt;ptr);
188
+ }
189
+
190
+ /* Future Use:
191
+ WMQ_MQCHARS2HASH(hash,resolved_q_name, pmqod-&gt;ResolvedQName)
192
+ WMQ_MQCHARS2HASH(hash,resolved_q_mgr_name, pmqod-&gt;ResolvedQMgrName)
193
+ */
194
+
195
+ return Qtrue;
196
+ }</pre>
197
+ </body>
198
+ </html>