Skip to content

Commit c399759

Browse files
authored
Merge pull request #4 from nikandfor/patch-1
Switch from dep to "go mod" for dependencies, and update code snippet formatting.
2 parents aaf8fcf + fdae819 commit c399759

File tree

5 files changed

+36
-112
lines changed

5 files changed

+36
-112
lines changed

Gopkg.lock

Lines changed: 0 additions & 52 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 38 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in this JMS 2.0 style interface in Golang. Note that there are additional workin
3535
### Send and receive a message containing a text string
3636
(from [sample_sendreceive_test.go](sample_sendreceive_test.go))
3737
Note that for illustration purposes this sample only has limited error handling, which you should never do in production application code! Please see the TestSampleSendReceiveWithErrorHandling function for an equivalent sample that demonstrates good practice for error handling.
38-
```
38+
```golang
3939
// Create a ConnectionFactory using details stored in some external property files
4040
cf, cfErr := mqjms.CreateConnectionFactoryFromDefaultJSONFiles()
4141
if cfErr != nil {
@@ -79,14 +79,14 @@ if rcvBody != nil {
7979

8080
### Send a non-persistent message
8181
(from [deliverymode_test.go](deliverymode_test.go))
82-
```
82+
```golang
8383
msgBody = "My non-persistent message"
8484
err3 := context.CreateProducer().SetDeliveryMode(jms20subset.DeliveryMode_NON_PERSISTENT).SendString(queue, msgBody)
8585
```
8686

8787
### Error handling
8888
(from [sample_errorhandling_test.go](sample_errorhandling_test.go))
89-
```
89+
```golang
9090
// Create a ConnectionFactory using some property files
9191
cf, cfErr := mqjms.CreateConnectionFactoryFromDefaultJSONFiles()
9292
assert.Nil(t, cfErr)
@@ -122,7 +122,7 @@ your own error handling or logging.
122122
* Handle error codes returned by the queue manager - [sample_errorhandling_test.go](sample_errorhandling_test.go)
123123

124124
As normal with Go, you can run any individual testcase by executing a command such as;
125-
```
125+
```bash
126126
go test -run TestSampleSendReceiveWithErrorHandling
127127
```
128128

@@ -134,15 +134,14 @@ The IBM MQ client on which this library depends is supported on Linux and Window
134134

135135
1. Install Golang
136136
- This library has been validated with Golang v1.11.4 and v1.12.9. If you don't have Golang installed on your system you can [download it here](https://golang.org/doc/install) for MacOS, Linux or Windows
137-
2. Install 'dep' to manage the dependent packages
138-
- See [Installation instructions](https://github.com/golang/dep#installation) for details
137+
139138
3. Install the MQ Client library
140139
- If you have a full MQ server with a queue manager installed on your machine then you already have the client library
141140
- If you don't have a queue manager installed on your machine then you can download the "redistributable client" library for IBM MQ 9.1.1 CD or higher for [Linux](https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.1.1.0-IBM-MQC-Redist-LinuxX64.tar.gz), [Windows](https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.1.1.0-IBM-MQC-Redist-Win64.zip) or [MacOS](https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/mactoolkit/IBM-MQ-Toolkit-Mac-x64-9.1.1.0.tar.gz)
142141
- Simply unzip the archive and make a note of the installation location. For ease of configuration you may wish to unzip the archive into the default install IBM MQ location for your platform
143142
- Note that v9.1.1 (CD) or higher of the MQ client library is required as it includes header files that are not present in v9.1.0 LTS or below.
144143
4. Git clone this project to download this JMS style implementation onto your workstation
145-
```
144+
```bash
146145
# Update and set the GOPATH variable to match your workspace
147146
export GOPATH=/home/myuser/workspace
148147

@@ -159,32 +158,25 @@ The IBM MQ client on which this library depends is supported on Linux and Window
159158
### Configuring your environment
160159

161160
First you must configure your command console environment as described in the [mq-golang Getting Started instructions](https://github.com/ibm-messaging/mq-golang#getting-started) so that the necessary flags are set;
162-
```
161+
```bash
163162
# Configure your Go environment variables (update to match your own setup)
164-
export GOROOT=/usr/local/go
165163
export GOPATH=/home/myuser/workspace
166-
export PATH=$PATH:$GOROOT/bin
164+
export PATH=$PATH:$GOPATH/bin
167165

168166
# Set the CGO flags to allow the compilation of the Go/C client interface
169167
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
170168
```
171169

172170

173171
**If your client install is not located in the default installation location**, for example `/opt/mqm` then you also need to set the follow environment variables to point at your installation location. For example on Linux or MacOS;
174-
```
172+
```bash
175173
export MQ_INSTALLATION_PATH=$HOME/9.1.1.0-IBM-MQC-Redist-LinuxX64
176174
export CGO_CFLAGS="-I$MQ_INSTALLATION_PATH/inc"
177175
export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-rpath,$MQ_INSTALLATION_PATH/lib64"
178176
```
179177

180-
Download the Golang modules on which this project depends by running the dep command;
181-
```
182-
cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/
183-
dep ensure
184-
```
185-
186178
Confirm the settings are correct by compiling the MQ JMS Golang package, for example as follows; (no errors will be shown if successful)
187-
```
179+
```bash
188180
cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/mqjms/
189181
go build
190182
```
@@ -203,7 +195,7 @@ The test cases use the `CreateConnectionFactoryFromDefaultJSONFiles` method to o
203195
Once you have added the details of your queue manager and user credentials into the two JSON files and placed them in your `/Downloads` directory you are ready to run the test, which is done in the same way as any other Go tests.
204196

205197
Note that the tests require the queues `DEV.QUEUE.1` and `DEV.QUEUE.2` to be defined on your queue manager, be empty of messages and be accessible to the application username you are using. This will be the case by default for queue managers provisioned through the MQ on Cloud service, but may require manual configuration for queue managers you have created through other means.
206-
```
198+
```bash
207199
> cd $GOPATH/src/github.com/ibm-messaging/mq-golang-jms20/
208200
> go test -v
209201

@@ -218,10 +210,9 @@ ok github.com/ibm-messaging/mq-golang-jms20 11.308s
218210

219211
### Writing your own Golang application that talks to IBM MQ
220212
Writing your own application to talk to IBM MQ is simple - as shown in the [sample_sendreceive_test.go](sample_sendreceive_test.go) sample. Simply import this module into your source file, and get started!
221-
```
213+
```golang
222214
import (
223215
"github.com/ibm-messaging/mq-golang-jms20/mqjms"
224-
225216
)
226217
```
227218

@@ -234,7 +225,7 @@ The first thing you'll need to do is create a ConnectionFactory object so that y
234225
2. Create a new ConnectionFactory object and set the variables in your application code
235226
- This is a quick and easy way to get started, but less desirable for production quality applications
236227
- You can hardcode the values in your source file, or perhaps look them up from environment variables as shown below
237-
```
228+
```golang
238229
cf := mqjms.ConnectionFactoryImpl{
239230
QMName: "QM_ONE",
240231
Hostname: "random.hostname.com",

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/ibm-messaging/mq-golang-jms20
2+
3+
go 1.11
4+
5+
require (
6+
github.com/davecgh/go-spew v1.1.1 // indirect
7+
github.com/ibm-messaging/mq-golang v1.0.1-0.20190820103725-19b946c185a8
8+
github.com/stretchr/testify v1.4.0
9+
)

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/ibm-messaging/mq-golang v1.0.1-0.20190820103725-19b946c185a8 h1:kUwSXeftVen12FRnShG+Ykhb2Kd6Cd/DbpWwbYal7j0=
5+
github.com/ibm-messaging/mq-golang v1.0.1-0.20190820103725-19b946c185a8/go.mod h1:qjsZDb7m1oKnbPeDma2JVJTKgyCA91I4bcJ1qHY+gcA=
6+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9+
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
10+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
11+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
12+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
13+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
14+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)