Skip to content

Commit 41a5cee

Browse files
committed
Adding MQ client to the container
(cherry picked from commit dd7f8b87c2afc9c8ed30fb3d894ccceaad4356d9)
1 parent b2af4bd commit 41a5cee

File tree

6 files changed

+66
-3
lines changed

6 files changed

+66
-3
lines changed

openshift-app-sample/Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
FROM golang:1.15 as builder
22
ENV APP_USER app
33
ENV APP_HOME /go/src/openshift-app-sample
4+
RUN mkdir -p /opt/mqm \
5+
&& chmod a+rx /opt/mqm
6+
# Location of the downloadable MQ client package \
7+
ENV RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
8+
RDTAR="IBM-MQC-Redist-LinuxX64.tar.gz" \
9+
VRMF=9.2.0.1
10+
# Install the MQ client from the Redistributable package. This also contains the
11+
# header files we need to compile against. Setup the subset of the package
12+
# we are going to keep - the genmqpkg.sh script removes unneeded parts
13+
ENV genmqpkg_incnls=1 \
14+
genmqpkg_incsdk=1 \
15+
genmqpkg_inctls=1
16+
RUN cd /opt/mqm \
17+
&& curl -LO "$RDURL/$VRMF-$RDTAR" \
18+
&& tar -zxf ./*.tar.gz \
19+
&& rm -f ./*.tar.gz \
20+
&& bin/genmqpkg.sh -b /opt/mqm
421
RUN groupadd $APP_USER && useradd -m -g $APP_USER -l $APP_USER
522
RUN mkdir -p $APP_HOME && chown -R $APP_USER:$APP_USER $APP_HOME
623
WORKDIR $APP_HOME
@@ -15,5 +32,7 @@
1532
RUN mkdir -p $APP_HOME
1633
WORKDIR $APP_HOME
1734
COPY --chown=0:0 --from=builder $APP_HOME/openshift-app-sample $APP_HOME
35+
COPY --chown=0:0 --from=builder /opt/mqm /opt/mqm
1836
USER $APP_USER
19-
CMD ["./openshift-app-sample"]
37+
CMD ["./openshift-app-sample"]
38+
#CMD ["/bin/bash"]

openshift-app-sample/src/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src
2+

openshift-app-sample/src/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/ibm-messaging/mq-golang-jms20/openshift-app-sample/src
2+
3+
go 1.13
4+
5+
require github.com/ibm-messaging/mq-golang-jms20 v1.2.0

openshift-app-sample/src/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/ibm-messaging/mq-golang-jms20 v1.2.0 h1:pVB4fPpyaEh8fTmyGBH4BlnLINB9f8z9CZdwLY4m4rM=
3+
github.com/ibm-messaging/mq-golang-jms20 v1.2.0/go.mod h1:l6BQdpzorRc27vFbrLSrUJXfP1kyzTXINQX/O2MIiSk=
4+
github.com/ibm-messaging/mq-golang/v5 v5.0.0 h1:9J8bsDoCo60rbSgB7ZAURPG3L5Kpr+F8dYNOwQ7Qnnk=
5+
github.com/ibm-messaging/mq-golang/v5 v5.0.0/go.mod h1:ywCwmYbJOU/E0rl+z4GiNoxVMty68O+LVO39a1VMXrE=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

openshift-app-sample/src/main.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,35 @@
99
// Package main provides the entry point for a executable application.
1010
package main
1111

12-
import "fmt"
12+
import (
13+
"fmt"
14+
"log"
15+
16+
"github.com/ibm-messaging/mq-golang-jms20/mqjms"
17+
)
1318

1419
func main() {
15-
fmt.Println("Hello World!!!")
20+
fmt.Println("Beginning world!!!")
21+
22+
cf := mqjms.ConnectionFactoryImpl{
23+
QMName: "QM1",
24+
Hostname: "myhostname.com",
25+
PortNumber: 1414,
26+
ChannelName: "SYSTEM.DEF.SVRCONN",
27+
UserName: "username",
28+
Password: "password",
29+
}
30+
31+
// Creates a connection to the queue manager, using defer to close it automatically
32+
// at the end of the function (if it was created successfully)
33+
context, errCtx := cf.CreateContext()
34+
if context != nil {
35+
defer context.Close()
36+
}
37+
38+
if errCtx != nil {
39+
log.Fatal(errCtx)
40+
}
41+
42+
fmt.Println("Ending world!!!")
1643
}

openshift-app-sample/src/src

-2.03 MB
Binary file not shown.

0 commit comments

Comments
 (0)