Skip to content

Commit

Permalink
Restructure IBM MQ client security related example
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshLK committed Feb 26, 2024
1 parent 1b9ec56 commit e63550c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions examples/ibmmq-client-security/.github/README.md
7 changes: 7 additions & 0 deletions examples/ibmmq-client-security/Config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
queueManagerName = "QM1"
host = "localhost"
port = 1414
channel = "DEV.APP.SVRCONN"
userID = "app"
password = "password"
queueName = "DEV.QUEUE.1"
31 changes: 31 additions & 0 deletions examples/ibmmq-client-security/Securing IBM MQ Client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Securing IBM MQ client

This example demonstrates how to initiate secure communication between an IBM MQ client and an IBM MQ server.

## Prerequisites

### 1. Setup IBM MQ server

Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally.

### 2. Configuration

Update IBM MQ related configurations in `Config.toml` in the example directory:

```toml
queueManagerName = "<queue-manager-name>"
host = "<host>"
port = <port>
channel = "<ibm-mq-channel>"
userID = "<user-ID>"
password = "<password>"
queueName = "<queue-name>"
```

## Run the Example

Execute the following command to run the example:

```bash
bal run
```
23 changes: 16 additions & 7 deletions examples/ibmmq-client-security/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@

import ballerinax/ibm.ibmmq;

configurable string queueManagerName = ?;
configurable string host = ?;
configurable int port = ?;
configurable string channel = ?;
configurable string userID = ?;
configurable string password = ?;
configurable string queueName = ?;

public function main() returns error? {
ibmmq:QueueManager queueManager = check new (
name = "QM1",
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
name = queueManagerName,
host = host,
channel = channel,
userID = userID,
password = password,
// Provide the relevant SSL cipher-suite.
sslCipherSuite = ibmmq:TLS12ORHIGHER,
secureSocket = {
Expand All @@ -37,10 +46,10 @@ public function main() returns error? {
}
}
);
ibmmq:Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", ibmmq:MQOO_OUTPUT);
check producer->put({
ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT);
check queue->put({
payload: "This is a sample message to IBM MQ queue".toBytes()
});
check producer->close();
check queue->close();
check queueManager.disconnect();
}

0 comments on commit e63550c

Please sign in to comment.