WORKING WITH SOAP\HTTP NODE IN BROKER

==SOAP NODE VS HTTP NODE==

First, you need to separate between 2 nodes:
1. SOAP Input
2. HTTP Input

1. HTTPInput and HTTPReply nodes use the broker-wide HTTP listener

This command:

mqsireportproperties <<NAME OF INTEGRATION NODE>> -b httplistener -o HTTPConnector -a

1.1. As default, this port is broker-wide HTTP listener

(you can change it with the httpNodesUseEmbeddedListener command)
1.2. The port you get is the port which the HTTP nodes listen to

2. SOAPInput, SOAPReply, and SOAPAsyncResponse nodes use the embedded HTTP listener

However, this command:

mqsireportproperties <<NAME OF INTEGRATION NODE>> -e default -o HTTPConnector -a

2.1. This port is different per EG
2.2. The port you get is the port which the SOAP nodes in the current EG (default) listen to

(you can change it with the soapNodesUseEmbeddedListener command)

==HTTP LISTENING IN BROKER==
The broker starts listening just when there is a deployment flow with HTTP/SOAP nodes on runtime

==HOW TO GET PORT LIST==
1. As you added, you can get the ports details by this command and by the Broker Explorer, right click on the instance

Export Ports configuration (which use Broker Java API)

This command using the r flag:

2. You can use this command which gives you the list of all the relevant ports in the Broker (same details as Export Ports give)

 mqsireportproperties <<NAME OF INTEGRATION NODE>> -e default -o HTTPConnector -r

If you got to cahnge the port – you do it like this one

==HOT TO CHANGE THE PORT VALUE==

mqsichangeproperties <<NAME OF INTEGRATION NODE>> -e default -o HTTPConnector -n explicitlySetPortNumber -v NEW_PORT

For more information on IBM info center:

HTTP listeners:

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/bc43700_.htm?cp=SSKM8N_8.0.0%2F1-9-7-1-3-0-0

Execution group HTTP listener parameters (SOAP and HTTP nodes)

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/an09148_.htm?lang=en

STANDARD SYSTEM LOGS

The broker writes information, warning, and error messages to standard output (STDOUT) and standard error (STDERR). The broker records this information for the execution group and for the broker admin agent (bipbroker process).

On some operating systems, the two standard logs are written to separate files, but the system might provide an option for the data to be recorded to a single merged file. On other systems, the two targets are defined to a single, and you might have the option to separate them. Check the documentation that is provided with your operating system for more details about STDOUT and STDERR.

Brokers write records to both STDOUT and STDERR. Always check the contents of the file or files when an error occurs.

Because the records are written whenever components are active, check occasionally that the location of the file or files has sufficient space, or trim the file contents on a regular basis.

The default location of STDOUT and STDERR depends on the operating system:
Location of STDOUT and STDERR for broker admin agent:
/var/mqsi/components/broker_name
Location of STDOUT and STDERR for execution group:
/var/mqsi/components/broker_name/execution_group_uuid

LINUX & UNIX SYSTEMS: CONFIGURING THE SYSLOG DAEMON

WebSphere Message Broker processes call the syslog commands on the operating system but only those messages that correspond to the filter defined for the output destination are displayed. WebSphere Message Broker messages have:

  • A facility of user.
  • A level of err, warn, or info, depending on the severity of the situation causing the message to be issued.

To record all WebSphere Message Broker messages, create a filter on the user facility for messages of level info or greater. It is good practice to write these messages to a separate file; there might be a high number of them and they are more likely to be of interest to broker administrators rather than to system administrators.

The following line in a syslog.conf file causes all WebSphere Message Broker events to be written to a file/var/log/user.log

user.info /var/log/user.log

MultiHopping with 3 Managers

Requirement: To set up a minimal steps for a Two Way MQ communication between two queue managers ie From A to B & From B to C

Passing the messages between more than one intermediate queue managers is called Multi-Hopping. Multi-hopping occurs when a message needs to traverse one or more queue-managers in order to reach the destination queue-manager.

The Setup in which a QMGR is networked with the next QMGR which is networked to the next QMGR ie  (QMA -> QMB -> QMC -> QMD -> QME).

If a message is created on QMA, and the destination queue-manager is on QME, then the message must flow from QMB to QMC, to QMD to QME.

QMB and QMC will need a queue-manager aliases since they are non-adjacent (don’t have a transmission queue) to the destination queue-manager.

QMB needs a definition to move the message from QMB to the next hop QMC. and so on

So, when the message arrives on QMB, a queue-manager alias must exist to resolve the queue-manager name in the XQH (transmission queue header):
DEF QR(QME) RQMname(QME) XMITQ(QMC).

This definition tells the MCA (message channel agent) on QMB to move the message to transmission queue named QMC, so that the message will be sent to QMC.

When the message arrives on QMC, again a queue-manager alias will be need to be defined  to move the message to a transmission queue named QMD:
DEF QR(QME) RQMname(QME) XMITQ(QMD).

So QMA doesn’t know any thing about QME so by defining the QM alias the message is reached to the destination QME.

The only thing and the only route that QMA knows is how to get to QMB. Everything else is resolved at QMB. So as long as QMB is secured, then no application can send messages to QMC without going through QMB.

Quick Reference Commands for Multi Hopping with 3 QMGRS

On Queue Manager A :

crtmqm A
strmqm A
runmqsc A
DEFINE QLOCAL(A.TQ) USAGE(XMITQ)
DEFINE CHANNEL(A.B) CHLTYPE(SDR) CONNAME(‘192.20.20.21(6001)’) XMITQ(A.TQ)
DEFINE QREMOTE(C.RQ) RNAME(C.LQ) RQMNAME(C) XMITQ(A.TQ)
START CHANNEL(A.B)
DISPLAY CHSTATUS(*)

On Queue Manager B :

crtmqm B
strmqm B
runmqsc B
DEFINE CHANNEL(A.B) CHLTYPE(RCVR)
DEFINE QLOCAL(B.TQ) USAGE(XMITQ)
DEFINE LISTENER(B.LSTR) TRPTYPE(TCP) PORT(6001) IPADDR(192.20.20.21)
START LISTENER(B.LSTR)
DEFINE CHANNEL(B.C) CHLTYPE (SDR) TRPTYPE(TCP) CONNAME(‘192.20.20.21(6002)’) XMITQ(B.TQ)

— Qmgr Alias needs to be set in the QMB

DEFINE QREMOTE(C) RQMNAME(C) RNAME(”) XMITQ(B.TQ)
START CHANNEL(A.B)
START CHANNEL(B.C)
DISPLAY CHSTATUS()
DISPLAY LSSTATUS(
)

On Queue Manager C :

crtmqm C
strmqm C
runmqsc C
DEFINE LISTENER(C.LSTR) TRPTYPE(TCP) PORT(6002) IPADDR(192.20.20.21)
DEFINE CHANNEL(B.C) CHLTYPE(RCVR) TRPTYPE(TCP)
START LISTENER(C.LSTR)
DEFINE QLOCAL(C.LQ)
START CHANNEL(B.C)
DISPLAY CHSTATUS()
DISPLAY LSSTATUS(
)

Testing of MultiHopping :

In Windows Env :

C:\Program Files>cd IBM

C:\Program Files\IBM>cd “WebSphere MQ_1”

C:\Program Files\IBM\WebSphere MQ_1>cd bin

C:\Program Files\IBM\WebSphere MQ_1\bin>amqsput C.RQ A
Sample AMQSPUT0 start
target queue is C.RQ
test message1

Sample AMQSPUT0 end

C:\Program Files\IBM\WebSphere MQ_1\bin>amqsget C.LQ C
Sample AMQSGET0 start
message <test message1>
no more messages
Sample AMQSGET0 end

In Linux Env :

bash-3.2$ pwd
/opt/mqm/samp/bin
bash-3.2$ ./amqsput C.RQ A
Sample AMQSPUT0 start
target queue is C.RQ
This is a test
Sample AMQSPUT0 end
bash-3.2$ ./amqsbcg C.LQ C

 

————-RUNTIME OUTPUT————-

———————On Queue Manager A———————
C:\Program Files\IBM\IIB\10.0.0.6>crtmqm A
WebSphere MQ queue manager created.
Directory ‘C:\ProgramData\IBM\MQ\qmgrs\A’ created.
The queue manager is associated with installation ‘Installation1’.
Creating or replacing default objects for queue manager ‘A’.
Default objects statistics : 82 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.

C:\Program Files\IBM\IIB\10.0.0.6>strmqm A
WebSphere MQ queue manager ‘A’ starting.
The queue manager is associated with installation ‘Installation1’.
5 log records accessed on queue manager ‘A’ during the log replay phase.
Log replay for queue manager ‘A’ complete.
0 log records accessed on queue manager ‘A’ during the recovery phase.
Transaction manager state recovered for queue manager ‘A’.
WebSphere MQ queue manager ‘A’ started using V8.0.0.4.

C:\Program Files\IBM\IIB\10.0.0.6>

C:\Program Files\IBM\IIB\10.0.0.6>runmqsc A
5724-H72 (C) Copyright IBM Corp. 1994, 2015.
Starting MQSC for queue manager A.

DEFINE QLOCAL(A.TQ) USAGE(XMITQ)
1 : DEFINE QLOCAL(A.TQ) USAGE(XMITQ)
AMQ8006: WebSphere MQ queue created.
DEFINE CHANNEL(A.B) CHLTYPE(SDR) CONNAME(‘127.0.0.1(6001)’) XMITQ(A.TQ)
2 : DEFINE CHANNEL(A.B) CHLTYPE(SDR) CONNAME(‘127.0.0.1(6001)’) XMITQ(A.TQ)

AMQ8014: WebSphere MQ channel created.

:
DEFINE QREMOTE(C.RQ) RNAME(C.LQ) RQMNAME(C) XMITQ(A.TQ)
3 : DEFINE QREMOTE(C.RQ) RNAME(C.LQ) RQMNAME(C) XMITQ(A.TQ)
AMQ8006: WebSphere MQ queue created.

:
START CHANNEL(A.B)
4 : START CHANNEL(A.B)
AMQ8018: Start WebSphere MQ channel accepted.

:
DISPLAY CHSTATUS()
5 : DISPLAY CHSTATUS(
)
AMQ8417: Display Channel Status details.
CHANNEL(A.B) CHLTYPE(SDR)
CONNAME(127.0.0.1(6001)) CURRENT
RQMNAME( ) STATUS(RETRYING)
SUBSTATE( ) XMITQ(A.TQ)

——————On Queue Manager B—————————–

C:\Program Files\IBM\IIB\10.0.0.6>strmqm B
WebSphere MQ queue manager ‘B’ starting.
The queue manager is associated with installation ‘Installation1’.
5 log records accessed on queue manager ‘B’ during the log replay phase.
Log replay for queue manager ‘B’ complete.
Transaction manager state recovered for queue manager ‘B’.
WebSphere MQ queue manager ‘B’ started using V8.0.0.4.

C:\Program Files\IBM\IIB\10.0.0.6>runmqsc B
5724-H72 (C) Copyright IBM Corp. 1994, 2015.
Starting MQSC for queue manager B.

DEFINE CHANNEL(A.B) CHLTYPE(RCVR)
1 : DEFINE CHANNEL(A.B) CHLTYPE(RCVR)
AMQ8014: WebSphere MQ channel created.
DEFINE QLOCAL(B.TQ) USAGE(XMITQ)
2 : DEFINE QLOCAL(B.TQ) USAGE(XMITQ)
AMQ8006: WebSphere MQ queue created.

DEFINE LISTENER(B.LSTR) TRPTYPE(TCP) PORT(6001) IPADDR(127.0.0.1)
20 : DEFINE LISTENER(B.LSTR) TRPTYPE(TCP) PORT(6001) IPADDR(127.0.0.1)
AMQ8626: WebSphere MQ listener created.

START LISTENER(B.LSTR)
22 : START LISTENER(B.LSTR)
AMQ8021: Request to start WebSphere MQ listener accepted.

:
DEFINE CHANNEL(B.C) CHLTYPE (SDR) TRPTYPE(TCP) CONNAME(‘127.0.0.1(6002)’) XMITQ(B.TQ)
23 : DEFINE CHANNEL(B.C) CHLTYPE (SDR) TRPTYPE(TCP) CONNAME(‘127.0.0.1(6002)’) XMITQ(B.TQ)
AMQ8014: WebSphere MQ channel created.


DEFINE QREMOTE(C) RQMNAME(C) RNAME(”) XMITQ(B.TQ)
1 : DEFINE QREMOTE(C) RQMNAME(C) RNAME(”) XMITQ(B.TQ)
AMQ8006: WebSphere MQ queue created.

:
START CHANNEL(A.B)
2 : START CHANNEL(A.B)
AMQ9514: Channel ‘A.B’ is in use.

:
START CHANNEL(B.C)
3 : START CHANNEL(B.C)
AMQ8018: Start WebSphere MQ channel accepted.

:
DISPLAY CHSTATUS()
4 : DISPLAY CHSTATUS(
)
AMQ8417: Display Channel Status details.
CHANNEL(A.B) CHLTYPE(RCVR)
CONNAME(127.0.0.1) CURRENT
RQMNAME(A) STATUS(RUNNING)
SUBSTATE(RECEIVE)
AMQ8417: Display Channel Status details.
CHANNEL(B.C) CHLTYPE(SDR)
CONNAME(127.0.0.1(6002)) CURRENT
RQMNAME( ) STATUS(RETRYING)
SUBSTATE( ) XMITQ(B.TQ)

:
DISPLAY LSSTATUS()
5 : DISPLAY LSSTATUS(
)
AMQ8631: Display listener status details.
LISTENER(B.LSTR) STATUS(RUNNING)
PID(2356)

——————On Queue Manager C————————

C:\Program Files\IBM\IIB\10.0.0.6>crtmqm C
WebSphere MQ queue manager created.
Directory ‘C:\ProgramData\IBM\MQ\qmgrs\C’ created.
The queue manager is associated with installation ‘Installation1’.
Creating or replacing default objects for queue manager ‘C’.
Default objects statistics : 82 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.

C:\Program Files\IBM\IIB\10.0.0.6>strmqm C
WebSphere MQ queue manager ‘C’ starting.
The queue manager is associated with installation ‘Installation1’.
5 log records accessed on queue manager ‘C’ during the log replay phase.
Log replay for queue manager ‘C’ complete.
Transaction manager state recovered for queue manager ‘C’.
WebSphere MQ queue manager ‘C’ started using V8.0.0.4.

C:\Program Files\IBM\IIB\10.0.0.6>runmqsc C
5724-H72 (C) Copyright IBM Corp. 1994, 2015.
Starting MQSC for queue manager C.

DEFINE LISTENER(C.LSTR) TRPTYPE(TCP) PORT(6002) IPADDR(127.0.0.1)
1 : DEFINE LISTENER(C.LSTR) TRPTYPE(TCP) PORT(6002) IPADDR(127.0.0.1)
AMQ8626: WebSphere MQ listener created.

:
DEFINE CHANNEL(B.C) CHLTYPE(RCVR) TRPTYPE(TCP)
2 : DEFINE CHANNEL(B.C) CHLTYPE(RCVR) TRPTYPE(TCP)
AMQ8014: WebSphere MQ channel created.

:
START LISTENER(C.LSTR)
3 : START LISTENER(C.LSTR)
AMQ8021: Request to start WebSphere MQ listener accepted.

:
DEFINE QLOCAL(C.LQ)
4 : DEFINE QLOCAL(C.LQ)
AMQ8006: WebSphere MQ queue created.

:
START CHANNEL(B.C)
5 : START CHANNEL(B.C)
AMQ8018: Start WebSphere MQ channel accepted.

:
DISPLAY CHSTATUS()
6 : DISPLAY CHSTATUS(
)
AMQ8420: Channel Status not found.

:
DISPLAY LSSTATUS()
7 : DISPLAY LSSTATUS(
)
AMQ8631: Display listener status details.
LISTENER(C.LSTR) STATUS(RUNNING)
PID(18356)

:
DISPLAY CHSTATUS()
8 : DISPLAY CHSTATUS(
)
AMQ8417: Display Channel Status details.
CHANNEL(B.C) CHLTYPE(RCVR)
CONNAME(127.0.0.1) CURRENT
RQMNAME(B) STATUS(RUNNING)
SUBSTATE(RECEIVE)
Testing of MultiHopping :

C:\Program Files>cd IBM

C:\Program Files\IBM>cd “WebSphere MQ_1”

C:\Program Files\IBM\WebSphere MQ_1>cd bin

C:\Program Files\IBM\WebSphere MQ_1\bin>amqsput C.RQ A
Sample AMQSPUT0 start
target queue is C.RQ
test message1

Sample AMQSPUT0 end

C:\Program Files\IBM\WebSphere MQ_1\bin>amqsbcg C.LQ C

AMQSBCG0 – starts here


MQOPEN – ‘C.LQ’

 

MQGET of message number 1, CompCode:0 Reason:0
****Message descriptor****

StrucId : ‘MD ‘ Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 546 CodedCharSetId : 437
Format : ‘MQSTR ‘
Priority : 0 Persistence : 0
MsgId : X’414D512041202020202020202020202011E4465B20003103′
CorrelId : X’000000000000000000000000000000000000000000000000’
BackoutCount : 0
ReplyToQ : ‘ ‘
ReplyToQMgr : ‘A ‘
** Identity Context
UserIdentifier : ‘30260 ‘
AccountingToken :
X’1601051500000052AAC868F89FB474235F636B4910060000000000000000000B’
ApplIdentityData : ‘ ‘
** Origin Context
PutApplType : ’11’
PutApplName : ‘PHERE MQ_1\bin64\amqsput.exe’
PutDate : ‘20180712’ PutTime : ‘05422558’
ApplOriginData : ‘ ‘

GroupId : X’000000000000000000000000000000000000000000000000’
MsgSeqNumber : ‘1’
Offset : ‘0’
MsgFlags : ‘0’
OriginalLength : ‘-1’

**** Message ****

length – 13 of 13 bytes

00000000: 7465 7374 206D 6573 7361 6765 31 ‘test message1 ‘

No more messages
MQCLOSE
MQDISC
C:\Program Files\IBM\WebSphere MQ_1\bin>

SSL configuration

What this exercise is about
This article shows you how to set up SSL communication in WebSphere Message Broker on Windows System. It also includes an example of testing the SSL using a flow.
In the first part of the exercise you will go through steps involved in configuring SSL
In the second part of the exercise you will go through How to Configure Message Broker to serve HTTP/HTTPS requests
In the third part of the exercise you will go through How to Set up ports exclusively for execution groups
In the fourth part of the exercise you will go through How to Set up JVM attributes for execution groups
In the fifth part of the exercise you will go through Testing SSL with MB.
What you should be able to do
At the end of the exercise you will be able to :
  • Generate a .jks keystore.
  • Generate a certificate signing request (CSR) for the existing keystore.
  • Import a root or intermediate Certificate Authority (CA) certificate to the existing keystore of extension “.crt”.
  • Import a signed certificate of extension “.cer”to the existing keystore.
  • Validate the certificate details.
  • Testing the SSL
Introduction
     Java Keytool is a key and certificate management utility which allows users to manage their own public/private key pairs and certificates. It also allows users to cache certificates. Java Keytool stores the keys and certificates in what is called a keystore. By default the Java keystore is implemented as a file. It protects private keys with a password. A Keytool keystore contains the private key and any certificates necessary to complete a chain of trust and establish the trustworthiness of the primary certificate.
    Each certificate in a Java keystore is associated with a unique alias. When creating a Java keystore you will first create the .jks file that will initially only contain the private key. You will then generate a CSR and have a certificate generated from it. Then you will import the certificate to the keystore including any root certificates. Java Keytool also several other functions that allow you to view the details of a certificate or list the certificates contained in a keystore or export a certificate.
Part 1: Steps for Configuring SSL
Step 1:- Generate a Java keystore and key pair
keytool -genkey -alias mydomain -keyalg RSA -keystore keystore.jks -keysize 2048
Inorder to issue this command,open IBM Command console & change the path as per your requirement
where
<Keytool> is a key & certificate management utilityu tool
<genkey> Generate a pair of keys ( Private key and Public key)
<alias> is the alias name used for the private key for security.
<keyalg> identifies the algorithm we used
<keystore> identifies the keystore.
<keysize> specifies the size in bits format.
2048 is the bit structure used.It also depends on the OS used.
On issuing this command it prompts for Keystore password.Then it asks for some more security questions.This command generates a keystore.jks file in the specified path.
Step 2:- Generate a certificate signing request (CSR) for an existing Java keystore
keytool -certreq -alias mydomain -keystore keystore.jks -file mydomain .csr
After entering the password,if no errors were found within the command,it moves to path without showing any message ,otherwise it displays error message like “keyttool error”
where
<certreq> Location where csr file is stored.Used to generate a certificate request to send to the certificate authority
<alias> is the alias used for the key. By default set to “mykey”.
<keystore> using the -genkey command to generate a key pair (public and private key)
<file> indicates the file name with path.
Step 3:- Import a root or intermediate CA certificate to the existing keystore
Here we have to send the .csr file to the Certificate Authority team to get the certificates generated.For this visit www.verisign.com & get free trials.Then it asks for some personal details like our email id & server name.Then we have to upload our csr file.The generated crt file will then be sent to our email id.
After receiving the signed certificate from the CA, save it in notepad with extension.crt & proceed with the following steps:
keytool -import -trustcacerts -alias root -file Cert.crt -keystore MBV7Broker.jks
where
<keystore> file name is MBV7Broker.jks and the intermediate CA cert is Cert.crt.This file can be generated by using third party CA’s like GlobalSign and VeriSign.
<trustcacerts> used to provide additional certificates for the chain of trust, namely the certificates
<file> indicates the file name with path.
<keystore> using the -genkey command to generate a key pair (public and private key)
<printcert> Reads the certificate from the file cert_file, and prints its contents in a human-readable format.
Step 4:-Import a signed primary certificate to an existing Java keystore
keytool -import -trustcacerts -alias MBV7Broker -file certificate.der -keystore MBV7Broker.jks
where
<trustcacerts> used to provide additional certificates for the chain of trust, namely the certificates
Step 5:- Validate the certificate details
To List all certificates available in the keystore
keytool -list -keystore miracle.jks
Part 2 :- Configuring Message Broker to serve HTTP/HTTPS requests
  1. To List the broker registry
mqsireportproperties MBV7Broker -o BrokerRegistry -r
where
o – objects
r – includes listing of child elements also if present.
  1. Import root certificates and server certificates to the broker truststore
keytool -import -trustcacerts –alias Certificate.Cert -file “C:\IBM\MQSI\7.0\Cert.crt”
-keypass <password> -keystore cacerts –storepass changeit
3. Enable SSL on the broker instance

This command enables SSL for the HTTP listener object:

mqsichangeproperties MBV7Broker -b httplistener -o HTTPListener -n enableSSLConnector -v true
  1. Modify broker properties to point to the keystore file
mqsichangeproperties MBV7Broker -b httplistener -o HTTPSConnector -n keystoreFile -v “C:\IB\MQSI\7.0\ MBV7Broker.jks”
  1. Add broker keystore file to broker registry
mqsichangeproperties MBV7Broker -o BrokerRegistry -n brokerKeystoreFile
-v “C:\IBM\MQSI\7.0\ MBV7Broker.jks”
6. Add broker truststore file to broker registry
mqsichangeproperties MBV7Broker -o BrokerRegistry -n brokerTruststoreFile -v “C:\IBM\MQSI\7.0\jre16\lib\security\cacerts”
7. Set the registry password for keystore
mqsisetdbparms MBV7Broker -n brokerTruststore::password -u temp -p changeit
8. Associate the broker with keystore password
mqsichangeproperties MBV7Broker -b httplistener -o HTTPSConnector -n keystorePass -v <password>
9. Associate a port for broker to serve HTTPS requests
mqsichangeproperties MBV7Broker -b httplistener -o HTTPSConnector -n port -v 7094
10. Associate a port for broker to serve HTTP requests
mqsichangeproperties MBV7Broker -b httplistener -o HTTPConnector -n port -v 7091
11. Change the JVM attributes

You can change JVM heap sizes according to your requirements by modifying the object ComIbmJVMManager:

mqsichangeproperties MBV7Broker -o ComIbmJVMManager -n jvmMaxHeapSize -v 1048576000

mqsichangeproperties MBV7Broker -o ComIbmJVMManager -n jvmMinHeapSize -v 134217728
12. Verify the broker properties
mqsireportproperties MBV7Broker -b httplistener -o HTTPConnector -n port 7091
mqsireportproperties MBV7Broker -b httplistener -o HTTPSConnector -n port 7094
  1. Restart the broker
 mqsistop MBV7Broker
 mqsistart MBV7Broker
 mqsistop MBV7Broker
 mqsistart MBV7Broker
Part 3:- Setting up ports exclusively for execution groups

To serve the HTTP requests, a port needs to be configured at the execution group (EG) level.

1. Configure the SSL protocol
First tell the EG which SSL protocol type are using. SSLv3 is the default SSL protocol.

mqsichangeproperties MBV7Broker -e <EG Name> -o HTTPSConnector -n sslProtocol -v SSLv3
2. Associate the keystore file with the broker EG

The keystore file created earlier needs to be associated with the broker instance in order for it to know its repository file. To avoid confusion, do not have multiple keystore files on the server.

mqsichangeproperties MBV7Broker -e default -o HTTPSConnector 
    -n keystoreFile -v “C:\IBM\MQSI\7.0\MBV7Broker .jks”
3. Associate the keystore type.

You should configure the keystore type on the broker, because there are several other keystore types supported by broker. Information on these types is outside the scope of this article, which uses a Java Keystore (JKS).

mqsichangeproperties MBV7Broker -e default -o HTTPSConnector -n keystoreType -v JKS
4.Associate the keystore password

Associate the keystore password to the broker so that it can save it in its registry for authentication purpose, which is required when querying the new requests:

mqsichangeproperties MBV7Broker -e default -o HTTPSConnector -n keystorePass -v <password>
Part 4 : Setting up JVM attributes for execution groups

When an execution group is started in WebSphere Message Broker, it creates a JVM that is primarily used by the IBM primitive nodes that make use of Java functionality. The DataFlowEngine JVM can be configured either by passing parameters to it directly, or through the broker. When using the broker JVM by any of the means above, the DataFlowEngine memory may continue to grow and may cause resource problems. Use the following few commands to set up your min and max JVM heap size:

mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n keystoreFile 
    -v “C:\IBM\MQSI\7.0\MBV7Broker.jks”


mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n keystoreType 
    -v JKS

mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n keystorePass 
    -v brokerKeystore::password


mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n truststoreFile 
    -v “C:\IBM\MQSI\7.0\MBV7Broker.jks”
In this command, the keystore file type is associated with the ComIbmJVMManager object.
mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n truststoreType -v JKS
When querying new requests, associate the keystore password with the broker’s ComIbmJVMManager object so that it can be saved it in its registry for authentication purposes:
mqsichangeproperties MBV7Broker -e default -o ComIbmJVMManager -n truststorePass 
    -v brokerTruststore::password
Testing SSL using a Message flow:-
Message Flow Creation
Request Flow
Inorder to fire a message,we used MQInput node where we give some BLOB data to fire the flow.The HTTPRequest invokes the service at http://localhost:7091/test1 where 7091 is the port no. which we have configured earlier using commands.
Node Name
Node type
Properties
MQInput
MQInput
(Basic) Queue Name : q1
(Input Message parsing) Message Domain : BLOB : For messages with an unspecified format
(Security) Identity Token Type : Transport Default
HTTPRequest
HTTPRequest
(Basic) Web service URL : http://localhost:7091/test1
(Input Message parsing) Message Domain : XMLNSC : For XML messages (namespace aware, validation, low memory use)
(SSL) SSLProtocol:SSLV3
Enable SSL Certificate Hostname Checking – check this box
(Advanced) Response Message Location in Tree – OutputRoot.BLOB
Compute
Compute
Default Properties
MQOutput
MQOutput
(Basic) Queue Name : q2
Response Flow
HTTPInput
HTTPInput
HTTPReply
HTTPReply
Default Properties

Configuring an HTTPRequest node to use SSL

Creating a message flow to make HTTPS requests

The following message flow creates a generic message flow for converting a WebSphere® MQ message into an HTTP Request:

  1. Create a message flow with the nodes MQInput->HTTPRequest->Compute->MQOutput.
  2. On the MQInput node, set the queue name to “q1” and create the WebSphere MQ queue.
  3. On the MQOutput node, set the queue name to “q2” and create the WebSphere MQ queue.
  4. On the HTTPRequest node, set the Web Service URL to point to the HTTP server to call. To call the HTTPInput node, use http://localhost:7091/test1.
  5. On the Advanced properties tab of the HTTPRequest node, set the Response message location in tree property to OutputRoot.BLOB.
  6. On the Compute node, add the following ESQL code:

The message flow is now ready to be deployed to the broker.

Configuring HTTPInput and HTTPReply nodes to use SSL

For this we have to Configure the HTTPInput and HTTPReply nodes to communicate with other applications that use HTTPS by creating a keystore file, configuring the broker to use SSL, and creating a message flow to process HTTPS requests.

Creating a message flow to process HTTPS requests

Create a simple message flow to use HTTPS by connecting an HTTPInput node to an HTTPReply node. The two most important properties to set on the HTTPInput node are:

  • Path suffix for URL; for example, /* or /testHTTPS.
  • Use HTTPS.

/* means that the HTTPInput node matches against any request that is sent to the HTTP listener on a designated port.
You can now deploy the message flow to the broker. If you have completed all the documented steps, message BIP3132 is written to the local system log (on Windows, the event log), stating that the HTTPS listener has been started.
You can now test the system.

Testing the example

To test that the example works, complete the following steps:

  1. After Succesful creation of request & response flow.
  2. Deploy the HTTPRequest message flow.
  3. Put a message to the WebSphere MQ queue HTTPS.IN1. If successful, a message appears on the output queue. If the process fails, an error appears in the local error log (which is the event log on Windows).

Testing your configuration

The simplest method of testing whether HTTPS is configured correctly is to use a Web browser to make a request to the broker over HTTPS.
Start a Web browser and enter the following URL:

 http://localhost:7091/test1

Change values in the URL to reflect the changes that you have made in your broker configuration; for example, the port number. When a window is displayed asking you to accept the certificate, select Yes. The browser refreshes the window and displays an empty HTML page:

  • In Mozilla browsers, the empty HTML page looks like the following example:

  • In Internet Explorer, the following information is displayed:
XML document must have a top level element. Error processing resource 'http://localhost:7091/test1'

These responses mean that a blank page was returned, indicating that the setup worked correctly. To add content to the empty page, you can add a Compute node to the flow.
You can use another HTTPS client to process HTTPS requests. Read the documentation for the client to find out how to configure it to make client connections over SSL.
You can also use another HTTPS client, such as a Java or .net client, instead of the Web browser. Depending on the type of client, you might need to export the certificate (which was created with keytool) from the keystore file associated with the HTTP listener, then import it into the keystore for the client. Read the client documentation to find out how to configure the client to make client connections over SSL.

We can also test this Flow by using SOAPUI or by pasting url in the address bar and hitting enter key.
1.On pasting the url “http://172.17.5.110:7091/test1” into the address bar,the response flow begins
& then it displays a message on the browser like
2.Using SOAPUI tool:-
Open SOAPUI tool then goto file –>preferences to do all the necessary configurations for ssl.
Then a preferences window appears like this:-
It asks for jks path along with keystore password along with port no.which we configured earlier.
Then start the request flow by putting some sample BLOB message in MQInput nodeThen the flow starts
then click on “submit request to specific endpoint URL” from SOAPUI tool
Then it hits the response flow
then again back to the request flow to process the compute node
and finally the message is sent to the MQOutput node.
After processing we can see the response in the SOAPUI Tool
Installing Certificates in Internet Explorer
Step1:-Goto Tools → Internet Options
Step 2:- Browse to Content Tab and in the Certificates are click certificates button
Step 3:-The certificates window opens there find Import button & click on it
Step 4:- Goto path where you stored the certificates
and click open..
Step 5:- Here choose Automatically select the certificate store based on the type of certificate
Finally click on Finish…
Then you see this window.
Finally To check whether our certificate was imported successfully into the browser:-

ESQL Coding conventions

Naming/Coding conventions are needed to understand and maintain the software.

Here i am explaining the  file naming and organization, file layout, comments, line wrapping, alignment, white space, naming conventions, frequently used statements, and useful programming practices.

1.File naming and organization

The following guidelines should be used when constructing the ESQL files that implement a WebSphere Message Broker application:

  • ESQL source files should always have names that end with the extension .esql. For example: NotificationTimeout.esql.
  • ESQL filenames should consist of mixed-case alphabetic characters, with the first letter of each word and all acronyms in uppercase. For example: IBMExample.esql.

In general, ESQL files longer than 2000 lines are cumbersome to deal with and should be avoided, by ensuring that a single ESQL file implements the message flows that relate to each other, and by abstracting reusable code into separate ESQL files.

ESQL files can be grouped in broker schemas, which are a hierarchical way of organizing ESQL files. They also serve to create local name spaces so that procedures and functions can be reused, and yet be distinguished by the schema they are in. In short, broker schemas are organizational units of related code that address a specific business or logical problem. Therefore, related ESQL files should be placed in their own schema.

namingConvention

ESQL file organization and layout

2.File layout

The content of each ESQL file should conform to the following standards:

  • The file must start with a descriptive header comment, as described in Section 5 below.
  • The header comment should be followed by a broker schema declaration and the PATH clauses that specify a list of additional schemas to be searched when matching function and procedure calls to their implementations. Do not use the default broker schema.

BROKER SCHEMA com.ibm.convention.sample

PATH com.ibm.convention.common;

PATH com.ibm.convention.detail;

The remainder of the file should be divided into three sections:

1.Broker schema level variables and constants

They are not globally reusable and can only be used within the same broker schema.

EXTERNAL variables are also known as user-defined properties. They are implicitly constant. When you use the NAMESPACE and NAME clauses, their values are implicitly constant and of type CHARACTER.
DECLARE DAY1 EXTERNAL CHARACTER ‘monday’;

DECLARE XMLSCHEMA_INSTANCE NAMESPACE ‘http://www.w3.org/2001/XMLSchema-instance&#8217;;

DECLARE HIGH_PRIORITY CONSTANT INTEGER 7;

DECLARE processIdCounter SHARED INTEGER 0;

2.Broker schema level procedures and functions

They are globally reusable and can be called by other functions or procedures in ESQL files within any schema defined in the same or another project.

CREATE PROCEDURE getProcessId(OUT processId CHARACTER)

BEGIN

    BEGIN ATOMIC

        SET processId = CAST(CURRENT_TIMESTAMP AS CHARACTER FORMAT ‘ddHHmmss’)

                        || CAST(processIdCounter as CHAR);

        SET processIdCounter = processIdCounter + 1;

    END;

END;

CREATE FUNCTION encodeInBASE64(IN data BLOB)

RETURNS CHARACTER

LANGUAGE JAVA

EXTERNAL NAME “com.ibm.broker.util.base64.encode”;

3.Modules

A module defines a specific behavior for a message flow node. It must begin with the CREATE node_type MODULE statement and end with an END MODULE statement. The node_type must be either COMPUTE, DATABASE, or FILTER. A module must contain the function Main(), which is the entry point for the module. The constants, variables, functions, and procedures declared within the module can be used only within the module.

CREATE FILTER MODULE FilterData

CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

DECLARE messageType REFERENCE TO Root.XMLNSC.Msg.Type;

IF messageType = ‘P’ THEN

RETURN TRUE;

ELSE

IF messageType = ‘D’ THEN

RETURN FALSE;

ELSE

RETURN UNKNOWN;

END IF;

END IF;

END;

END MODULE;


3.Naming conventions

In general, the names assigned to various ESQL constructs should be mnemonic and descriptive, using whole words and avoiding confusing acronyms and abbreviations. Of course, you need to balance descriptiveness with brevity, because overly long names are hard to handle and make code harder to understand. The following table provides naming conventions for ESQL broker schemas, modules, keywords, correlation names, procedures, functions, variables, and constants.

Entity Naming rules
Schema A schema name reflects the file system name leading the location of files in this schema. Each level in a schema name is mapped to a directory name. To be supported by any file system, schema names should consist of lower case alphanumeric characters. The names should be prefixed with the reverse of the company URL. com.ibm.convention.
sample
Module A module name should consist of more than one alphanumeric character, start with an upper case letter, and have mixed case, with the first letter of each internal word and all letters of acronyms in uppercase. It must match any label assigned to a compute, database, or filter node in a message flow that uses the module. If more than one such node in a message flow uses the same module, add additional characters to the node labels in order to differentiate between them. ConstructInvoice1
ConstructInvoice2
IsReconnect
RetrieveIBMData
ESQL keyword ESQL keywords should be uppercase, although they are not case sensitive. SET
CREATE PROCEDURE
TRUE
Field reference or correlation name A field reference or correlation name should start with an uppercase letter and have mixed case, with the first letter of each internal word and all letters of acronyms in uppercase. Environment.Variables.
Invoice.
CustomerNumber
Variable A variable name should start with a lowercase letter and have mixed case, with the first letter of each internal word and all letters of acronyms in uppercase. Since a variable name should start with a lowercase letter, it should not start with an acronym. Trivial variable names such as i or x can be assigned to temporary variables of limited scope and importance at your discretion. i
invoiceItem
currentHL7Section
controlReference
Procedure or function A procedure or function name should consist of more than one alphanumeric character, start with a lowercase letter, and have mixed case, with the first letter of each internal word and all letters of acronyms in uppercase. The first word of the name should be a verb. setEnvironment
computeIBMValue
Constant A constant name should start with a letter, use all uppercase letters, and use the underscore ( _ ) to separate words. MIN_VOLUME
MAX_RETRIES
4.Comments

The discussion below classifies ESQL comments into one of two classes:

  • Header comments, used to summarize and demarcate a section of an ESQL file
  • Implementation comments, used to clarify the meaning of a piece of ESQL logic.

4.1. Header comments

4.1.1. File header

An ESQL file should always begin with a file-header comment that provides the name of the file, a brief synopsis of the purpose of the file, the copyright, and author information. The example below illustrates one possible format for such a header, but any suitable alternative that clearly conveys the same information is acceptable. The header is 80 characters in length. The description text should consist of complete sentences, wrapped as needed without using hyphenation. List each author on a separate line.

 

*

* File name: Workfile.esql

*

* Purpose:   Sample ESQL file with proper prologue.

*

* Authors:   Rachel Shen

*                 Ankur Upadhyaya

* Date      21 March 2008

* Version:  1.0

*

* @copyright  IBM Canada Ltd. 2008.  All rights reserved.

*

*/

4.1.2. Module header

Every module definition must be preceded by a module header comment. A module header contains descriptive text that consists of complete sentences, wrapped as needed without using hyphenation:

/*

* Module description goes here

*

*/

4.1.3. Procedure header

Every procedure definition must be preceded by a procedure header comment. A procedure header contains descriptive text that consists of complete sentences, wrapped as needed without using hyphenation. This header should also name and describe each of the parameters handled by the procedure, classifying them as type IN, OUT, or INOUT. The parameter descriptions need not consist of complete sentences — brief, descriptive phrases should suffice. However, they should be preceded by a hyphen and properly aligned with one another:

 

* Procedure description goes here.

*

* Parameters:

*

* IN:     REFERENCE parameter1 – Description goes here.

* INOUT: INTEGER   parameter2 – Description goes here.

* OUT:    TIMESTAMP result     – Description goes here.

*

*/

4.1.5. Function header

Function headers are essentially the same as procedure headers:

 

* Function description goes here.

*

* Parameters:

*

* IN:     REFERENCE parameter1 – Description goes here.

* INOUT: INTEGER   parameter2 – Description goes here.

* OUT:    TIMESTAMP result     – Description goes here.

*

* RETURNS: BOOLEAN – Description goes here.

*

*/

4.2. Implementation comments

Add comments to ESQL source code to clarify program logic and convey information that is not immediately obvious from inspecting the code. Do not add too many comments — they can become redundant, complicate code maintenance, and get out of date as the software evolves. In general, too many comments indicate poorly written code, because well written code tends to be self explanatory. Implementation comments can be written in single-line, block, or trailing forms, as described below.

4.2.1. Single-line comments

A single-line comment is a short comment that explains and aligns with the code that follows it. It should be preceded by a single blank line and immediately followed by the code that it describes:

— Check for the condition

IF condition THEN

    SET z = x + y;

END IF;

4.2.2. Block comments

Block comments are used to provide descriptions of ESQL files, modules, procedures, and functions. Use Block comments at the beginning of each file and before each module, procedure, and function. You can also use them anywhere in an ESQL file. Block comments inside a function or procedure should be indented at the same level as the code they describe. Precede a block comment by a single blank line and immediately follow it by the code it describes. Because shorter comments with expressive code are always preferable to lengthy block comments, block comments should be rarely used within a procedure or function. Example of a block comment:

*

* Here is a block comment to show an example of comments

* within a procedure or function.

*

*/

IF condition THEN

SET z = x + y;

END IF;

4.2.3. Trailing comments

Trailing comments are brief remarks on the same line as the code they refer to. Indent these comments to clearly separate them from the relevant code. If several trailing comments relate to the same segment of code, align the comments with one another. Trailing comments are usually brief phrases and need not be complete sentences:

IF condition THEN

SET z = x + y;           — trailing comment 1

ELSE

SET z = (x – y) * k;    — comment 2, aligned with comment 1

END IF;

5.Style guidelines

5.1. Line wrapping and alignment

Lines of ESQL source code should be wrapped and aligned according to the following guidelines:

  • Every statement should be placed on a separate line.
  • Lines longer than 80 characters should be avoided as they exceed the default width of many terminals and development tools.
  • The unit of indentation used to align ESQL source code should be four characters which is the default setting in the WebSphere Message Broker Toolkit. The specific construction of this indentation, using spaces or tabs, is left to the discretion of the programmer.
  • Line lengths should be limited by breaking lengthy expressions according to the following rules:
  • Lines should be as long as possible, without exceeding 80 characters;
  • Break after a comma;
  • Break before an operator;
  • Break at the highest level possible in the expression;
  • Align a new line with the beginning of the expression at the same level on the preceding line. Should this alignment require deep indentations that produce awkward code, an indentation of eight spaces may be used instead.

The following ESQL code samples illustrate the above rules.

1

2

3

4

5

6

7

8

9

10

11

CREATE FUNCTION function1(IN longExpression1 REFERENCE,

IN longExpression2 CHAR,

OUT longExpression3 NUMBER,

INOUT longExpression4 CHAR)

CALL procedure1(myLongVariable1, myLongVariable2, myLongVariable3,

myLongVariable4);

SET returnValue = function1(argument1, argument2, argument3,

function2(argument4, argument5,

argument6));

SET finalResult = ((x / variable1) * (variable2 – variable3))

+ (y * variable5);

The ESQL sample below illustrates a case where an indentation of eight spaces should be used instead of the usual alignment to avoid deeper indentations that would result in confusing code.

1

2

3

4

— INDENT 8 SPACES TO AVOID VERY DEEP INDENT

CREATE PROCEDURE showAVeryLongProcedureName(IN argument1,

INOUT argument2,

OUT argument3)

Finally, the ESQL samples below illustrate line wrapping and alignment practices. The first is preferable because the line break is inserted at the highest level possible.

SET longName1 = longName2 * (longName3 + longName4 – longName5)

+ 4 * longname6;                         — PREFER

SET longName1 = longName2 * (longName3 + longName4

– longName5) + 4 * longname6;          — AVOID

5.2. White space

White space should be used to improve code readability.

  • Insert two blank lines between sections of a ESQL file;
  • Insert one blank line between functions and procedures;
  • Insert one blank line between the variable declarations in a function/procedure and its first statement;
  • Insert one blank line before a block or single-line comment;
  • A blank space should follow each comma in any ESQL statement that makes use of commas outside of a string literal;
  • All binary operators should be separated from their operands by spaces.
SET a = c + d;

SET a = (a + b) / (c * d);

6.Statements

Each line should contain at most one statement. Here are some sample statements.

6.1. DECLARE

Put declarations right after the broker schemas or at the beginning of modules, functions, and procedures. One declaration per line is recommended:

– EXTERNAL variable

DECLARE DAY1 EXTERNAL CHARACTER ‘monday’;

— NAMESPACE variable

DECLARE XMLSCHEMA_INSTANCE NAMESPACE ‘http://www.w3.org/2001/XMLSchema-instance&#8217;;

— CONSTANT

DECLARE HIGH_PRIORITY CONSTANT INTEGER 7;

— SHARED variable

DECLARE processIdCounter SHARED INTEGER 0;

— REFERENCE

DECLARE messageType REFERENCE TO Root.XMLNSC.Msg.Type;

6.2. FOR

DECLARE i INTEGER 1;

FOR source AS Environment.SourceData.Folder[] DO

SET i = i + 1;

END FOR;

6.3. IF

– IF statement

IF InputBody.Msg.Report = ‘PDF’ THEN

SET OutputRoot.XMLNSC.Msg.Type = ‘P’;

END IF;

— IF-ELSE statement

IF InputBody.Msg.Report = ‘PDF’ THEN

SET OutputRoot.XMLNSC.Msg.Type = ‘P’;

ELSE

SET OutputRoot.XMLNSC.Msg.Type = ‘X’;

END IF;

— IF-ELSEIF-ELSE statement

IF InputBody.Msg.Report = ‘PDF’ THEN

SET OutputRoot.XMLNSC.Msg.Type = ‘P’;

ELSEIF InputBody.Msg.Report = ‘DOC’ THEN

SET OutputRoot.XMLNSC.Msg.Type = ‘D’;

ELSE

SET OutputRoot.XMLNSC.Msg.Type = ‘X’;

END IF;

6.4. LOOP

DECLARE i INTEGER;

SET i = 1;

x : LOOP

IF i >= 4 THEN

LEAVE x;

END IF;

SET i = i + 1;

END LOOP x;

6.5. RETURN

RETURN;

RETURN TRUE;

RETURN FALSE;

RETURN UNKNOWN;

RETURN ((priceTotal / numItems) > 42);

6.6. THROW

THROW USER EXCEPTION;

THROW USER EXCEPTION CATALOG ‘BIPv600’ MESSAGE 2951

VALUES(‘The SQL State: ‘, SQLSTATE, ‘The SQL Code: ‘,

SQLCODE, ‘The SQLNATIVEERROR: ‘, SQLNATIVEERROR,

‘The SQL Error Text: ‘, SQLERRORTEXT);

6.7. WHILE

— WHILE statement

DECLARE i INTEGER 1;

WHILE i <= 10 DO

SET OutputRoot.XMLNSC.Msg.Count[i] = i;

SET i = i + 1;

END WHILE;

6.8. CASE

CASE function

— Like ?: Expression in C

SET OutputRoot.XMLNSC.Msg.Type = CASE InputBody.Msg.Report

WHEN ‘PDF’ THEN ‘P’

WHEN ‘DOC’ THEN ‘D’

ELSE ‘X’

END;

— Like SWITCH Expression in C

CASE InputBody.Msg.Report

WHEN ‘PDF’ THEN

SET OutputRoot.XMLNSC.Msg.Type = ‘P’;

WHEN ‘DOC’ THEN

CALL handleDocument();

ELSE

CALL handleUnkown();

END CASE;

6.9. SELECT

SELECT ITEM segment.No

FROM ControlRef.Segments.Segment[] AS segment

WHERE segment.No = currentSegment;

6.10. UPDATE

UPDATE Database.TELEMETRY AS telemetry

SET bitmap = refEnvTeleSeg.NewBitmap

WHERE telemetry.TelemetryId = refEnvTeleSeg.Results.TelemetryId;

6.11. INSERT

INSERT INTO Database.TELEMETRY_SEGMENT (TelemetryId, BlockNum, FileSegment)

VALUES (refEnvTeleSeg.Results.TelemetryId, RefEnvTeleSeg.SegmentNum,

ASBITSTREAM(Body));

7.Programming practices
  • Put variables and constants at the broker schema level only when they need to be reused by multiple modules.
  • Initialize variables within DECLARE statements, especially EXTERNAL variables.
  • Declare REFERENCEs to avoid excess navigation of the Message Tree.
  • Specify a direction indicator for all new routines of any type for documentation purposes although the direction indicator (IN, OUT, INOUT) of FUNCTION is optional for each parameter.
  • Make code as concise as possible to restrict the number of statements. This will cut parsing overhead.
  • Use LASTMOVE or CARDINALITY statements to check the existence of fields in the message tree. This would avoid mistakes.
  • Avoid use of CARDINALITY statements inside loops.
  • Avoid overuse of Compute nodes because tree copying is processor heavy: put reusable nodes into sub-flows.
  • Avoid nested IF statements: use ELSEIF or CASE WHEN clauses to get quicker drop-out.
  • Avoid overuse of string manipulation because it is processor heavy: use the REPLACE function in preference to a complete re-parsing.
  • Use parentheses to make the meaning clear. The order of precedence in the arithmetic expressions is:
  • Parentheses
  • Unary operators including unary – and NOT
  • Multiplication and division
  • Concatenation
  • Addition and subtraction
  • Operations at the same level are evaluated from left to right.
  1. Code sample
/*

*

* File Name: ESQLCodeConvention.esql

*

* Purpose:   Sample ESQL file with proper prologue.

*

* Authors:   Rachel Shen

*                 Ankur Upadhyaya

* Date      21 March 2008

* Version:  1.0

*

* @copyright  IBM Canada Ltd. 2008.  All rights reserved.

*

*/

BROKER SCHEMA com.ibm.convention.sample

PATH com.ibm.convention.common;

— First day of the week

DECLARE DAY1 EXTERNAL CHARACTER ‘monday’;

— XML schema instance namespace

DECLARE XMLSCHEMA_INSTANCE NAMESPACE ‘http://www.w3.org/2001/XMLSchema-instance&#8217;;

— High priority message’s priority on MQ

DECLARE HIGH_PRIORITY CONSTANT INTEGER 7;

— A shared counter to generate process id

DECLARE processIdCounter SHARED INTEGER 0;

/*

* This procedure generates the process id.

*

* Parameters:

*

* OUT:   CHARACTER processId     – Description goes here.

*

*/

CREATE PROCEDURE getProcessId(OUT processId CHARACTER)

BEGIN

BEGIN ATOMIC

SET processId = CAST(CURRENT_TIMESTAMP AS CHARACTER FORMAT ‘ddHHmmss’)

|| CAST(processIdCounter as CHAR);

SET processIdCounter = processIdCounter + 1;

END;

END;

/*

* This function encodes the input in BASE64 format.

*

* Parameters:

* IN:    BLOB document – Input document for encoding.

*

* RETURNS: CHARACTER   – BASE64 encoded string.

*

*/

CREATE FUNCTION encodeInBASE64 (IN data BLOB)

RETURNS CHARACTER

LANGUAGE JAVA

EXTERNAL NAME “com.ibm.broker.util.base64.encode”;

/*

* This module has the sample code for the article, ESQL code convention.

*/

CREATE COMPUTE MODULE CreateESQLCodeConvention

CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

DECLARE processId CHARACTER;  — Unique identifier of the working process

CALL getProcessId(processId);

SET encodedMessage = base64Encode(ASBITSTREAM(InputBody.Msg));

RETURN TRUE;

END;

END MODULE;

/*

* This module filters data base on the message type.

* It has the sample code of the second module in the ESQL file.

*/

CREATE FILTER MODULE FilterData

CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

DECLARE messageType REFERENCE TO Root.XMLNSC.Msg.Type;

IF messageType = ‘P’ THEN

RETURN TRUE;

ELSEIF messageType = ‘D’ THEN

RETURN FALSE;

ELSE

RETURN UNKNOWN;

END IF;

END;

END MODULE;

 

Course Details

Following are the list of topics covering in the training : 

 

SNo. TOPIC
1 Introduction & Environment
2 XML & XSD & WSDL
3 ToolKit Introduction & Components
4 IIB Architecture
5 Message Tree(Logical Tree) Structures
6 Message Flow ,subflow , library
7 Webservices
8 Compute Node: Properties, uses; Routing & Transformation
9 MessageModel & Parsing
10 Soap Nodes & HTTP Nodes
11 Oracles Queries & Creating packages
12 ESQL (Functions ,Datatypes , Modules,Casting…)
13 WebServices & Applications (Creating WebServiecs & Importing wsdl’s)
14 ESQL Nodes
15 SOAP Structure
16 NODES: FileNodes & all common nodes (routeToLable,lable,input,output,Route,filter,Trace,MQNodes,RCD,timerNodes… )
17 Using Database (Odbc & Jdbc)
18 Regular Using Commands
19 Mapping Node & Importance
20 Using Java In Toolkit
21 Error Handling (Debug & Trace)
22 DFDL (Dfdl Model & Importance)
23 Proxy & It’s Importance
24 SSL Certificate Importing
25 GlobalCache
26 File Processing & Importance
27 MQ concepts (Creating Queues , InterProcessing Communication B/w QManagers ,Clustering…)
28 Real time scenarios

 

ESQL-UDP(user Defined Properties)

UDP is a flow level constant , and the purpose of UDP is to creating custom variables of which the values can be changed with out re-touching the code. We can set the values at run time to dynamically change the behavior of the message flow.

While building the bar file we need to provide the values for UDP’s .Generally we used properties file to change the values of UDP’s.

This property is used by the ESQL or JAVA program inside the message flow nodes, such as compute node.

The advantage of UDP is that their values can be changed by operational staff based on environment (UAT or production) at the time of deployment. We need not do the changes in application programs.

udp

Fig: Flow level UDP property

In the above fig. UDP_CUSTOMER_CODE is the name of the UDP. We can assign the default value in the flow itself and while building the  bar file we can override this property.User Defined Properties tab is present at the bottom of the Edit window.

How to Define UDP in ESQL :

Define User Defined Properties  in ESQL by using a DECLARE statement with the EXTERNAL keyword.

syntax :-       DECLARE  UDP_CUSTOMER_CODE  EXTERNAL  CHARACTER;

ESQL VARIABLE SCOPE AND LIFETIME :

The variables declared and used in ESQL will have a scope (Flow/Module/Nodes to which the variable is accessible) and lifetime (time till the variable holds the value). When we declare a variable in ESQL, it will have the above two characteristics defined already based on the declaration syntax and place where it is declared.

There are mainly 3 types of variables in ESQL as below:

Module Variable ( Normal variable)
External Variable (UDP variable)
Shared Variable (long Lived variable)

Normal or Module variable  :

When we declare a variable within an ESQL module or without any special keyword, those are called Normal variable. This variable’s lifetime start with a node and end within that node. The visibilities of those varaibles are within the module only. For every message which pass through the node, a new instance of these normal variables will be created.

But if we define a normal variable outside the node, ie on schema level, the variable will be accessible to all the modules in the schema. But a separate instance will be given for each module.

In general, if DECLARE ed a variable in schema level without any keyword, its accessible across the nodes within the schema, but the value is not SHARE able.

Scope: for every single message passing through the node.

Lifetime: For a single message passing through the node.

Usage: for normal function/procedure calls, data processing.

External variable or User-Defined property Variable :

When we need a variable whose values are set at deployment time, we can create User defined property or External variables. External variables must be declared within the schema or module scope before actually using it. UDPs can be accessed by any built-in node that uses ESQL or JAVA. External variables are accessible anywhere in the flow and are not restricted to any particular node. External variable can be initialized by either the message flow editor (UDP) or BAR file. For every message which passes through the Flow, a new instance of these variables will be created. EXTERNAL variable value cannot be changed by ESQL.

Scope: for all messages passing through the flow

Lifetime: Till the message flow stops.

Usage: For configuration data like database name, schema name, WS-Use rid, Password etc.

Shared Variable (Long Lived variable) :

Shared variables are those as the name indicates share the value across multiple message flow instances. Shared variable lifetime is till the execution group restart and scope is throughout the message flow. It can be accessed in any nodes which uses ESQL. It can be modified using any node/ESQL in the flow.

SHARED variables can be accessed by multiple instance of same message flow in the same execution group. SHARED variable is accessible to all the flows in the execution group, but, a different instance will be getting for each different flow. Means, you cannot actually SHARE the data using SHARED variable between different flows in same execution group. Only the Same flow instances will get the SHARED data using SHARED variables.

Scope: for all messages passing through the flow.

Lifetime: Till the execution group stops.

Note: If you declare a variable in Schema level without any keyword (normal), it will be accessible to each ESQL node. But each node get a new instance of this variable, ie, data cannot be shared by normal schema level variables. If the data need to be shared, the ESQL variable in schema should be declared as SHARED.

 

Connectivity

Here i am explaining some network level connectivity commands like ifconfig,ping,netstat,telnet ,wget,curl…

Ifconfig : To check IP of the machine . (ipconfig for windows)

ifconfig.png

ping Ping is a basic Internet program that allows a user to verify that a particular IP address/url exists and can accept requests. 

ping_ip

ping_url

netstat : Netstat is a common command line TCP/IP networking utility available in most versions of Windows, Linux, UNIX and other operating systems. Netstat provides information and statistics about protocols in use and current TCP/IP network connections.

Here 12000 is port.

netstat

In case of windows the command should : netstat -an | findstr 1200

Telnet The TELNET command enables you to log on to a foreign host that supports TCP⁄IP.

You can able to eatablish the connection using ip/url of the foreign host.

Here 80 is the default port for http in case of https port is 443

telnet with IP.png

telnet with url.png

weget : wget stands for “web get”. It is a command-line utility which downloads files over a network.

It can work in the background, while the user is not logged on.

If your flow was deployed in a remote/local machine & you want to check(download) the service(wsdl) , in this case wget will helps you to download the deployed wsdl.

Eg :  wget http://10.211.55.7:7080/TestService

If any proxy is exists , then you need to enter proxy authentications also.

wget.png

using wget we can send request to the service

Eg : wget –post-file=request.txt http://IP or URL:PORT/TestService –no-proxy

Here request.txt needs contains your entire soap/http request and also the file needs to be present on the current path then this command fires the request and capture the response & stores it in the same path (as a text file)

wget with proxy :

wget –post-file=request.txt https://IP or URL:Port/TestService –http-user=userid –http-password=password

curl : Curl is similar to the wget , here also you can fire a request without any testing tools like SoapUi/PostMan.

curl -u userid:password -X POST -d ‘Here your entire xml request’ https://IP or URL:PORT/ServiceName –header “Content-Type: application/xml” –header “Accept: application/xml”

Here XPOST is the request type.

 

ESQL

Extended Structured Query Language (ESQL) is a programming language defined by WMB / IIB to define and manipulate data within a message flow.
We can use ESQL for the following Nodes :
Compute,
Database,
DatabaseInput, and
Filter nodes.

For each node, use need to create an ESQL module in which you code the ESQL statements and functions to tailor the behavior of the node. You can access message content, or database content, or both, to achieve the results that you require. ESQL modules are maintained in ESQL files, managed through the Broker Application Development / Integration Development perspective.
You can use the ESQL debugger, which is part of the flow debugger, to debug the code that you write.
The debugger steps through ESQL code statement by statement, so that you can view and check the results of every line of code that is run.
ESQL is based on Structured Query Language (SQL) which is in common usage with relational databases such as ORACLE. ESQL extends the constructs of the SQL language to provide support for you to work with message and database content to define the behavior of nodes in a message flow.

The ESQL code that you create to customize nodes within a message flow is defined in an ESQL file, typically named <message_flow_name>.esql, which is associated with the Message Broker / Integration project.

Note : The name of the module in the ESQL file must match the name specified for the module in the ESQL Module property of the corresponding node.

You can also use ESQL to create functions and procedures that you can use in the Mapping node.
To use ESQL correctly and efficiently in your message flows, you must also understand the following
concepts:
• Data types
• Variables
• Field references
• Operators
• Functions
• Procedures
• Modules

ESQL data types :
ESQL defines the following categories of data. Each category contains one or more data types.

• Boolean
• Datetime
• Null  –>NULL
• Numeric
• Reference
• String

Boolean : 

  • TRUE
  • FALSE
  • UNKNOWN

Datetime :

  • DATE
  • TIME
  • GMTTIME
  • TIMESTAMP
  • YEAR
  • YEAR TO MONTH
  • MONTH
  • DAY
  • DAY TO HOUR
  • DAY TO MINUTE
  • DAY TO SECOND
  • HOUR
  • HOUR TO MINUTE
  • HOUR TO SECOND
  • MINUTE
  • MINUTE TO SECOND
  • SECOND

Numeric : 

  • DECIMAL
  • FLOAT
  • INT

Reference :

If you use a REFERENCE, you are able to modify any element, even if the element is part of an input tree. EG : DECLARE inputMsg REFERENCE TO InputRoot.XMLNSC.RootElement;

String :

  • BIT
  • BLOB
  • CHAR

For More Info on DataTypes : ESQL_DataTypes

Variables : 

An ESQL variable is a data field that is used to help process a message.
To define a variable and give it a name, use the DECLARE statement.
The names of ESQL variables are case-sensitive; The WMB / IIB Toolkit marks variables that have not been defined. Remove all these warnings before deploying a message flow.

STAY TUNE FOR REMAINING CONCEPT 🙂 🙂