Skip to content

Commit 5fade19

Browse files
committed
bugfix: Maintain DeliveryMode when setting MQMD header properties - #51
1 parent 046052a commit 5fade19

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

mqjms/ProducerImpl.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@ func (producer ProducerImpl) Send(dest jms20subset.Destination, msg jms20subset.
8484
pmo.Options |= ibmmq.MQPMO_ASYNC_RESPONSE
8585
}
8686

87-
// Convert the JMS persistence into the equivalent MQ message descriptor
88-
// attribute.
89-
if producer.deliveryMode == jms20subset.DeliveryMode_NON_PERSISTENT {
90-
putmqmd.Persistence = ibmmq.MQPER_NOT_PERSISTENT
91-
} else {
92-
putmqmd.Persistence = ibmmq.MQPER_PERSISTENT
93-
}
94-
9587
var buffer []byte
9688

9789
// We have a "Message" object and can use a switch to safely convert it
@@ -145,6 +137,14 @@ func (producer ProducerImpl) Send(dest jms20subset.Destination, msg jms20subset.
145137
log.Fatal(jms20subset.CreateJMSException("UnexpectedMessageType", "UnexpectedMessageType-send1", nil))
146138
}
147139

140+
// Convert the JMS persistence into the equivalent MQ message descriptor
141+
// attribute.
142+
if producer.deliveryMode == jms20subset.DeliveryMode_NON_PERSISTENT {
143+
putmqmd.Persistence = ibmmq.MQPER_NOT_PERSISTENT
144+
} else {
145+
putmqmd.Persistence = ibmmq.MQPER_PERSISTENT
146+
}
147+
148148
// If the producer has a TTL specified then apply it to the put MQMD so
149149
// that MQ will honour it.
150150
if producer.timeToLive > 0 {

priority_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func TestPrioritySetGet(t *testing.T) {
7676
// Go again with a different priority.
7777
newMsgPriority := 2
7878
producer = producer.SetPriority(newMsgPriority)
79+
producer = producer.SetDeliveryMode(jms20subset.DeliveryMode_PERSISTENT)
7980
assert.Equal(t, newMsgPriority, producer.GetPriority())
8081

8182
errSend = producer.Send(queue, txtMsg)
@@ -95,11 +96,13 @@ func TestPrioritySetGet(t *testing.T) {
9596
// Check the Priority
9697
gotPropValue = rcvMsg.GetJMSPriority()
9798
assert.Equal(t, newMsgPriority, gotPropValue)
99+
assert.Equal(t, jms20subset.DeliveryMode_PERSISTENT, rcvMsg.GetJMSDeliveryMode())
98100

99101
// -------
100102
// Go again with a different priority.
101103
newMsgPriority2 := 7
102104
producer = producer.SetPriority(newMsgPriority2)
105+
producer = producer.SetDeliveryMode(jms20subset.DeliveryMode_NON_PERSISTENT)
103106
assert.Equal(t, newMsgPriority2, producer.GetPriority())
104107

105108
errSend = producer.Send(queue, txtMsg)
@@ -119,6 +122,7 @@ func TestPrioritySetGet(t *testing.T) {
119122
// Check the Priority
120123
gotPropValue = rcvMsg.GetJMSPriority()
121124
assert.Equal(t, newMsgPriority2, gotPropValue)
125+
assert.Equal(t, jms20subset.DeliveryMode_NON_PERSISTENT, rcvMsg.GetJMSDeliveryMode())
122126

123127
}
124128

0 commit comments

Comments
 (0)