ferocia-rubywmq 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +8 -0
- data/LICENSE +13 -0
- data/Manifest.txt +20 -0
- data/README +73 -0
- data/examples/each_a.rb +32 -0
- data/examples/each_b.rb +41 -0
- data/examples/each_header.rb +38 -0
- data/examples/files_to_q.cfg +24 -0
- data/examples/files_to_q.rb +47 -0
- data/examples/get_a.rb +35 -0
- data/examples/get_client.rb +51 -0
- data/examples/put1_a.rb +25 -0
- data/examples/put1_b.rb +33 -0
- data/examples/put1_c.rb +32 -0
- data/examples/put_a.rb +35 -0
- data/examples/put_b.rb +43 -0
- data/examples/put_dlh.rb +41 -0
- data/examples/put_dynamic_q.rb +38 -0
- data/examples/put_group_a.rb +51 -0
- data/examples/put_group_b.rb +53 -0
- data/examples/put_rfh.rb +67 -0
- data/examples/put_rfh2_a.rb +43 -0
- data/examples/put_rfh2_b.rb +43 -0
- data/examples/put_xmit_q.rb +33 -0
- data/examples/q_to_files.cfg +17 -0
- data/examples/q_to_files.rb +48 -0
- data/examples/request.rb +60 -0
- data/examples/server.rb +97 -0
- data/ext/build.bat +3 -0
- data/ext/build.sh +6 -0
- data/ext/decode_rfh.c +348 -0
- data/ext/decode_rfh.h +45 -0
- data/ext/extconf.rb +44 -0
- data/ext/extconf_client.rb +40 -0
- data/ext/generate/generate_const.rb +167 -0
- data/ext/generate/generate_reason.rb +246 -0
- data/ext/generate/generate_structs.rb +97 -0
- data/ext/generate/wmq_structs.erb +371 -0
- data/ext/lib/wmq_temp.rb +197 -0
- data/ext/wmq.c +93 -0
- data/ext/wmq.h +367 -0
- data/ext/wmq_message.c +671 -0
- data/ext/wmq_mq_load.c +217 -0
- data/ext/wmq_queue.c +1411 -0
- data/ext/wmq_queue_manager.c +1587 -0
- data/lib/wmq.rb +25 -0
- data/rubywmq.binary.gemspec +32 -0
- data/rubywmq.gemspec +33 -0
- data/tests/test.rb +328 -0
- metadata +124 -0
data/ext/wmq_mq_load.c
ADDED
@@ -0,0 +1,217 @@
|
|
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
|
+
#include "wmq.h"
|
18
|
+
|
19
|
+
#if defined _WIN32 && !defined __CYGWIN__
|
20
|
+
/*
|
21
|
+
* WINDOWS 32 BIT
|
22
|
+
*/
|
23
|
+
|
24
|
+
#define MQ_LOAD(LIBRARY) \
|
25
|
+
HINSTANCE handle = LoadLibrary(LIBRARY); \
|
26
|
+
if (!handle) \
|
27
|
+
{ \
|
28
|
+
rb_raise(wmq_exception, \
|
29
|
+
"WMQ::QueueManager#connect(). Failed to load MQ Library:%s, rc=%ld", \
|
30
|
+
LIBRARY, \
|
31
|
+
GetLastError()); \
|
32
|
+
}
|
33
|
+
|
34
|
+
#define MQ_RELEASE FreeLibrary((HINSTANCE)pqm->mq_lib_handle);
|
35
|
+
|
36
|
+
#define MQ_FUNCTION(FUNC, CAST) \
|
37
|
+
pqm->FUNC = (CAST)GetProcAddress(handle, #FUNC); \
|
38
|
+
if (!pqm->FUNC) \
|
39
|
+
{ \
|
40
|
+
rb_raise(wmq_exception, "Failed to find API "#FUNC" in MQ Library"); \
|
41
|
+
}
|
42
|
+
|
43
|
+
#define MQ_LIBRARY_SERVER "mqm"
|
44
|
+
#define MQ_LIBRARY_CLIENT "mqic32"
|
45
|
+
#elif defined(SOLARIS) || defined(__SVR4) || defined(__linux__) || defined(LINUX)
|
46
|
+
/*
|
47
|
+
* SOLARIS, LINUX
|
48
|
+
*/
|
49
|
+
|
50
|
+
#ifndef RTLD_LAZY
|
51
|
+
#define RTLD_LAZY 1
|
52
|
+
#endif
|
53
|
+
#ifndef RTLD_GLOBAL
|
54
|
+
#define RTLD_GLOBAL 0
|
55
|
+
#endif
|
56
|
+
|
57
|
+
#if defined(__linux__) || defined(LINUX)
|
58
|
+
#include <dlfcn.h>
|
59
|
+
#endif
|
60
|
+
|
61
|
+
#define MQ_LOAD(LIBRARY) \
|
62
|
+
void* handle = (void*)dlopen(LIBRARY, RTLD_LAZY|RTLD_GLOBAL); \
|
63
|
+
if (!handle) \
|
64
|
+
{ \
|
65
|
+
rb_raise(wmq_exception, \
|
66
|
+
"WMQ::QueueManager#connect(). Failed to load MQ Library:%s, rc=%s", \
|
67
|
+
LIBRARY, \
|
68
|
+
dlerror()); \
|
69
|
+
}
|
70
|
+
|
71
|
+
#define MQ_RELEASE dlclose(pqm->mq_lib_handle);
|
72
|
+
|
73
|
+
#define MQ_FUNCTION(FUNC, CAST) \
|
74
|
+
pqm->FUNC = (CAST)dlsym(handle, #FUNC); \
|
75
|
+
if (!pqm->FUNC) \
|
76
|
+
{ \
|
77
|
+
rb_raise(wmq_exception, "Failed to find API "#FUNC" in MQ Library"); \
|
78
|
+
}
|
79
|
+
|
80
|
+
#if defined(SOLARIS) || defined(__SVR4)
|
81
|
+
#define MQ_LIBRARY_SERVER "libmqm.so"
|
82
|
+
#define MQ_LIBRARY_CLIENT "libmqic.so"
|
83
|
+
#else
|
84
|
+
#define MQ_LIBRARY_SERVER "libmqm_r.so"
|
85
|
+
#define MQ_LIBRARY_CLIENT "libmqic_r.so"
|
86
|
+
#endif
|
87
|
+
#elif defined(__hpux)
|
88
|
+
/*
|
89
|
+
* HP-UX
|
90
|
+
*/
|
91
|
+
|
92
|
+
#define MQ_LOAD(LIBRARY) \
|
93
|
+
shl_t handle = shl_load(file, BIND_DEFERRED, 0); \
|
94
|
+
if (!handle) \
|
95
|
+
{ \
|
96
|
+
rb_raise(wmq_exception, \
|
97
|
+
"WMQ::QueueManager#connect(). Failed to load MQ Library:%s, rc=%s", \
|
98
|
+
LIBRARY, \
|
99
|
+
strerror(errno)); \
|
100
|
+
}
|
101
|
+
|
102
|
+
#define MQ_RELEASE shl_unload((shl_t)pqm->mq_lib_handle);
|
103
|
+
|
104
|
+
#define MQ_FUNCTION(FUNC, CAST) \
|
105
|
+
pqm->FUNC = NULL; \
|
106
|
+
shl_findsym(&handle,FUNC,TYPE_PROCEDURE,(void*)&(pqm->FUNC)); \
|
107
|
+
if(pqm->FUNC == NULL) \
|
108
|
+
{ \
|
109
|
+
shl_findsym(&handle,FUNC,TYPE_UNDEFINED,(void*)&(pqm->FUNC)); \
|
110
|
+
if(pqm->FUNC == NULL) \
|
111
|
+
{ \
|
112
|
+
rb_raise(wmq_exception, "Failed to find API "#FUNC" in MQ Library"); \
|
113
|
+
} \
|
114
|
+
}
|
115
|
+
|
116
|
+
#define MQ_LIBRARY_SERVER "libmqm_r.sl"
|
117
|
+
#define MQ_LIBRARY_CLIENT "libmqic_r.sl"
|
118
|
+
#endif
|
119
|
+
|
120
|
+
void Queue_manager_mq_load(PQUEUE_MANAGER pqm)
|
121
|
+
{
|
122
|
+
#if defined MQ_FUNCTION
|
123
|
+
PMQCHAR library;
|
124
|
+
if(pqm->is_client_conn)
|
125
|
+
{
|
126
|
+
library = MQ_LIBRARY_CLIENT;
|
127
|
+
if(pqm->trace_level) printf("WMQ::QueueManager#connect() Loading MQ Client Library:%s\n", library);
|
128
|
+
}
|
129
|
+
else
|
130
|
+
{
|
131
|
+
library = MQ_LIBRARY_SERVER;
|
132
|
+
if(pqm->trace_level) printf("WMQ::QueueManager#connect() Loading MQ Server Library:%s\n", library);
|
133
|
+
}
|
134
|
+
|
135
|
+
{
|
136
|
+
MQ_LOAD(library)
|
137
|
+
|
138
|
+
if(pqm->trace_level>1) printf("WMQ::QueueManager#connect() MQ Library:%s Loaded successfully\n", library);
|
139
|
+
|
140
|
+
MQ_FUNCTION(MQCONNX,void(*)(PMQCHAR,PMQCNO,PMQHCONN,PMQLONG,PMQLONG))
|
141
|
+
MQ_FUNCTION(MQCONN, void(*)(PMQCHAR,PMQHCONN,PMQLONG,PMQLONG))
|
142
|
+
MQ_FUNCTION(MQDISC,void(*) (PMQHCONN,PMQLONG,PMQLONG))
|
143
|
+
MQ_FUNCTION(MQBEGIN,void(*)(MQHCONN,PMQVOID,PMQLONG,PMQLONG))
|
144
|
+
MQ_FUNCTION(MQBACK,void(*) (MQHCONN,PMQLONG,PMQLONG))
|
145
|
+
MQ_FUNCTION(MQCMIT,void(*) (MQHCONN,PMQLONG,PMQLONG))
|
146
|
+
MQ_FUNCTION(MQPUT1,void(*) (MQHCONN,PMQVOID,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG))
|
147
|
+
|
148
|
+
MQ_FUNCTION(MQOPEN,void(*) (MQHCONN,PMQVOID,MQLONG,PMQHOBJ,PMQLONG,PMQLONG))
|
149
|
+
MQ_FUNCTION(MQCLOSE,void(*)(MQHCONN,PMQHOBJ,MQLONG,PMQLONG,PMQLONG))
|
150
|
+
MQ_FUNCTION(MQGET,void(*) (MQHCONN,MQHOBJ,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG,PMQLONG))
|
151
|
+
MQ_FUNCTION(MQPUT,void(*) (MQHCONN,MQHOBJ,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG))
|
152
|
+
|
153
|
+
MQ_FUNCTION(MQINQ,void(*) (MQHCONN,MQHOBJ,MQLONG,PMQLONG,MQLONG,PMQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG))
|
154
|
+
MQ_FUNCTION(MQSET,void(*) (MQHCONN,MQHOBJ,MQLONG,PMQLONG,MQLONG,PMQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG))
|
155
|
+
|
156
|
+
MQ_FUNCTION(mqCreateBag,void(*)(MQLONG,PMQHBAG,PMQLONG,PMQLONG))
|
157
|
+
MQ_FUNCTION(mqDeleteBag,void(*)(PMQHBAG,PMQLONG,PMQLONG))
|
158
|
+
MQ_FUNCTION(mqClearBag,void(*)(MQHBAG,PMQLONG,PMQLONG))
|
159
|
+
MQ_FUNCTION(mqExecute,void(*)(MQHCONN,MQLONG,MQHBAG,MQHBAG,MQHBAG,MQHOBJ,MQHOBJ,PMQLONG,PMQLONG))
|
160
|
+
MQ_FUNCTION(mqCountItems,void(*)(MQHBAG,MQLONG,PMQLONG,PMQLONG,PMQLONG))
|
161
|
+
MQ_FUNCTION(mqInquireBag,void(*)(MQHBAG,MQLONG,MQLONG,PMQHBAG,PMQLONG,PMQLONG))
|
162
|
+
MQ_FUNCTION(mqInquireItemInfo,void(*)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG,PMQLONG,PMQLONG))
|
163
|
+
MQ_FUNCTION(mqInquireInteger,void(*)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG,PMQLONG))
|
164
|
+
MQ_FUNCTION(mqInquireString,void(*)(MQHBAG,MQLONG,MQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG,PMQLONG,PMQLONG))
|
165
|
+
MQ_FUNCTION(mqAddInquiry,void(*)(MQHBAG,MQLONG,PMQLONG,PMQLONG))
|
166
|
+
MQ_FUNCTION(mqAddInteger,void(*)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG))
|
167
|
+
MQ_FUNCTION(mqAddString,void(*)(MQHBAG,MQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG))
|
168
|
+
|
169
|
+
pqm->mq_lib_handle = (void*)handle;
|
170
|
+
|
171
|
+
if(pqm->trace_level>1) printf("WMQ::QueueManager#connect() MQ API's loaded successfully\n");
|
172
|
+
}
|
173
|
+
#else
|
174
|
+
/*
|
175
|
+
* For all the other platforms were we have to have two versions of Ruby WMQ
|
176
|
+
* 1: Linked with MQ Server Library
|
177
|
+
* 2: Linked with MQ Client Library
|
178
|
+
*
|
179
|
+
* As a result to use the client library:
|
180
|
+
* require 'wmq/wmq_client'
|
181
|
+
*/
|
182
|
+
pqm->MQCONNX = &MQCONNX;
|
183
|
+
pqm->MQCONN = &MQCONN;
|
184
|
+
pqm->MQDISC = &MQDISC;
|
185
|
+
pqm->MQBEGIN = &MQBEGIN;
|
186
|
+
pqm->MQBACK = &MQBACK;
|
187
|
+
pqm->MQCMIT = &MQCMIT;
|
188
|
+
pqm->MQPUT1 = &MQPUT1;
|
189
|
+
|
190
|
+
pqm->MQOPEN = &MQOPEN;
|
191
|
+
pqm->MQCLOSE = &MQCLOSE;
|
192
|
+
pqm->MQGET = &MQGET;
|
193
|
+
pqm->MQPUT = &MQPUT;
|
194
|
+
|
195
|
+
pqm->MQINQ = &MQINQ;
|
196
|
+
pqm->MQSET = &MQSET;
|
197
|
+
|
198
|
+
pqm->mqCreateBag = &mqCreateBag;
|
199
|
+
pqm->mqClearBag = &mqClearBag;
|
200
|
+
pqm->mqExecute = &mqExecute;
|
201
|
+
pqm->mqCountItems = &mqCountItems;
|
202
|
+
pqm->mqInquireBag = &mqInquireBag;
|
203
|
+
pqm->mqInquireItemInfo= &mqInquireItemInfo;
|
204
|
+
pqm->mqInquireInteger = &mqInquireInteger;
|
205
|
+
pqm->mqInquireString = &mqInquireString;
|
206
|
+
#endif
|
207
|
+
}
|
208
|
+
|
209
|
+
void Queue_manager_mq_free(PQUEUE_MANAGER pqm)
|
210
|
+
{
|
211
|
+
if(pqm->mq_lib_handle)
|
212
|
+
{
|
213
|
+
if(pqm->trace_level>1) printf("WMQ::QueueManager#gc() Releasing MQ Library\n");
|
214
|
+
MQ_RELEASE
|
215
|
+
pqm->mq_lib_handle = 0;
|
216
|
+
}
|
217
|
+
}
|