Skip to content

Commit 99bfb37

Browse files
authored
Merge pull request #12 from ibm-messaging/local-transactions
Support for local transactions
2 parents 7d79ce1 + e10ab25 commit 99bfb37

23 files changed

+498
-253
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ your own error handling or logging.
118118
* Send a message as Persistent or NonPersistent - [deliverymode_test.go](deliverymode_test.go)
119119
* Get by CorrelationID - [getbycorrelid_test.go](getbycorrelid_test.go)
120120
* Request/reply messaging pattern - [requestreply_test.go](requestreply_test.go)
121+
* Send and receive under a local transaction - [local_transaction_test.go](local_transaction_test.go)
121122
* Sending a message that expires after a period of time - [timetolive_test.go](timetolive_test.go)
122123
* Handle error codes returned by the queue manager - [sample_errorhandling_test.go](sample_errorhandling_test.go)
123124

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/ibm-messaging/mq-golang v1.0.1-0.20190820103725-19b946c185a8 h1:kUwSXeftVen12FRnShG+Ykhb2Kd6Cd/DbpWwbYal7j0=
44
github.com/ibm-messaging/mq-golang v1.0.1-0.20190820103725-19b946c185a8/go.mod h1:qjsZDb7m1oKnbPeDma2JVJTKgyCA91I4bcJ1qHY+gcA=
5+
github.com/ibm-messaging/mq-golang v3.0.0+incompatible h1:Yc3c8emAyveT54uNDRMkgvS+EBAHeLNWHkc3hk5x+IY=
56
github.com/ibm-messaging/mq-golang/v5 v5.0.0 h1:9J8bsDoCo60rbSgB7ZAURPG3L5Kpr+F8dYNOwQ7Qnnk=
67
github.com/ibm-messaging/mq-golang/v5 v5.0.0/go.mod h1:ywCwmYbJOU/E0rl+z4GiNoxVMty68O+LVO39a1VMXrE=
78
github.com/ibm-messaging/mq-golang/v5 v5.1.2 h1:u0e1Vce2TNqJpH088vF77rDMsnMRWnGaOIlxZo4DMZc=
89
github.com/ibm-messaging/mq-golang/v5 v5.1.2/go.mod h1:ywCwmYbJOU/E0rl+z4GiNoxVMty68O+LVO39a1VMXrE=
910
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1011
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12+
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
1113
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1214
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
1315
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=

jms20subset/ConnectionFactory.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
// Interfaces for messaging applications in the style of the Java Message Service (JMS) API.
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// ConnectionFactory defines a Golang interface which provides similar
@@ -18,5 +18,12 @@ type ConnectionFactory interface {
1818

1919
// CreateContext creates a connection to the messaging provider using the
2020
// configuration parameters that are encapsulated by this ConnectionFactory.
21+
//
22+
// Defaults to sessionMode of JMSContextAUTOACKNOWLEDGE
2123
CreateContext() (JMSContext, JMSException)
24+
25+
// CreateContextWithSessionMode creates a connection to the messaging provider using the
26+
// configuration parameters that are encapsulated by this ConnectionFactory,
27+
// and the specified session mode.
28+
CreateContextWithSessionMode(sessionMode int) (JMSContext, JMSException)
2229
}

jms20subset/DeliveryMode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// Go doesn't allow constants in structs so the naming of this file is only for
1414
// logical grouping purposes. The constants are package scoped, but we use a
1515
// prefix to the naming in order to maintain similarity with Java JMS.
1616

17-
// Used to configure messages to be sent Persistently.
17+
// DeliveryMode_PERSISTENT is used to configure messages to be sent Persistently.
1818
const DeliveryMode_PERSISTENT int = 2
1919

20-
// Used to configure messages to be sent Non-Persistently.
20+
// DeliveryMode_NON_PERSISTENT is Used to configure messages to be sent Non-Persistently.
2121
const DeliveryMode_NON_PERSISTENT int = 1

jms20subset/Destination.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// Destination encapsulates a provider-specific address, which is typically

jms20subset/JMSConsumer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// JMSConsumer provides the ability for an application to receive messages

jms20subset/JMSContext.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

13+
// JMSContextAUTOACKNOWLEDGE is used to specify a sessionMode that automatically acknowledge message transmission.
14+
const JMSContextAUTOACKNOWLEDGE int = 1
15+
16+
// JMSContextSESSIONTRANSACTED is used to specify a sessionMode that requires manual commit/rollback of transactions.
17+
const JMSContextSESSIONTRANSACTED int = 0
18+
1319
// JMSContext represents a connection to the messaging provider, and
1420
// provides the capability for applications to create Producer and Consumer
1521
// objects so that it can send and receive messages.
@@ -54,6 +60,12 @@ type JMSContext interface {
5460
// name and different parameters we must use a different function name.
5561
CreateTextMessageWithString(txt string) TextMessage
5662

63+
// Commit confirms all messages sent/received during this transaction.
64+
Commit()
65+
66+
// Rollback releases all messages sent/received during this transaction.
67+
Rollback()
68+
5769
// Closes the connection to the messaging provider.
5870
//
5971
// Since the provider typically allocates significant resources on behalf of

jms20subset/JMSException.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// JMSException represents an interface for returning details of a

jms20subset/JMSProducer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// JMSProducer is a simple object used to send messages on behalf of a

jms20subset/Message.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// SPDX-License-Identifier: EPL-2.0
99

10-
//
10+
// Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.
1111
package jms20subset
1212

1313
// Message is the root interface of all JMS Messages. It defines the

0 commit comments

Comments
 (0)