@@ -68,7 +68,7 @@ func (ctx ContextImpl) CreateConsumer(dest jms20subset.Destination) (jms20subset
68
68
func (ctx ContextImpl ) CreateConsumerWithSelector (dest jms20subset.Destination , selector string ) (jms20subset.JMSConsumer , jms20subset.JMSException ) {
69
69
70
70
// Lock the context while we are making calls to the queue manager so that it
71
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
71
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
72
72
ctx .ctxLock .Lock ()
73
73
defer ctx .ctxLock .Unlock ()
74
74
@@ -126,7 +126,7 @@ func (ctx ContextImpl) CreateConsumerWithSelector(dest jms20subset.Destination,
126
126
func (ctx ContextImpl ) CreateBrowser (dest jms20subset.Destination ) (jms20subset.QueueBrowser , jms20subset.JMSException ) {
127
127
128
128
// Lock the context while we are making calls to the queue manager so that it
129
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
129
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
130
130
ctx .ctxLock .Lock ()
131
131
defer ctx .ctxLock .Unlock ()
132
132
@@ -177,18 +177,14 @@ func (ctx ContextImpl) CreateBrowser(dest jms20subset.Destination) (jms20subset.
177
177
// CreateTextMessage is a JMS standard mechanism for creating a TextMessage.
178
178
func (ctx ContextImpl ) CreateTextMessage () jms20subset.TextMessage {
179
179
180
- // Lock the context while we are making calls to the queue manager so that it
181
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
182
- ctx .ctxLock .Lock ()
183
- defer ctx .ctxLock .Unlock ()
184
-
185
180
var bodyStr * string
186
181
thisMsgHandle := ctx .createMsgHandle (ctx .qMgr )
187
182
188
183
return & TextMessageImpl {
189
184
bodyStr : bodyStr ,
190
185
MessageImpl : MessageImpl {
191
186
msgHandle : & thisMsgHandle ,
187
+ ctxLock : ctx .ctxLock ,
192
188
},
193
189
}
194
190
}
@@ -197,6 +193,11 @@ func (ctx ContextImpl) CreateTextMessage() jms20subset.TextMessage {
197
193
// store and retrieve message properties.
198
194
func (ctx ContextImpl ) createMsgHandle (qMgr ibmmq.MQQueueManager ) ibmmq.MQMessageHandle {
199
195
196
+ // Lock the context while we are making calls to the queue manager so that it
197
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
198
+ ctx .ctxLock .Lock ()
199
+ defer ctx .ctxLock .Unlock ()
200
+
200
201
cmho := ibmmq .NewMQCMHO ()
201
202
thisMsgHandle , err := qMgr .CrtMH (cmho )
202
203
@@ -220,17 +221,13 @@ func (ctx ContextImpl) createMsgHandle(qMgr ibmmq.MQQueueManager) ibmmq.MQMessag
220
221
// and initialise it with the chosen text string.
221
222
func (ctx ContextImpl ) CreateTextMessageWithString (txt string ) jms20subset.TextMessage {
222
223
223
- // Lock the context while we are making calls to the queue manager so that it
224
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
225
- ctx .ctxLock .Lock ()
226
- defer ctx .ctxLock .Unlock ()
227
-
228
224
thisMsgHandle := ctx .createMsgHandle (ctx .qMgr )
229
225
230
226
msg := & TextMessageImpl {
231
227
bodyStr : & txt ,
232
228
MessageImpl : MessageImpl {
233
229
msgHandle : & thisMsgHandle ,
230
+ ctxLock : ctx .ctxLock ,
234
231
},
235
232
}
236
233
@@ -240,51 +237,44 @@ func (ctx ContextImpl) CreateTextMessageWithString(txt string) jms20subset.TextM
240
237
// CreateBytesMessage is a JMS standard mechanism for creating a BytesMessage.
241
238
func (ctx ContextImpl ) CreateBytesMessage () jms20subset.BytesMessage {
242
239
243
- // Lock the context while we are making calls to the queue manager so that it
244
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
245
- ctx .ctxLock .Lock ()
246
- defer ctx .ctxLock .Unlock ()
247
-
248
240
var thisBodyBytes * []byte
249
241
thisMsgHandle := ctx .createMsgHandle (ctx .qMgr )
250
242
251
243
return & BytesMessageImpl {
252
244
bodyBytes : thisBodyBytes ,
253
245
MessageImpl : MessageImpl {
254
246
msgHandle : & thisMsgHandle ,
247
+ ctxLock : ctx .ctxLock ,
255
248
},
256
249
}
257
250
}
258
251
259
252
// CreateBytesMessageWithBytes is a JMS standard mechanism for creating a BytesMessage.
260
253
func (ctx ContextImpl ) CreateBytesMessageWithBytes (bytes []byte ) jms20subset.BytesMessage {
261
254
262
- // Lock the context while we are making calls to the queue manager so that it
263
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
264
- ctx .ctxLock .Lock ()
265
- defer ctx .ctxLock .Unlock ()
266
-
267
255
thisMsgHandle := ctx .createMsgHandle (ctx .qMgr )
268
256
269
257
return & BytesMessageImpl {
270
258
bodyBytes : & bytes ,
271
259
MessageImpl : MessageImpl {
272
260
msgHandle : & thisMsgHandle ,
261
+ ctxLock : ctx .ctxLock ,
273
262
},
274
263
}
275
264
}
276
265
277
266
// Commit confirms all messages that were sent under this transaction.
278
267
func (ctx ContextImpl ) Commit () jms20subset.JMSException {
279
268
280
- // Lock the context while we are making calls to the queue manager so that it
281
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
282
- ctx .ctxLock .Lock ()
283
- defer ctx .ctxLock .Unlock ()
284
-
285
269
var retErr jms20subset.JMSException
286
270
287
271
if (ibmmq.MQQueueManager {}) != ctx .qMgr {
272
+
273
+ // Lock the context while we are making calls to the queue manager so that it
274
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
275
+ ctx .ctxLock .Lock ()
276
+ defer ctx .ctxLock .Unlock ()
277
+
288
278
err := ctx .qMgr .Cmit ()
289
279
290
280
if err != nil {
@@ -336,14 +326,15 @@ func (ctx ContextImpl) Commit() jms20subset.JMSException {
336
326
// Rollback releases all messages that were sent under this transaction.
337
327
func (ctx ContextImpl ) Rollback () jms20subset.JMSException {
338
328
339
- // Lock the context while we are making calls to the queue manager so that it
340
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
341
- ctx .ctxLock .Lock ()
342
- defer ctx .ctxLock .Unlock ()
343
-
344
329
var retErr jms20subset.JMSException
345
330
346
331
if (ibmmq.MQQueueManager {}) != ctx .qMgr {
332
+
333
+ // Lock the context while we are making calls to the queue manager so that it
334
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
335
+ ctx .ctxLock .Lock ()
336
+ defer ctx .ctxLock .Unlock ()
337
+
347
338
err := ctx .qMgr .Back ()
348
339
349
340
if err != nil {
@@ -370,7 +361,7 @@ func (ctx ContextImpl) Close() {
370
361
if (ibmmq.MQQueueManager {}) != ctx .qMgr {
371
362
372
363
// Lock the context while we are making calls to the queue manager so that it
373
- // doesn't conflict with the finalizer we use (below) to delete unused MessageHandles.
364
+ // doesn't conflict with the finalizer we use to delete unused MessageHandles.
374
365
ctx .ctxLock .Lock ()
375
366
defer ctx .ctxLock .Unlock ()
376
367
0 commit comments