Skip to content

Commit b7cfd31

Browse files
committed
Merge branch 'UNO-SOFT-v8-c'
2 parents da0625a + 945da5f commit b7cfd31

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
=======
4+
### October 2018
5+
* Allow compilation against MQ v8
6+
37
## October 2018 - v3.0.0
48
* Added functions to the mqmetric package to assist with collecting channel status
59
* Better handle truncated messages when listing the queues that match a pattern

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This repository demonstrates how you can call IBM MQ from applications written i
66
77
This repository previously contained sample programs that exported MQ statistics to some monitoring packages. These have now been moved to a new [GitHub repository called mq-metric-samples](https://github.com/ibm-messaging/mq-metric-samples).
88

9-
A minimum level of MQ V9 is required to build these packages.
10-
The monitoring data published by the queue manager is not available before that version; the interface also assumes availability of MQI structures from that level of MQ.
9+
A minimum level of MQ V8 is required to build these packages.
10+
However, note that the monitoring data published by the queue manager is not available before MQ V9.
1111

1212
## Health Warning
1313

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module github.com/ibm-messaging/mq-golang

ibmmq/mqiMQCNO.go

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@ package ibmmq
2626
#include <cmqc.h>
2727
#include <cmqxc.h>
2828
29+
void freeCCDTUrl(MQCNO *mqcno) {
30+
#if defined(MQCNO_VERSION_6) && MQCNO_CURRENT_VERSION >= MQCNO_VERSION_6
31+
if (mqcno->CCDTUrlPtr != NULL) {
32+
free(mqcno->CCDTUrlPtr);
33+
}
34+
#endif
35+
}
36+
37+
void setCCDTUrl(MQCNO *mqcno, PMQCHAR url, MQLONG length) {
38+
#if defined(MQCNO_VERSION_6) && MQCNO_CURRENT_VERSION >= MQCNO_VERSION_6
39+
if (mqcno->Version < MQCNO_VERSION_6) {
40+
mqcno->Version = MQCNO_VERSION_6;
41+
}
42+
mqcno->CCDTUrlOffset = 0;
43+
mqcno->CCDTUrlPtr = NULL;
44+
mqcno->CCDTUrlLength = length;
45+
if (url != NULL) {
46+
mqcno->CCDTUrlPtr = url;
47+
}
48+
#else
49+
if (url != NULL) {
50+
free(url);
51+
}
52+
#endif
53+
}
54+
2955
*/
3056
import "C"
3157
import "unsafe"
@@ -152,14 +178,10 @@ func copyCNOtoC(mqcno *C.MQCNO, gocno *MQCNO) {
152178
mqcno.SecurityParmsPtr = nil
153179
}
154180

155-
mqcno.CCDTUrlOffset = 0
156-
if len(gocno.CCDTUrl) != 0 {
157-
mqcno.CCDTUrlPtr = C.PMQCHAR(unsafe.Pointer(C.CString(gocno.CCDTUrl)))
158-
mqcno.CCDTUrlLength = C.MQLONG(len(gocno.CCDTUrl))
159-
} else {
160-
mqcno.CCDTUrlPtr = nil
161-
mqcno.CCDTUrlLength = 0
162-
}
181+
// The CCDT URL option was introduced in MQ V9. To compile against older
182+
// versions of MQ, setting of it has been moved to a C function that can use
183+
// the pre-processor to decide whether it's needed.
184+
C.setCCDTUrl(mqcno, C.PMQCHAR(C.CString(gocno.CCDTUrl)), C.MQLONG(len(gocno.CCDTUrl)))
163185
return
164186
}
165187

@@ -187,8 +209,6 @@ func copyCNOfromC(mqcno *C.MQCNO, gocno *MQCNO) {
187209
C.free(unsafe.Pointer(mqcno.SSLConfigPtr))
188210
}
189211

190-
if mqcno.CCDTUrlPtr != nil {
191-
C.free(unsafe.Pointer(mqcno.CCDTUrlPtr))
192-
}
212+
C.freeCCDTUrl(mqcno)
193213
return
194214
}

samples/clientconn/clientconn.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ func main() {
7777
// Reference the CD structure from the CNO
7878
// and indicate that we want to use the client
7979
// connection method.
80-
cno.ClientConn = cd
80+
if true {
81+
cno.ClientConn = cd
82+
} else {
83+
// This is how you might reference a remote CCDT instead of
84+
// explicitly putting in the CD structure.
85+
cno.CCDTUrl = "http://localhost:3030"
86+
}
8187
cno.Options = ibmmq.MQCNO_CLIENT_BINDING
8288

89+
8390
// Also fill in the userid and password if the MQSAMP_USER_ID
8491
// environment variable is set. This is the same as the C
8592
// sample programs such as amqsput.

0 commit comments

Comments
 (0)