rubywmq 0.3.0-sparc-solaris2.8-mq5.3
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/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 +47 -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/request.rb +59 -0
- data/examples/server.rb +96 -0
- data/lib/wmq/wmq.so +0 -0
- data/lib/wmq/wmq_const.rb +697 -0
- data/lib/wmq/wmq_const_admin.rb +275 -0
- data/lib/wmq/wmq_temp.rb +197 -0
- data/lib/wmq.rb +25 -0
- data/tests/test.rb +299 -0
- metadata +73 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
################################################################################
|
16
|
+
#
|
17
|
+
# WARNING: DO NOT MODIFY THIS FILE
|
18
|
+
#
|
19
|
+
# This file was generated by generate_const.rb.
|
20
|
+
#
|
21
|
+
################################################################################
|
22
|
+
module WMQ
|
23
|
+
# Admin constants from cmqc.h
|
24
|
+
|
25
|
+
# Object Types
|
26
|
+
MQOT_Q = 1
|
27
|
+
MQOT_NAMELIST = 2
|
28
|
+
MQOT_PROCESS = 3
|
29
|
+
MQOT_STORAGE_CLASS = 4
|
30
|
+
MQOT_Q_MGR = 5
|
31
|
+
MQOT_CHANNEL = 6
|
32
|
+
MQOT_AUTH_INFO = 7
|
33
|
+
MQOT_CF_STRUC = 10
|
34
|
+
MQOT_RESERVED_1 = 999
|
35
|
+
MQOT_ALL = 1001
|
36
|
+
MQOT_ALIAS_Q = 1002
|
37
|
+
MQOT_MODEL_Q = 1003
|
38
|
+
MQOT_LOCAL_Q = 1004
|
39
|
+
MQOT_REMOTE_Q = 1005
|
40
|
+
MQOT_SENDER_CHANNEL = 1007
|
41
|
+
MQOT_SERVER_CHANNEL = 1008
|
42
|
+
MQOT_REQUESTER_CHANNEL = 1009
|
43
|
+
MQOT_RECEIVER_CHANNEL = 1010
|
44
|
+
MQOT_CURRENT_CHANNEL = 1011
|
45
|
+
MQOT_SAVED_CHANNEL = 1012
|
46
|
+
MQOT_SVRCONN_CHANNEL = 1013
|
47
|
+
MQOT_CLNTCONN_CHANNEL = 1014
|
48
|
+
|
49
|
+
# Security Identifier Types
|
50
|
+
MQSIDT_NONE = 'x00'
|
51
|
+
MQSIDT_NT_SECURITY_ID = 'x01'
|
52
|
+
MQSIDT_WAS_SECURITY_ID = 'x02'
|
53
|
+
|
54
|
+
# Channel Types
|
55
|
+
MQCHT_SENDER = 1
|
56
|
+
MQCHT_SERVER = 2
|
57
|
+
MQCHT_RECEIVER = 3
|
58
|
+
MQCHT_REQUESTER = 4
|
59
|
+
MQCHT_ALL = 5
|
60
|
+
MQCHT_CLNTCONN = 6
|
61
|
+
MQCHT_SVRCONN = 7
|
62
|
+
MQCHT_CLUSRCVR = 8
|
63
|
+
MQCHT_CLUSSDR = 9
|
64
|
+
MQQT_LOCAL = 1
|
65
|
+
MQQT_MODEL = 2
|
66
|
+
MQQT_ALIAS = 3
|
67
|
+
MQQT_REMOTE = 6
|
68
|
+
MQQT_CLUSTER = 7
|
69
|
+
MQCQT_LOCAL_Q = 1
|
70
|
+
MQCQT_ALIAS_Q = 2
|
71
|
+
MQCQT_REMOTE_Q = 3
|
72
|
+
MQCQT_Q_MGR_ALIAS = 4
|
73
|
+
MQQT_ALL = 1001
|
74
|
+
MQQDT_PREDEFINED = 1
|
75
|
+
MQQDT_PERMANENT_DYNAMIC = 2
|
76
|
+
MQQDT_TEMPORARY_DYNAMIC = 3
|
77
|
+
MQQDT_SHARED_DYNAMIC = 4
|
78
|
+
MQQA_GET_INHIBITED = 1
|
79
|
+
MQQA_GET_ALLOWED = 0
|
80
|
+
MQQA_PUT_INHIBITED = 1
|
81
|
+
MQQA_PUT_ALLOWED = 0
|
82
|
+
MQQA_SHAREABLE = 1
|
83
|
+
MQQA_NOT_SHAREABLE = 0
|
84
|
+
MQQA_BACKOUT_HARDENED = 1
|
85
|
+
MQQA_BACKOUT_NOT_HARDENED = 0
|
86
|
+
MQMDS_PRIORITY = 0
|
87
|
+
MQMDS_FIFO = 1
|
88
|
+
MQTC_OFF = 0
|
89
|
+
MQTC_ON = 1
|
90
|
+
MQTT_NONE = 0
|
91
|
+
MQTT_FIRST = 1
|
92
|
+
MQTT_EVERY = 2
|
93
|
+
MQTT_DEPTH = 3
|
94
|
+
MQUS_NORMAL = 0
|
95
|
+
MQUS_TRANSMISSION = 1
|
96
|
+
MQDL_SUPPORTED = 1
|
97
|
+
MQDL_NOT_SUPPORTED = 0
|
98
|
+
MQIT_NONE = 0
|
99
|
+
MQIT_MSG_ID = 1
|
100
|
+
MQIT_CORREL_ID = 2
|
101
|
+
MQIT_MSG_TOKEN = 4
|
102
|
+
MQIT_GROUP_ID = 5
|
103
|
+
MQBND_BIND_ON_OPEN = 0
|
104
|
+
MQBND_BIND_NOT_FIXED = 1
|
105
|
+
MQQSGD_Q_MGR = 0
|
106
|
+
MQQSGD_COPY = 1
|
107
|
+
MQQSGD_SHARED = 2
|
108
|
+
MQQSGD_GROUP = 3
|
109
|
+
MQNC_MAX_NAMELIST_NAME_COUNT = 256
|
110
|
+
MQNT_NONE = 0
|
111
|
+
MQNT_Q = 1
|
112
|
+
MQNT_CLUSTER = 2
|
113
|
+
MQNT_AUTH_INFO = 4
|
114
|
+
MQNT_ALL = 1001
|
115
|
+
MQCHAD_DISABLED = 0
|
116
|
+
MQCHAD_ENABLED = 1
|
117
|
+
MQCMDL_LEVEL_1 = 100
|
118
|
+
MQCMDL_LEVEL_101 = 101
|
119
|
+
MQCMDL_LEVEL_110 = 110
|
120
|
+
MQCMDL_LEVEL_114 = 114
|
121
|
+
MQCMDL_LEVEL_120 = 120
|
122
|
+
MQCMDL_LEVEL_200 = 200
|
123
|
+
MQCMDL_LEVEL_201 = 201
|
124
|
+
MQCMDL_LEVEL_210 = 210
|
125
|
+
MQCMDL_LEVEL_220 = 220
|
126
|
+
MQCMDL_LEVEL_221 = 221
|
127
|
+
MQCMDL_LEVEL_320 = 320
|
128
|
+
MQCMDL_LEVEL_420 = 420
|
129
|
+
MQCMDL_LEVEL_500 = 500
|
130
|
+
MQCMDL_LEVEL_510 = 510
|
131
|
+
MQCMDL_LEVEL_520 = 520
|
132
|
+
MQCMDL_LEVEL_530 = 530
|
133
|
+
MQEXPI_OFF = 0
|
134
|
+
MQIGQ_DISABLED = 0
|
135
|
+
MQIGQ_ENABLED = 1
|
136
|
+
MQIGQPA_DEFAULT = 1
|
137
|
+
MQIGQPA_CONTEXT = 2
|
138
|
+
MQIGQPA_ONLY_IGQ = 3
|
139
|
+
MQIGQPA_ALTERNATE_OR_IGQ = 4
|
140
|
+
MQPL_MVS = 1
|
141
|
+
MQPL_OS390 = 1
|
142
|
+
MQPL_ZOS = 1
|
143
|
+
MQPL_OS2 = 2
|
144
|
+
MQPL_AIX = 3
|
145
|
+
MQPL_UNIX = 3
|
146
|
+
MQPL_OS400 = 4
|
147
|
+
MQPL_WINDOWS = 5
|
148
|
+
MQPL_WINDOWS_NT = 11
|
149
|
+
MQPL_VMS = 12
|
150
|
+
MQPL_NSK = 13
|
151
|
+
MQSP_AVAILABLE = 1
|
152
|
+
MQSP_NOT_AVAILABLE = 0
|
153
|
+
# Admin constants from cmqcfc.h
|
154
|
+
MQACT_FORCE_REMOVE = 1
|
155
|
+
MQBT_OTMA = 1
|
156
|
+
MQCFO_REFRESH_REPOSITORY_YES = 1
|
157
|
+
MQCFO_REFRESH_REPOSITORY_NO = 0
|
158
|
+
MQCFO_REMOVE_QUEUES_YES = 1
|
159
|
+
MQCFO_REMOVE_QUEUES_NO = 0
|
160
|
+
MQCHIDS_NOT_INDOUBT = 0
|
161
|
+
MQCHIDS_INDOUBT = 1
|
162
|
+
MQCHS_INACTIVE = 0
|
163
|
+
MQCHS_BINDING = 1
|
164
|
+
MQCHS_STARTING = 2
|
165
|
+
MQCHS_RUNNING = 3
|
166
|
+
MQCHS_STOPPING = 4
|
167
|
+
MQCHS_RETRYING = 5
|
168
|
+
MQCHS_STOPPED = 6
|
169
|
+
MQCHS_REQUESTING = 7
|
170
|
+
MQCHS_PAUSED = 8
|
171
|
+
MQCHS_INITIALIZING = 13
|
172
|
+
MQCHSR_STOP_NOT_REQUESTED = 0
|
173
|
+
MQCHSR_STOP_REQUESTED = 1
|
174
|
+
MQCHTAB_Q_MGR = 1
|
175
|
+
MQCHTAB_CLNTCONN = 2
|
176
|
+
MQCFR_YES = 1
|
177
|
+
MQCFR_NO = 0
|
178
|
+
MQET_MQSC = 1
|
179
|
+
MQEVO_OTHER = 0
|
180
|
+
MQEVO_CONSOLE = 1
|
181
|
+
MQEVO_INIT = 2
|
182
|
+
MQEVO_MSG = 3
|
183
|
+
MQEVO_MQSET = 4
|
184
|
+
MQEVO_INTERNAL = 5
|
185
|
+
MQEVR_DISABLED = 0
|
186
|
+
MQEVR_ENABLED = 1
|
187
|
+
MQFC_YES = 1
|
188
|
+
MQFC_NO = 0
|
189
|
+
MQIDO_COMMIT = 1
|
190
|
+
MQIDO_BACKOUT = 2
|
191
|
+
MQMCAS_STOPPED = 0
|
192
|
+
MQMCAS_RUNNING = 3
|
193
|
+
MQMODE_FORCE = 0
|
194
|
+
MQMODE_QUIESCE = 1
|
195
|
+
MQMODE_TERMINATE = 2
|
196
|
+
MQPO_YES = 1
|
197
|
+
MQPO_NO = 0
|
198
|
+
MQQMDT_EXPLICIT_CLUSTER_SENDER = 1
|
199
|
+
MQQMDT_AUTO_CLUSTER_SENDER = 2
|
200
|
+
MQQMDT_AUTO_EXP_CLUSTER_SENDER = 4
|
201
|
+
MQQMDT_CLUSTER_RECEIVER = 3
|
202
|
+
MQQMT_NORMAL = 0
|
203
|
+
MQQMT_REPOSITORY = 1
|
204
|
+
MQQO_YES = 1
|
205
|
+
MQQO_NO = 0
|
206
|
+
MQQSIE_NONE = 0
|
207
|
+
MQQSIE_HIGH = 1
|
208
|
+
MQQSIE_OK = 2
|
209
|
+
MQQSOT_ALL = 1
|
210
|
+
MQQSOT_INPUT = 2
|
211
|
+
MQQSOT_OUTPUT = 3
|
212
|
+
MQQSO_NO = 0
|
213
|
+
MQQSO_YES = 1
|
214
|
+
MQQSO_SHARED = 1
|
215
|
+
MQQSO_EXCLUSIVE = 2
|
216
|
+
MQQSUM_YES = 1
|
217
|
+
MQQSUM_NO = 0
|
218
|
+
MQRP_YES = 1
|
219
|
+
MQRP_NO = 0
|
220
|
+
MQRQ_CONN_NOT_AUTHORIZED = 1
|
221
|
+
MQRQ_OPEN_NOT_AUTHORIZED = 2
|
222
|
+
MQRQ_CLOSE_NOT_AUTHORIZED = 3
|
223
|
+
MQRQ_CMD_NOT_AUTHORIZED = 4
|
224
|
+
MQRQ_Q_MGR_STOPPING = 5
|
225
|
+
MQRQ_Q_MGR_QUIESCING = 6
|
226
|
+
MQRQ_CHANNEL_STOPPED_OK = 7
|
227
|
+
MQRQ_CHANNEL_STOPPED_ERROR = 8
|
228
|
+
MQRQ_CHANNEL_STOPPED_RETRY = 9
|
229
|
+
MQRQ_CHANNEL_STOPPED_DISABLED = 10
|
230
|
+
MQRQ_BRIDGE_STOPPED_OK = 11
|
231
|
+
MQRQ_BRIDGE_STOPPED_ERROR = 12
|
232
|
+
MQRQ_SSL_HANDSHAKE_ERROR = 13
|
233
|
+
MQRQ_SSL_CIPHER_SPEC_ERROR = 14
|
234
|
+
MQRQ_SSL_CLIENT_AUTH_ERROR = 15
|
235
|
+
MQRQ_SSL_PEER_NAME_ERROR = 16
|
236
|
+
MQSCO_Q_MGR = 1
|
237
|
+
MQSCO_CELL = 2
|
238
|
+
MQSUS_YES = 1
|
239
|
+
MQSUS_NO = 0
|
240
|
+
MQNPM_CLASS_NORMAL = 0
|
241
|
+
MQNPM_CLASS_HIGH = 10
|
242
|
+
MQDELO_NONE = 0x00000000
|
243
|
+
MQDELO_LOCAL = 0x00000004
|
244
|
+
MQPUBO_NONE = 0x00000000
|
245
|
+
MQPUBO_CORREL_ID_AS_IDENTITY = 0x00000001
|
246
|
+
MQPUBO_RETAIN_PUBLICATION = 0x00000002
|
247
|
+
MQPUBO_OTHER_SUBSCRIBERS_ONLY = 0x00000004
|
248
|
+
MQPUBO_NO_REGISTRATION = 0x00000008
|
249
|
+
MQPUBO_IS_RETAINED_PUBLICATION = 0x00000010
|
250
|
+
MQREGO_NONE = 0x00000000
|
251
|
+
MQREGO_CORREL_ID_AS_IDENTITY = 0x00000001
|
252
|
+
MQREGO_ANONYMOUS = 0x00000002
|
253
|
+
MQREGO_LOCAL = 0x00000004
|
254
|
+
MQREGO_DIRECT_REQUESTS = 0x00000008
|
255
|
+
MQREGO_NEW_PUBLICATIONS_ONLY = 0x00000010
|
256
|
+
MQREGO_PUBLISH_ON_REQUEST_ONLY = 0x00000020
|
257
|
+
MQREGO_DEREGISTER_ALL = 0x00000040
|
258
|
+
MQREGO_INCLUDE_STREAM_NAME = 0x00000080
|
259
|
+
MQREGO_INFORM_IF_RETAINED = 0x00000100
|
260
|
+
MQREGO_DUPLICATES_OK = 0x00000200
|
261
|
+
MQREGO_NON_PERSISTENT = 0x00000400
|
262
|
+
MQREGO_PERSISTENT = 0x00000800
|
263
|
+
MQREGO_PERSISTENT_AS_PUBLISH = 0x00001000
|
264
|
+
MQREGO_PERSISTENT_AS_Q = 0x00002000
|
265
|
+
MQREGO_ADD_NAME = 0x00004000
|
266
|
+
MQREGO_NO_ALTERATION = 0x00008000
|
267
|
+
MQREGO_FULL_RESPONSE = 0x00010000
|
268
|
+
MQREGO_JOIN_SHARED = 0x00020000
|
269
|
+
MQREGO_JOIN_EXCLUSIVE = 0x00040000
|
270
|
+
MQREGO_LEAVE_ONLY = 0x00080000
|
271
|
+
MQREGO_VARIABLE_USER_ID = 0x00100000
|
272
|
+
MQREGO_LOCKED = 0x00200000
|
273
|
+
MQUA_FIRST = 65536
|
274
|
+
MQUA_LAST = 999999999
|
275
|
+
end
|
data/lib/wmq/wmq_temp.rb
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
################################################################################
|
16
|
+
|
17
|
+
module WMQ
|
18
|
+
|
19
|
+
# Temporary placeholder until the following code is moved to 'C'
|
20
|
+
|
21
|
+
#
|
22
|
+
class QueueManager
|
23
|
+
def method_missing(name, *args)
|
24
|
+
if args.size == 1
|
25
|
+
self.execute({:command=>name}.merge(args[0]))
|
26
|
+
elsif args.size == 0
|
27
|
+
self.execute({:command=>name})
|
28
|
+
else
|
29
|
+
raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Execute any MQSC command against the queue manager
|
34
|
+
#
|
35
|
+
# Example
|
36
|
+
# require 'wmq/wmq'
|
37
|
+
# require 'wmq/wmq_const_admin'
|
38
|
+
# WMQ::QueueManager.connect(:q_mgr_name=>'REID', :connection_name=>'localhost(1414)') do |qmgr|
|
39
|
+
# qmgr.mqsc('dis ql(*)').each {|item| p item }
|
40
|
+
# end
|
41
|
+
def mqsc(mqsc_text)
|
42
|
+
self.execute(:command=>:escape, :escape_type=>WMQ::MQET_MQSC, :escape_text=>mqsc_text).collect {|item| item[:escape_text] }
|
43
|
+
end
|
44
|
+
|
45
|
+
# Put a reply message back to the sender
|
46
|
+
#
|
47
|
+
# The :message is sent to the queue and queue manager specified in the
|
48
|
+
# :reply_to_q and :reply_to_q_mgr propoerties of the :request_message.
|
49
|
+
#
|
50
|
+
# The following rules are followed before sending the reply:
|
51
|
+
# - Only send replies to Request messages. No reply for Datagrams
|
52
|
+
# - Set the message type to Reply when replying to a request message
|
53
|
+
# - Reply with:
|
54
|
+
# - Remaining Expiry (Ideally deduct any processing time since get)
|
55
|
+
# - Same priority as received message
|
56
|
+
# - Same persistence as received message
|
57
|
+
# - Adhere to the Report options supplied for message and correlation id's
|
58
|
+
# in reply message
|
59
|
+
# - All headers must be returned on reply messages
|
60
|
+
# - This allows the calling application to store state information
|
61
|
+
# in these headers
|
62
|
+
# - Unless of course if the relevant header is input only and used
|
63
|
+
# for completing the request
|
64
|
+
# - In this case any remaining headers should be returned
|
65
|
+
# to the caller
|
66
|
+
#
|
67
|
+
# Parameters:
|
68
|
+
# * :request_message The message originally received
|
69
|
+
# * All the other parameters are the same as QueueManager#put
|
70
|
+
#
|
71
|
+
def put_to_reply_q(parms)
|
72
|
+
# Send replies only if message type is request
|
73
|
+
if parms[:request_message].descriptor[:msg_type] == WMQ::MQMT_REQUEST
|
74
|
+
request = parms.delete(:request_message)
|
75
|
+
|
76
|
+
reply = parms[:message] ||= Message.new(:data=>parms[:data])
|
77
|
+
reply.descriptor[:msg_type] = WMQ::MQMT_REPLY
|
78
|
+
reply.descriptor[:expiry] = request.descriptor[:expiry]
|
79
|
+
reply.descriptor[:priority] = request.descriptor[:priority]
|
80
|
+
reply.descriptor[:persistence]= request.descriptor[:persistence]
|
81
|
+
reply.descriptor[:format] = request.descriptor[:format]
|
82
|
+
|
83
|
+
# Set Correlation Id based on report options supplied
|
84
|
+
if request.descriptor[:report] & WMQ::MQRO_PASS_CORREL_ID != 0
|
85
|
+
reply.descriptor[:correl_id] = request.descriptor[:correl_id]
|
86
|
+
else
|
87
|
+
reply.descriptor[:correl_id] = request.descriptor[:msg_id]
|
88
|
+
end
|
89
|
+
|
90
|
+
# Set Message Id based on report options supplied
|
91
|
+
if request.descriptor[:report] & WMQ::MQRO_PASS_MSG_ID != 0
|
92
|
+
reply.descriptor[:msg_id] = request.descriptor[:msg_id]
|
93
|
+
end
|
94
|
+
|
95
|
+
parms[:q_name] = request.descriptor[:reply_to_q]
|
96
|
+
parms[:q_mgr_name]= request.descriptor[:reply_to_q_mgr]
|
97
|
+
return put(parms)
|
98
|
+
else
|
99
|
+
return false
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Put a message to the Dead Letter Queue
|
104
|
+
#
|
105
|
+
# If an error occurs when processing a datagram message
|
106
|
+
# it is necessary to move the message to the dead letter queue.
|
107
|
+
# I.e. An error message cannot be sent back to the sender because
|
108
|
+
# the original message was not a request message.
|
109
|
+
# I.e. msg_type != WMQ::MQMT_REQUEST
|
110
|
+
#
|
111
|
+
# All existing message data, message descriptor and message headers
|
112
|
+
# are retained.
|
113
|
+
#
|
114
|
+
def put_to_dead_letter_q(parms)
|
115
|
+
message = parms[:message] ||= Message.new(:data=>parms[:data])
|
116
|
+
dlh = {
|
117
|
+
:header_type =>:dead_letter_header,
|
118
|
+
:reason =>parms.delete(:reason),
|
119
|
+
:dest_q_name =>parms.delete(:q_name),
|
120
|
+
:dest_q_mgr_name =>self.name}
|
121
|
+
|
122
|
+
message.headers.unshift(dlh)
|
123
|
+
parms[:q_name]='SYSTEM.DEAD.LETTER.QUEUE' #TODO Should be obtained from QMGR config
|
124
|
+
return self.put(parms)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
# Message contains the message descriptor (MQMD), data
|
130
|
+
# and any headers.
|
131
|
+
#
|
132
|
+
# Note:
|
133
|
+
# * The format in the descriptor applies only to the format of the data portion,
|
134
|
+
# not the format of any included headers
|
135
|
+
# * The message format can ONLY be supplied in the descriptor.
|
136
|
+
# * I.e. It is the format of the data, Not the headers.
|
137
|
+
# * On the wire formats are determined automatically by the :header_type key for
|
138
|
+
# each header
|
139
|
+
# * Other WebSphere MQ interfaces require that the formats be "daisy-chained"
|
140
|
+
# * I.e. The MQMD.Format is actually the format of the first header
|
141
|
+
# * Ruby WMQ removes this tedious requirement and performs this
|
142
|
+
# requirement automatically under the covers
|
143
|
+
# * The format of any header should not be supplied in the descriptor or any header
|
144
|
+
#
|
145
|
+
# Message has the following attributes:
|
146
|
+
# * descriptor = {
|
147
|
+
# # WebSphere MQ Equivalent
|
148
|
+
# :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
|
149
|
+
# WMQ::MQFMT_NONE # Do not supply header formats here
|
150
|
+
# :original_length => Number # MQMD.OriginalLength
|
151
|
+
# :priority => 0 .. 9 # MQMD.Priority
|
152
|
+
# :put_time => String # MQMD.PutTime
|
153
|
+
# :msg_id => String ...
|
154
|
+
# :expiry => Number
|
155
|
+
# :persistence => Number
|
156
|
+
# :reply_to_q => String
|
157
|
+
# :correl_id => String
|
158
|
+
# :feedback => Number
|
159
|
+
# :offset => Number
|
160
|
+
# :report => Number
|
161
|
+
# :msg_flags => Number
|
162
|
+
# :reply_to_q_mgr => String
|
163
|
+
# :appl_identity_data => String
|
164
|
+
# :put_appl_name => String
|
165
|
+
# :user_identifier => String
|
166
|
+
# :msg_seq_number => Number
|
167
|
+
# :appl_origin_data => String
|
168
|
+
# :accounting_token => String
|
169
|
+
# :backout_count => Number
|
170
|
+
# :coded_char_set_id => Number
|
171
|
+
# :put_appl_type => Number
|
172
|
+
# :msg_type => Number
|
173
|
+
# :group_id => String
|
174
|
+
# :put_date => String
|
175
|
+
# :encoding => Number
|
176
|
+
# }
|
177
|
+
# * data => String
|
178
|
+
# * headers => Array of Hashes
|
179
|
+
# * Note: Do not supply the format of any header. Ruby WMQ does this for you.
|
180
|
+
#
|
181
|
+
# The following headers are supported:
|
182
|
+
# * Rules And Formatting Header (RFH)
|
183
|
+
# :header_type => :rf_header
|
184
|
+
# :....
|
185
|
+
# * Rules and Formatting V2 Header (RFH2)
|
186
|
+
# ....
|
187
|
+
# * Dead Letter Header
|
188
|
+
# * CICS Header
|
189
|
+
# * IMS Header
|
190
|
+
# * Transmission Queue Header
|
191
|
+
# * ...
|
192
|
+
class Message
|
193
|
+
attr_reader :data, :descriptor, :headers
|
194
|
+
attr_writer :data, :descriptor, :headers
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
data/lib/wmq.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
################################################################################
|
16
|
+
|
17
|
+
# Load wmq that uses auto-load library.
|
18
|
+
#
|
19
|
+
# If it fails, then it is likely due to this platform not being supported
|
20
|
+
# by auto load facility in Ruby WMQ, so try to load client linked library
|
21
|
+
begin
|
22
|
+
require 'wmq/wmq'
|
23
|
+
rescue LoadError
|
24
|
+
require 'wmq/wmq_client'
|
25
|
+
end
|