Professional Documents
Culture Documents
Page 2 of 24
WMB Best Practices & ESQL Development
Guidelines
Table of Contents
1 Introduction................................................................................................................ 5
2 Purpose..................................................................................................................... 5
3 Assumptions..............................................................................................................5
4 WebSphere MB Best Practices..................................................................................6
4.1 Understand the Interface Business Requirement.............................................................6
4.2 Interface Design Layout.................................................................................................... 6
4.3 Common Characteristics of Interfaces..............................................................................6
4.4 Common Error/Exception Handling..................................................................................6
4.5 Common Control Handling............................................................................................... 6
4.6 Common Routines and Sub-Flows...................................................................................7
4.7 Location of Integration Logic............................................................................................ 7
4.8 Understand the Input and Output Messages....................................................................7
4.9 Determine how many Message Flows are needed...........................................................7
4.10 Complete the processing with as few nodes as possible..........................................8
4.11 Message Routing within a flow..................................................................................8
4.12 SubFlows................................................................................................................... 8
4.13 Transactionality and Persistence...............................................................................8
4.14 Use of CARDINALITY............................................................................................... 9
4.15 ESQL REFERENCE Variable....................................................................................9
4.16 Use of MOVE & LASTMOVE.....................................................................................9
4.17 Backout Processing Considerations........................................................................10
4.18 WBI MB Message Flow Standard Unit Test Conditions...........................................10
5 ESQL Development Guidelines................................................................................11
5.1 Line Length..................................................................................................................... 11
5.2 Wrapping Lines............................................................................................................... 11
5.3 Comments...................................................................................................................... 11
5.4 Flower Box Comments.................................................................................................... 11
5.5 Block Comments............................................................................................................ 13
5.6 Internal and End-of-Line Comments...............................................................................13
5.7 Comments for CR/DR..................................................................................................... 13
5.8 Statements..................................................................................................................... 14
5.8.1 WHILE Statement.................................................................................................... 14
Page 3 of 24
WMB Best Practices & ESQL Development
Guidelines
5.8.2 IF Statement............................................................................................................ 14
5.8.3 CASE Statement..................................................................................................... 15
5.8.4 SELECT Statement.................................................................................................15
5.8.5 INSERT Statement.................................................................................................. 15
5.8.6 Update Statement................................................................................................... 16
5.8.7 DELETE Statement.................................................................................................16
5.9 Declarations.................................................................................................................... 16
6 Appendix 1. Important Structures............................................................................17
6.1 MQMD – Message Descriptor........................................................................................ 17
6.2 MQRFH2 – Rules and Formatting Header.....................................................................18
6.3 Properties – Message Flow............................................................................................18
7 Appendix 2. Debug Tracing.....................................................................................20
8 A Sample ESQL.......................................................................................................21
Page 4 of 24
WMB Best Practices & ESQL Development
Guidelines
1 Introduction
This document presents some findings and recommendations concerning the use of WebSphere
Message Broker (WMB). These findings were developed from previous experiences of various
integration projects. It covers the aspects of WMB development encompassing Message Set
guidelines, Message Flow guidelines and Deployment guidelines.
2 Purpose
This document can serve as a baseline for Integration Projects using WMB with a little or no
modifications as appropriate.
3 Assumptions
Prior working level of knowledge on WMB for the readers of this document.
Page 5 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 6 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 7 of 24
WMB Best Practices & ESQL Development
Guidelines
4.12 SubFlows
Message Flows can be divided into SubFlows. Essentially, a Subflow is a sequence of nodes that
begins with an Input node and ends in an Output node. The object of using SubFlows is that
functions can be logically segregated in a way that increases maintainability and offers
opportunity for reuse.
The use of SubFlows does not have an adverse performance effect because at deploy time they
are simply folded into the flow to which they are assigned. It is important that the overall number
of nodes should not be increased when using SubFlows.
Page 8 of 24
WMB Best Practices & ESQL Development
Guidelines
As a rule, all messages should be handled as a Transaction. In the Input, Output and Compute
nodes, the Transactionality should always be set to ‘Automatic’. This practice allows the
WebSphere MQ message attributes to control the Transactionality of the flow; i.e. if a message is
read from a queue with an attribute of ‘Persistent’, WBI MB will supply the appropriate logging to
guarantee the Transactionality of the message.
It must be considered that overhead is incurred by making a message transactional. This is
caused by the need to save all the data necessary to enable a roll back should a failure condition
occur in a message flow.
Page 9 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 10 of 24
WMB Best Practices & ESQL Development
Guidelines
5.3 Comments
The ESQL code should be self-explanatory as far as possible, for example, by use of meaningful
variable names. Comments are needed however, to explain what the ESQL code is doing or why
is it doing that way if it is not obvious. Underlying assumptions should be noted.
Use the more standard format ‘/* Comment */’ for headers and multi-line comments, and ‘--
Comment’ for single line comments. Comments must be in coherent grammatical English starting
with a capital letter. Multiline comments should be above the line of codes they refer to, indented
to the same level as the code itself and be preceded by a blank line.
A comment is recommended for each logic construct as this tends to be where business logic can
be explained.
Page 11 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 12 of 24
WMB Best Practices & ESQL Development
Guidelines
Very short comments can (if needed) appear on the same line of the code they describe, but
should be shifted far enough to the right to separate them from the statement. If more than one
short comment appears in a chunk of code, they should all be indented to the same tab setting.
IF InputRoot.XML.MyMsg.Agent.Dept = TOUPPER(‘SALES’) THEN
SET OutputRoot.XML.MyMsg.BooleanValue = ‘FALSE’; -- Expected Case
ELSE
SET OutputRoot.XML.MyMsg.BooleanValue = ‘TRUE’; -- Special Case
END IF;
Page 13 of 24
WMB Best Practices & ESQL Development
Guidelines
5.8 Statements
Logical constructs such as WHILE, IF, CASE and database actions should have a comment
preceding them. These are the blocks where business logic is performed and the most likely
stumbling point when it comes to others trying to understand the code.
Specific rules applying to these statements follows, although in many circumstances, common
sense will prevail.
5.8.2 IF Statement
/*
* Comment here for the
* IF-ELSE Block
*/
IF <condition> THEN
<Perform Processing>
ELSEIF <condition> THEN
<Perform Processing>
ELSE
<Perform Processing>
END IF;
Page 14 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 15 of 24
WMB Best Practices & ESQL Development
Guidelines
5.9 Declarations
Declaration of variables must be made at the beginning of each and every procedure or function.
One variable declaration per line is recommended. Declarations should be grouped by variable
type and a blank line should separate two groups. Also it is recommended not to initialize a
variable during declaration. Initialization should be explicitly made as a separate assignment
statement.
DECLARE intVar01 INTEGER;
DECLARE intVar02 INTEGER;
DECLARE intVar03 INTEGER;
Page 16 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 17 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 18 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 19 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 20 of 24
WMB Best Practices & ESQL Development
Guidelines
8 A Sample ESQL
/**********************************************************************
* COPYRIGHT. <Company Name & Year> ALL RIGHTS RESERVED. NO PART OF *
* THIS SOURCE CODE MAY BE REPRODUCED, STORED IN A RETRIEVAL SYSTEM, OR*
* TRANSMITTED, IN ANY FORM BY ANY MEANS, ELECTRONIC, MECHANICAL, PHOTO*
* COPYING, RECORDING OR OTHERWISE, WITHOUT THE PRIOR WRITTEN PERMISS- *
* ION OF <Company Name> *
**********************************************************************/
/**********************************************************************
* Node Name: Get Employee Information *
* Module Name: IDD111_EmployeeInfo *
* Description: This module searches for information about the*
* Employee from the Employee Database. *
* *
* Version Date Author Description *
* =============== =========== ===========
============================*
* 1.00 25-Feb-2006 A. Program The initial version. *
**********************************************************************/
CREATE COMPUTE MODULE IDD111_EmployeeInfo
/****************************************************************
* Function Name: Main *
* Input Parameters: None *
* Output Parameters: Boolean Return *
* Description: The Main entrypoint to the module *
* Version Date Author Description *
* =============== =========== ===========
======================*
* 1.00 25-Feb-2006 A. Program The initial version *
*****************************************************************************/
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- Copy input headers to output
Page 21 of 24
WMB Best Practices & ESQL Development
Guidelines
CALL prcCopyMessageHeaders();
-- Return success
RETURN TRUE;
END;
/****************************************************************
* Procedure Name: prcCopyMessageHeaders *
* Input Parameters: None *
* Output Parameters: None *
* Description: Copies input message headers to *
* the output message *
* Version Date Author Description *
* =============== =========== ===========
======================*
* 1.00 25-Feb-2006 A. Program The initial version *
*****************************************************************************/
CREATE PROCEDURE prcCopyMessageHeaders()
BEGIN
DECLARE intIdx INTEGER; -- An Index Pointer
DECLARE intCounter INTEGER; -- A counter
-- Initialize Index to 1
SET intIdx = 1;
/*
Iterate through each subtree of InputRoot and copy the
Sub-tree to the OutputRoot until the Last one.
*/
WHILE intIdx < intCounter DO
Page 22 of 24
WMB Best Practices & ESQL Development
Guidelines
/****************************************************************
* Procedure Name: prcCreateOutputMessage *
* Input Parameters: None *
* Output Parameters: None *
* Description: Creates the Output Message *
* Version Date Author Description *
* =============== =========== ===========
======================*
* 1.00 25-Feb-2006 A. Program The initial version *
*****************************************************************************/
CREATE PROCEDURE prcCreateOutputMessage()
BEGIN
DECLARE chrEmpId CHARACTER; -- Employee Id
-- Initialize chrEmpId
SET chrEmpId = InputRoot.XML.Employee.Id;
Page 23 of 24
WMB Best Practices & ESQL Development
Guidelines
Page 24 of 24