Skip to content

Commit e84ce0e

Browse files
authored
Merge pull request #44 from matrober-uk/message-properties
Support for message properties
2 parents 42f4777 + b6f5f71 commit e84ce0e

File tree

9 files changed

+2226
-19
lines changed

9 files changed

+2226
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ your own error handling or logging.
117117
* Send/receive a slice of bytes (BytesMessage) - [bytesmessage_test.go](bytesmessage_test.go)
118118
* Receive with wait [receivewithwait_test.go](receivewithwait_test.go)
119119
* Send a message as Persistent or NonPersistent - [deliverymode_test.go](deliverymode_test.go)
120+
* Set a message property of type string, int, double or boolean - [messageproperties_test.go](messageproperties_test.go)
120121
* Get by CorrelationID - [getbycorrelid_test.go](getbycorrelid_test.go)
121122
* Request/reply messaging pattern - [requestreply_test.go](requestreply_test.go)
122123
* Send and receive under a local transaction - [local_transaction_test.go](local_transaction_test.go)

bytesmessage_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestBytesMessageNilBody(t *testing.T) {
8989
assert.Equal(t, 0, msg2.GetBodyLength())
9090
assert.Equal(t, []byte{}, *msg2.ReadBytes())
9191
default:
92-
assert.Fail(t, "Got something other than a text message")
92+
assert.Fail(t, "Got something other than a bytes message")
9393
}
9494

9595
}
@@ -138,7 +138,7 @@ func TestBytesMessageWithBody(t *testing.T) {
138138
assert.Equal(t, len(msgBody), msg2.GetBodyLength())
139139
assert.Equal(t, msgBody, *msg2.ReadBytes())
140140
default:
141-
assert.Fail(t, "Got something other than a text message")
141+
assert.Fail(t, "Got something other than a bytes message")
142142
}
143143

144144
}
@@ -186,7 +186,7 @@ func TestBytesMessageInitWithBytes(t *testing.T) {
186186
assert.Equal(t, len(msgBody), msg2.GetBodyLength())
187187
assert.Equal(t, msgBody, *msg2.ReadBytes())
188188
default:
189-
assert.Fail(t, "Got something other than a text message")
189+
assert.Fail(t, "Got something other than a bytes message")
190190
}
191191

192192
}
@@ -231,7 +231,7 @@ func TestBytesMessageProducerSendBytes(t *testing.T) {
231231
assert.Equal(t, 13, msg2.GetBodyLength())
232232
assert.Equal(t, msgBody, *msg2.ReadBytes())
233233
default:
234-
assert.Fail(t, "Got something other than a text message")
234+
assert.Fail(t, "Got something other than a bytes message")
235235
}
236236

237237
}

jms20subset/Message.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,46 @@ type Message interface {
4747
// Typical values returned by this method include
4848
// jms20subset.DeliveryMode_PERSISTENT and jms20subset.DeliveryMode_NON_PERSISTENT
4949
GetJMSDeliveryMode() int
50+
51+
// SetStringProperty enables an application to set a string-type message property.
52+
//
53+
// value is *string which allows a nil value to be specified, to unset an individual
54+
// property.
55+
SetStringProperty(name string, value *string) JMSException
56+
57+
// GetStringProperty returns the string value of a named message property.
58+
// Returns nil if the named property is not set.
59+
GetStringProperty(name string) (*string, JMSException)
60+
61+
// SetIntProperty enables an application to set a int-type message property.
62+
SetIntProperty(name string, value int) JMSException
63+
64+
// GetIntProperty returns the int value of a named message property.
65+
// Returns 0 if the named property is not set.
66+
GetIntProperty(name string) (int, JMSException)
67+
68+
// SetDoubleProperty enables an application to set a double-type (float64) message property.
69+
SetDoubleProperty(name string, value float64) JMSException
70+
71+
// GetDoubleProperty returns the double (float64) value of a named message property.
72+
// Returns 0 if the named property is not set.
73+
GetDoubleProperty(name string) (float64, JMSException)
74+
75+
// SetBooleanProperty enables an application to set a bool-type message property.
76+
SetBooleanProperty(name string, value bool) JMSException
77+
78+
// GetBooleanProperty returns the bool value of a named message property.
79+
// Returns false if the named property is not set.
80+
GetBooleanProperty(name string) (bool, JMSException)
81+
82+
// PropertyExists returns true if the named message property exists on this message.
83+
PropertyExists(name string) (bool, JMSException)
84+
85+
// GetPropertyNames returns a slice of strings containing the name of every message
86+
// property on this message.
87+
// Returns a zero length slice if no message properties are set.
88+
GetPropertyNames() ([]string, JMSException)
89+
90+
// ClearProperties removes all message properties from this message.
91+
ClearProperties() JMSException
5092
}

0 commit comments

Comments
 (0)