You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
39
39
// Create a ConnectionFactory using details stored in some external property files
@@ -122,7 +122,7 @@ your own error handling or logging.
122
122
* Handle error codes returned by the queue manager - [sample_errorhandling_test.go](sample_errorhandling_test.go)
123
123
124
124
As normal with Go, you can run any individual testcase by executing a command such as;
125
-
```
125
+
```bash
126
126
go test -run TestSampleSendReceiveWithErrorHandling
127
127
```
128
128
@@ -134,15 +134,14 @@ The IBM MQ client on which this library depends is supported on Linux and Window
134
134
135
135
1. Install Golang
136
136
- 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
+
139
138
3. Install the MQ Client library
140
139
- If you have a full MQ server with a queue manager installed on your machine then you already have the client library
141
140
- 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)
142
141
- 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
143
142
- 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.
144
143
4. Git clone this project to download this JMS style implementation onto your workstation
145
-
```
144
+
```bash
146
145
# Update and set the GOPATH variable to match your workspace
147
146
export GOPATH=/home/myuser/workspace
148
147
@@ -159,32 +158,25 @@ The IBM MQ client on which this library depends is supported on Linux and Window
159
158
### Configuring your environment
160
159
161
160
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
163
162
# Configure your Go environment variables (update to match your own setup)
164
-
export GOROOT=/usr/local/go
165
163
export GOPATH=/home/myuser/workspace
166
-
export PATH=$PATH:$GOROOT/bin
164
+
export PATH=$PATH:$GOPATH/bin
167
165
168
166
# Set the CGO flags to allow the compilation of the Go/C client interface
169
167
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
170
168
```
171
169
172
170
173
171
**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;
@@ -203,7 +195,7 @@ The test cases use the `CreateConnectionFactoryFromDefaultJSONFiles` method to o
203
195
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.
204
196
205
197
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.
@@ -218,10 +210,9 @@ ok github.com/ibm-messaging/mq-golang-jms20 11.308s
218
210
219
211
### Writing your own Golang application that talks to IBM MQ
220
212
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
222
214
import (
223
215
"github.com/ibm-messaging/mq-golang-jms20/mqjms"
224
-
225
216
)
226
217
```
227
218
@@ -234,7 +225,7 @@ The first thing you'll need to do is create a ConnectionFactory object so that y
234
225
2. Create a new ConnectionFactory object and set the variables in your application code
235
226
- This is a quick and easy way to get started, but less desirable for production quality applications
236
227
- You can hardcode the values in your source file, or perhaps look them up from environment variables as shown below
0 commit comments