/
mqiMQPMO.go
150 lines (121 loc) · 4.2 KB
/
mqiMQPMO.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package ibmmq
/*
Copyright (c) IBM Corporation 2016
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Contributors:
Mark Taylor - Initial Contribution
*/
/*
#include <stdlib.h>
#include <string.h>
#include <cmqc.h>
*/
import "C"
/*
MQPMO is a structure containing the MQ Put MessageOptions (MQPMO)
*/
type MQPMO struct {
Version int32
Options int32
Timeout int32
Context *MQObject
KnownDestCount int32
UnknownDestCount int32
InvalidDestCount int32
ResolvedQName string
ResolvedQMgrName string
// TODO: These fields are not currently mapped. The Dist List feature is not
// fully supported as Pub/Sub is the recommended approach.
//RecsPresent int32
//PutMsgRec []MQPMR
//ResponseRec []MQRR
OriginalMsgHandle MQMessageHandle
NewMsgHandle MQMessageHandle
Action int32
PubLevel int32
}
/*
NewMQPMO fills in default values for the MQPMO structure
*/
func NewMQPMO() *MQPMO {
pmo := new(MQPMO)
pmo.Version = int32(C.MQPMO_VERSION_1)
pmo.Options = int32(C.MQPMO_NONE)
pmo.Timeout = -1
pmo.Context = nil
pmo.KnownDestCount = 0
pmo.UnknownDestCount = 0
pmo.InvalidDestCount = 0
pmo.ResolvedQName = ""
pmo.ResolvedQMgrName = ""
pmo.OriginalMsgHandle.hMsg = C.MQHM_NONE
pmo.NewMsgHandle.hMsg = C.MQHM_NONE
pmo.Action = int32(C.MQACTP_NEW)
pmo.PubLevel = 9
return pmo
}
func copyPMOtoC(mqpmo *C.MQPMO, gopmo *MQPMO) {
setMQIString((*C.char)(&mqpmo.StrucId[0]), "PMO ", 4)
mqpmo.Version = C.MQLONG(gopmo.Version)
mqpmo.Options = C.MQLONG(gopmo.Options) | C.MQPMO_FAIL_IF_QUIESCING
mqpmo.Timeout = C.MQLONG(gopmo.Timeout)
if gopmo.Context != nil {
mqpmo.Context = gopmo.Context.hObj
}
mqpmo.KnownDestCount = C.MQLONG(gopmo.KnownDestCount)
mqpmo.UnknownDestCount = C.MQLONG(gopmo.UnknownDestCount)
mqpmo.InvalidDestCount = C.MQLONG(gopmo.InvalidDestCount)
setMQIString((*C.char)(&mqpmo.ResolvedQName[0]), gopmo.ResolvedQName, C.MQ_OBJECT_NAME_LENGTH)
setMQIString((*C.char)(&mqpmo.ResolvedQMgrName[0]), gopmo.ResolvedQMgrName, C.MQ_OBJECT_NAME_LENGTH)
mqpmo.RecsPresent = 0
mqpmo.PutMsgRecFields = 0
mqpmo.PutMsgRecOffset = 0
mqpmo.ResponseRecOffset = 0
mqpmo.PutMsgRecPtr = nil
mqpmo.ResponseRecPtr = nil
if gopmo.OriginalMsgHandle.hMsg != C.MQHM_NONE {
mqpmo.OriginalMsgHandle = gopmo.OriginalMsgHandle.hMsg
if mqpmo.Version < C.MQPMO_VERSION_3 {
mqpmo.Version = C.MQPMO_VERSION_3
}
}
if gopmo.NewMsgHandle.hMsg != C.MQHM_NONE {
mqpmo.NewMsgHandle = gopmo.NewMsgHandle.hMsg
if mqpmo.Version < C.MQPMO_VERSION_3 {
mqpmo.Version = C.MQPMO_VERSION_3
}
}
mqpmo.Action = C.MQLONG(gopmo.Action)
mqpmo.PubLevel = C.MQLONG(gopmo.PubLevel)
return
}
func copyPMOfromC(mqpmo *C.MQPMO, gopmo *MQPMO) {
gopmo.Version = int32(mqpmo.Version)
gopmo.Options = int32(mqpmo.Options)
gopmo.Timeout = int32(mqpmo.Timeout)
//gopmo.Context = mqpmo.Context // This is input only so don't copy back
gopmo.KnownDestCount = int32(mqpmo.KnownDestCount)
gopmo.UnknownDestCount = int32(mqpmo.UnknownDestCount)
gopmo.InvalidDestCount = int32(mqpmo.InvalidDestCount)
gopmo.ResolvedQName = trimStringN((*C.char)(&mqpmo.ResolvedQName[0]), C.MQ_OBJECT_NAME_LENGTH)
gopmo.ResolvedQMgrName = trimStringN((*C.char)(&mqpmo.ResolvedQMgrName[0]), C.MQ_OBJECT_NAME_LENGTH)
//gopmo.RecsPresent = int32(mqpmo.RecsPresent)
//gopmo.PutMsgRecFields = int32(mqpmo.PutMsgRecFields)
//gopmo.PutMsgRecOffset = int32(mqpmo.PutMsgRecOffset)
//gopmo.ResponseRecOffset = int32(mqpmo.ResponseRecOffset)
//gopmo.PutMsgRecPtr = mqpmo.PutMsgRecPtr
//gopmo.ResponseRecPtr = mqpmo.ResponseRecPtr
gopmo.OriginalMsgHandle.hMsg = mqpmo.OriginalMsgHandle
gopmo.NewMsgHandle.hMsg = mqpmo.NewMsgHandle
gopmo.Action = int32(mqpmo.Action)
gopmo.PubLevel = int32(mqpmo.PubLevel)
return
}