rubywmq 0.3.0-i386-mswin32-mq6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README +73 -0
- data/doc/classes/WMQ.html +6300 -0
- data/doc/classes/WMQ/Message.html +376 -0
- data/doc/classes/WMQ/Message.src/M000001.html +77 -0
- data/doc/classes/WMQ/Message.src/M000002.html +27 -0
- data/doc/classes/WMQ/Queue.html +1459 -0
- data/doc/classes/WMQ/Queue.src/M000003.html +205 -0
- data/doc/classes/WMQ/Queue.src/M000004.html +107 -0
- data/doc/classes/WMQ/Queue.src/M000005.html +198 -0
- data/doc/classes/WMQ/Queue.src/M000006.html +66 -0
- data/doc/classes/WMQ/Queue.src/M000007.html +203 -0
- data/doc/classes/WMQ/Queue.src/M000008.html +265 -0
- data/doc/classes/WMQ/Queue.src/M000009.html +120 -0
- data/doc/classes/WMQ/Queue.src/M000010.html +28 -0
- data/doc/classes/WMQ/Queue.src/M000011.html +30 -0
- data/doc/classes/WMQ/Queue.src/M000012.html +31 -0
- data/doc/classes/WMQ/Queue.src/M000013.html +31 -0
- data/doc/classes/WMQ/Queue.src/M000014.html +31 -0
- data/doc/classes/WMQ/QueueManager.html +1529 -0
- data/doc/classes/WMQ/QueueManager.src/M000015.html +182 -0
- data/doc/classes/WMQ/QueueManager.src/M000016.html +194 -0
- data/doc/classes/WMQ/QueueManager.src/M000017.html +92 -0
- data/doc/classes/WMQ/QueueManager.src/M000018.html +70 -0
- data/doc/classes/WMQ/QueueManager.src/M000019.html +49 -0
- data/doc/classes/WMQ/QueueManager.src/M000020.html +49 -0
- data/doc/classes/WMQ/QueueManager.src/M000021.html +63 -0
- data/doc/classes/WMQ/QueueManager.src/M000022.html +61 -0
- data/doc/classes/WMQ/QueueManager.src/M000023.html +65 -0
- data/doc/classes/WMQ/QueueManager.src/M000024.html +232 -0
- data/doc/classes/WMQ/QueueManager.src/M000025.html +30 -0
- data/doc/classes/WMQ/QueueManager.src/M000026.html +31 -0
- data/doc/classes/WMQ/QueueManager.src/M000027.html +31 -0
- data/doc/classes/WMQ/QueueManager.src/M000028.html +38 -0
- data/doc/classes/WMQ/QueueManager.src/M000029.html +33 -0
- data/doc/classes/WMQ/QueueManager.src/M000030.html +21 -0
- data/doc/classes/WMQ/QueueManager.src/M000031.html +284 -0
- data/doc/classes/WMQ/QueueManager.src/M000032.html +24 -0
- data/doc/classes/WMQ/QueueManager.src/M000033.html +18 -0
- data/doc/classes/WMQ/QueueManager.src/M000034.html +46 -0
- data/doc/classes/WMQ/QueueManager.src/M000035.html +27 -0
- data/doc/classes/WMQ/WMQException.html +111 -0
- data/doc/created.rid +1 -0
- data/doc/files/ext/lib/wmq_const_admin_rb.html +128 -0
- data/doc/files/ext/lib/wmq_const_rb.html +128 -0
- data/doc/files/ext/lib/wmq_temp_rb.html +122 -0
- data/doc/files/ext/wmq_c.html +101 -0
- data/doc/files/ext/wmq_message_c.html +101 -0
- data/doc/files/ext/wmq_queue_c.html +101 -0
- data/doc/files/ext/wmq_queue_manager_c.html +101 -0
- data/doc/fr_class_index.html +31 -0
- data/doc/fr_file_index.html +33 -0
- data/doc/fr_method_index.html +61 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/examples/each_a.rb +31 -0
- data/examples/each_b.rb +40 -0
- data/examples/each_header.rb +37 -0
- data/examples/files_to_q.cfg +24 -0
- data/examples/files_to_q.rb +46 -0
- data/examples/get_a.rb +34 -0
- data/examples/get_client.rb +50 -0
- data/examples/put1_a.rb +24 -0
- data/examples/put1_b.rb +32 -0
- data/examples/put1_c.rb +31 -0
- data/examples/put_a.rb +34 -0
- data/examples/put_b.rb +42 -0
- data/examples/put_dlh.rb +40 -0
- data/examples/put_dynamic_q.rb +37 -0
- data/examples/put_rfh.rb +66 -0
- data/examples/put_rfh2_a.rb +42 -0
- data/examples/put_rfh2_b.rb +42 -0
- data/examples/put_xmit_q.rb +32 -0
- data/examples/q_to_files.cfg +17 -0
- data/examples/q_to_files.rb +47 -0
- data/examples/request.rb +59 -0
- data/examples/server.rb +96 -0
- data/lib/wmq.rb +25 -0
- data/lib/wmq/wmq.so +0 -0
- data/lib/wmq/wmq_const.rb +745 -0
- data/lib/wmq/wmq_const_admin.rb +555 -0
- data/lib/wmq/wmq_temp.rb +197 -0
- data/tests/test.rb +299 -0
- 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 => 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->hcon)
|
35
|
+
{
|
36
|
+
if(pq->trace_level) printf ("WMQ::Queue#close() Queue not open\n");
|
37
|
+
return Qtrue;
|
38
|
+
}
|
39
|
+
|
40
|
+
if(pq->trace_level) printf ("WMQ::Queue#close() Queue Handle:%ld, Queue Manager Handle:%ld\n", pq->hobj, pq->hcon);
|
41
|
+
|
42
|
+
pq->MQCLOSE(pq->hcon, &pq->hobj, pq->close_options, &pq->comp_code, &pq->reason_code);
|
43
|
+
|
44
|
+
pq->hcon = 0; /* Every time the queue is opened, the qmgr handle must be fetched again! */
|
45
|
+
pq->hobj = 0;
|
46
|
+
|
47
|
+
if(pq->trace_level) printf("WMQ::Queue#close() MQCLOSE ended with reason:%s\n", wmq_reason(pq->reason_code));
|
48
|
+
|
49
|
+
if (pq->comp_code == MQCC_FAILED)
|
50
|
+
{
|
51
|
+
if (pq->exception_on_error)
|
52
|
+
{
|
53
|
+
VALUE name = Queue_name(self);
|
54
|
+
|
55
|
+
rb_raise(wmq_exception,
|
56
|
+
"WMQ::Queue#close(). Error closing Queue:%s, reason:%s",
|
57
|
+
RSTRING(name)->ptr,
|
58
|
+
wmq_reason(pq->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 => my_message, # n/a : Instance of Message
|
24
|
+
* :data => "Hello World", # n/a : Data to send
|
25
|
+
* :sync => false, # MQGMO_SYNCPOINT
|
26
|
+
* :new_id => true, # MQPMO_NEW_MSG_ID & MQPMO_NEW_CORREL_ID
|
27
|
+
* :new_msg_id => true, # MQPMO_NEW_MSG_ID
|
28
|
+
* :new_correl_id => true, # MQPMO_NEW_CORREL_ID
|
29
|
+
* :fail_if_quiescing => true, # MQOO_FAIL_IF_QUIESCING
|
30
|
+
* :options => 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 => 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 => 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 => 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 => 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 => 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 => true or false
|
68
|
+
* * Generate a new correlation id for this message
|
69
|
+
* Default: false
|
70
|
+
*
|
71
|
+
* * :fail_if_quiescing => 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 => Fixnum (Advanced MQ Use only)
|
88
|
+
* * Numeric field containing any of the MQ Put message options or'd together
|
89
|
+
* * E.g. :options => 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 => 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=>'REID', :connection_name=>'localhost(1414)') do |qmgr|
|
123
|
+
* qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
|
124
|
+
*
|
125
|
+
* # First message
|
126
|
+
* queue.put(:data => '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=>message, :data => '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=>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->hcon && (Queue_open(self) == Qfalse))
|
155
|
+
{
|
156
|
+
return Qfalse;
|
157
|
+
}
|
158
|
+
|
159
|
+
Queue_extract_put_message_options(hash, &pmo);
|
160
|
+
Message_build(&pq->p_buffer, &pq->buffer_size, pq->trace_level,
|
161
|
+
hash, &pBuffer, &BufferLength, &md);
|
162
|
+
|
163
|
+
if(pq->trace_level) printf("WMQ::Queue#put() Queue Handle:%ld, Queue Manager Handle:%ld\n", pq->hobj, pq->hcon);
|
164
|
+
|
165
|
+
pq->MQPUT(
|
166
|
+
pq->hcon, /* connection handle */
|
167
|
+
pq->hobj, /* object handle */
|
168
|
+
&md, /* message descriptor */
|
169
|
+
&pmo, /* put message options */
|
170
|
+
BufferLength, /* message length */
|
171
|
+
pBuffer, /* message buffer */
|
172
|
+
&pq->comp_code, /* completion code */
|
173
|
+
&pq->reason_code); /* reason code */
|
174
|
+
|
175
|
+
if(pq->trace_level) printf("WMQ::Queue#put() MQPUT ended with reason:%s\n", wmq_reason(pq->reason_code));
|
176
|
+
|
177
|
+
if (pq->reason_code != MQRC_NONE)
|
178
|
+
{
|
179
|
+
if (pq->exception_on_error)
|
180
|
+
{
|
181
|
+
VALUE name = Queue_name(self);
|
182
|
+
|
183
|
+
rb_raise(wmq_exception,
|
184
|
+
"WMQ::Queue#put(). Error writing a message to Queue:%s, reason:%s",
|
185
|
+
RSTRING(name)->ptr,
|
186
|
+
wmq_reason(pq->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, &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 => my_message, # n/a : Instance of Message
|
24
|
+
* :sync => false, # MQGMO_SYNCPOINT
|
25
|
+
* :wait => 0, # MQGMO_WAIT, duration in ms
|
26
|
+
* :match => WMQ::MQMO_NONE, # MQMO_*
|
27
|
+
* :convert => false, # MQGMO_CONVERT
|
28
|
+
* :fail_if_quiescing => true # MQOO_FAIL_IF_QUIESCING
|
29
|
+
* :options => WMQ::MQGMO_FAIL_IF_QUIESCING # MQGMO_*
|
30
|
+
* )
|
31
|
+
*
|
32
|
+
* Mandatory Parameters
|
33
|
+
* * :message => Message
|
34
|
+
* * An instance of the WMQ::Message
|
35
|
+
*
|
36
|
+
* Optional Parameters
|
37
|
+
* * :sync => 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 => 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 => 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=>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 => 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 => 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 => Fixnum (Advanced MQ Use only)
|
77
|
+
* * Numeric field containing any of the MQ Get message options or'd together
|
78
|
+
* * E.g. :options => 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 => 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=>'REID') do |qmgr|
|
116
|
+
* qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
|
117
|
+
* message = WMQ::Message.new
|
118
|
+
* if queue.get(:message => message)
|
119
|
+
* puts "Data Received: #{message.data}"
|
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->hcon && (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
|
+
"Mandatory key :message is missing from hash passed to get() for Queue: %s",
|
160
|
+
RSTRING(name)->ptr);
|
161
|
+
}
|
162
|
+
|
163
|
+
Message_build_mqmd(message, &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->trace_level > 1) printf("WMQ::Queue#get() Get Message Option: MatchOptions=%ld\n", gmo.MatchOptions);
|
192
|
+
if(pq->trace_level) printf("WMQ::Queue#get() Queue Handle:%ld, Queue Manager Handle:%ld\n", pq->hobj, pq->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->MQGET(
|
210
|
+
pq->hcon, /* connection handle */
|
211
|
+
pq->hobj, /* object handle */
|
212
|
+
&md, /* message descriptor */
|
213
|
+
&gmo, /* get message options */
|
214
|
+
pq->buffer_size, /* message buffer size */
|
215
|
+
pq->p_buffer, /* message buffer */
|
216
|
+
&messlen, /* message length */
|
217
|
+
&pq->comp_code, /* completion code */
|
218
|
+
&pq->reason_code); /* reason code */
|
219
|
+
|
220
|
+
/* report reason, if any */
|
221
|
+
if (pq->reason_code != MQRC_NONE)
|
222
|
+
{
|
223
|
+
if(pq->trace_level>1) printf("WMQ::Queue#get() Growing buffer size from %ld to %ld\n", pq->buffer_size, messlen);
|
224
|
+
/* TODO: Add support for autogrow buffer here */
|
225
|
+
if (pq->reason_code == MQRC_TRUNCATED_MSG_FAILED)
|
226
|
+
{
|
227
|
+
if(pq->trace_level>2)
|
228
|
+
printf ("WMQ::Queue#reallocate Resizing buffer from %ld to %ld bytes\n", pq->buffer_size, messlen);
|
229
|
+
|
230
|
+
free(pq->p_buffer);
|
231
|
+
pq->buffer_size = messlen;
|
232
|
+
pq->p_buffer = ALLOC_N(char, messlen);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
while (pq->reason_code == MQRC_TRUNCATED_MSG_FAILED);
|
237
|
+
|
238
|
+
if(pq->trace_level) printf("WMQ::Queue#get() MQGET ended with reason:%s\n", wmq_reason(pq->reason_code));
|
239
|
+
|
240
|
+
if (pq->comp_code != MQCC_FAILED)
|
241
|
+
{
|
242
|
+
Message_deblock(message, &md, pq->p_buffer, messlen, pq->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->exception_on_error && (pq->reason_code != MQRC_NO_MSG_AVAILABLE))
|
253
|
+
{
|
254
|
+
VALUE name = Queue_name(self);
|
255
|
+
|
256
|
+
rb_raise(wmq_exception,
|
257
|
+
"WMQ::Queue#get(). Error reading a message from Queue:%s, reason:%s",
|
258
|
+
RSTRING(name)->ptr,
|
259
|
+
wmq_reason(pq->reason_code));
|
260
|
+
}
|
261
|
+
return Qfalse;
|
262
|
+
}
|
263
|
+
}</pre>
|
264
|
+
</body>
|
265
|
+
</html>
|