Skip to content

Commit 6e58c23

Browse files
committed
Add support for ApplName on Connection - #20
1 parent 395940f commit 6e58c23

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

config-samples/connection_info.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"queueManagerName": "QM1",
33
"hostname": "myqm1.myserver.com",
44
"listenerPort": 31234,
5-
"applicationChannelName": "CLOUD.APP.SVRCONN"
5+
"applicationChannelName": "CLOUD.APP.SVRCONN",
6+
"applicationName": "example"
67
}

mqjms/ConnectionFactoryImpl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type ConnectionFactoryImpl struct {
4040

4141
KeyRepository string
4242
CertificateLabel string
43+
44+
// Allthough only available per MQ 9.1.2 it looks like a good idea to have this present in MQ-JMS
45+
ApplName string
4346
}
4447

4548
// CreateContext implements the JMS method to create a connection to an IBM MQ
@@ -94,6 +97,9 @@ func (cf ConnectionFactoryImpl) CreateContextWithSessionMode(sessionMode int) (j
9497

9598
}
9699

100+
// Fill in the optional (possible since MQ 9.1.2) application name
101+
cno.ApplName = cf.ApplName
102+
97103
} else if cf.TransportType == TransportType_BINDINGS {
98104

99105
// Indicate to use Bindings connections.

mqjms/FactoryFactory.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
//
2424
// This method reads the following files;
2525
// - $HOME/Downloads/connection_info.json for host/port/channel information
26-
// - $HOME/Downloads/applicationApiKey.json for username/password information
26+
// - $HOME/Downloads/apiKey.json for username/password information
2727
//
2828
// If your queue manager is hosted on the IBM MQ on Cloud service then you can
2929
// download these two files directly from the IBM Cloud service console.
@@ -42,7 +42,7 @@ func CreateConnectionFactoryFromDefaultJSONFiles() (cf ConnectionFactoryImpl, er
4242
// the file as the two parameters. If empty string is provided then the default
4343
// location and name is assumed as follows;
4444
// - $HOME/Downloads/connection_info.json for host/port/channel information
45-
// - $HOME/Downloads/applicationApiKey.json for username/password information
45+
// - $HOME/Downloads/apiKey.json for username/password information
4646
//
4747
// If your queue manager is hosted on the IBM MQ on Cloud service then you can
4848
// download these two files directly from the IBM Cloud service console.
@@ -87,7 +87,7 @@ func CreateConnectionFactoryFromJSON(connectionInfoLocn string, apiKeyLocn strin
8787
return ConnectionFactoryImpl{}, err
8888
}
8989

90-
var qmName, hostname, appChannel string
90+
var qmName, hostname, appChannel, appName string
9191
var port int
9292

9393
qmName, errQM := parseStringValueFromJSON("queueManagerName", connInfoMap, connectionInfoLocn)
@@ -110,6 +110,11 @@ func CreateConnectionFactoryFromJSON(connectionInfoLocn string, apiKeyLocn strin
110110
return ConnectionFactoryImpl{}, errChannel
111111
}
112112

113+
appName, errAppName := parseStringValueFromJSON("applicationName", connInfoMap, connectionInfoLocn)
114+
if errAppName != nil {
115+
return ConnectionFactoryImpl{}, errAppName
116+
}
117+
113118
// Now unmarshall and parse out the values from the api key file (that
114119
// contains the username/password credentials).
115120
var apiKeyMap map[string]*json.RawMessage
@@ -140,6 +145,7 @@ func CreateConnectionFactoryFromJSON(connectionInfoLocn string, apiKeyLocn strin
140145
ChannelName: appChannel,
141146
UserName: username,
142147
Password: password,
148+
ApplName: appName,
143149
}
144150

145151
// Give the populated ConnectionFactory back to the caller.

0 commit comments

Comments
 (0)