orbit-code-ai 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,12 +21,18 @@ The framework provides configuration-driven audit logging with field masking. Ev
21
21
  **Purpose**: Reads config from `Environment.Properties`, builds the audit XML structure, and routes to the audit queue.
22
22
 
23
23
  **Key behavior**:
24
- - Reads `AuditEnabled` and `LogEnabled` flags does nothing if both are FALSE
25
- - Extracts field values using XPath expressions defined in `value1`–`value10` properties
26
- - Masks fields listed in `maskingIn` / `maskingOut` using EVAL (dynamic path resolution)
27
- - Adds flow metadata: broker name, execution group, flow name, timestamps
28
-
29
- **Masking**: Fields listed in `maskingIn`/`maskingOut` have their values replaced with `****` before logging. Example masked field: `*.Header.ChannelUserInfo.UserPassword`
24
+ - Reads `AuditEnabled` / `LogEnabled` (the gate is the `Is*AuditEnabled` filter; AuditPoint builds the record)
25
+ - Tags `auditHeader.flowStart` from the node EXTERNAL `FLOW_START BOOLEAN` `LogAudit` sets it TRUE
26
+ (incoming), `LogOutgoingAudit` sets it FALSE (outgoing); incoming vs outgoing masking is chosen from this
27
+ - Sets `auditHeader.retryCount` from `InputRoot.MQRFH2.usr.retry.count` (0 when absent)
28
+ - Extracts field values using the paths in `value1`–`value10` properties (labelled by `key1`–`key10`)
29
+ - Masks the paths listed in `maskingIn` (incoming) / `maskingOut` (outgoing)
30
+ - Adds flow metadata: `applicationName`, `messageFlowName`, `brokerName`, `executionGroupName`, timestamps
31
+
32
+ **AuditPoint node external**: `DECLARE FLOW_START EXTERNAL BOOLEAN FALSE;`
33
+
34
+ **Masking**: fields listed in `maskingIn`/`maskingOut` are masked before logging. Example masked field:
35
+ `*.Header.ChannelUserInfo.UserPassword`.
30
36
 
31
37
  ---
32
38
 
@@ -1,146 +1,315 @@
1
1
  # Common Utilities (CommonUtils.esql)
2
2
 
3
- `CommonUtils.esql` is a 47KB shared ESQL library containing constants, queue routing, correlation ID generation, database access, and utility functions. Include it in every flow that needs routing or utility functions.
3
+ `CommonUtils.esql` is a ~48 KB (~1,200 line) shared ESQL library holding ESB constants, queue routing, channel lookups, correlation-ID generation, error-code/description mapping, response-header builders, exception parsing, and string/date helpers.
4
4
 
5
5
  **Location**: `Qiwa/Framework/Lib/CommonUtils.esql`
6
+ **Schema**: `BROKER SCHEMA Qiwa.Framework.Lib` (declared with `PATH Qiwa.Framework.Lib;`)
6
7
 
7
- ---
8
-
9
- ## Error Code Constants
8
+ To use any routine below from an application module, the app must reference the shared library **and** declare the path:
10
9
 
11
10
  ```esql
12
- -- Always use these constants, never hardcode error codes
13
- DECLARE ESB_SUCCESS_RESPONSE_CODE CONSTANT CHAR '00000000';
14
- DECLARE ESB_RUNTIME_TECHNICAL_ERROR_CODE CONSTANT CHAR '99999999';
15
- DECLARE ESB_MIDDLEWARE_DATABASE_ERROR_RESPONSE_CODE CONSTANT CHAR 'E0199998';
11
+ BROKER SCHEMA com.qiwa.esb.<package>
12
+ PATH Qiwa.Framework.Lib; -- required to resolve these routines
16
13
  ```
17
14
 
18
- Backend-specific error code ranges are also definedread `ErrorHandler.esql` for the full list per backend system.
15
+ > **Calling convention matters.** Most routines here are `CREATE FUNCTION` and return a value call them **inline** (`SET x = Fn(...)`), not with `CALL`. Only the `CREATE PROCEDURE` routines (marked below) are invoked with `CALL`. The signatures below are the real ones from source — do not guess parameters.
19
16
 
20
17
  ---
21
18
 
22
- ## Key Functions
19
+ ## Constants
20
+
21
+ All ESB codes are declared `EXTERNAL CHARACTER` (user-defined properties — overridable per-deploy via the BAR/`.properties`, **not** `CONSTANT`). Read them by name; never hardcode the literals.
22
+
23
+ | Constant | Value | Meaning |
24
+ |---|---|---|
25
+ | `ESB_SUCCESS_RESPONSE_CODE` | `'00000000'` | Success |
26
+ | `ESB_RUNTIME_TECHNICAL_ERROR_CODE` | `'99999999'` | Generic runtime/technical error |
27
+ | `ESB_MIDDLEWARE_RUNTIME_ERROR_RESPONSE_CODE` | `'99999999'` | Middleware runtime error |
28
+ | `ESB_MIDDLEWARE_DATABASE_ERROR_RESPONSE_CODE` | `'E0199998'` | Middleware DB error |
29
+ | `ESB_MIDDLEWARE_IN_ACTIVE_CHANNEL_RESPONSE_CODE` | `'E9009999'` | Channel inactive |
30
+ | `ESB_MIDDLEWARE_NOT_EXIST_CHANNEL_RESPONSE_CODE` | `'55555555'` | Channel not found |
31
+ | `ESB_MIDDLEWARE_UN_AUTHORIZED_OPERATION_RESPONSE_CODE` | `'44444444'` | Channel not authorized for the service |
32
+ | `ESB_EMPTY_HEADER_RESPONSE_CODE` | `'E5500003'` | Empty/missing header |
33
+ | `ESB_WS_ADAPTER_GATEWAY_RS_FLOW_QUEUE` | `'ESB.WS.OUT'` | WS adapter response-flow queue |
34
+ | `Billing_TIMEOUT` | `'1000'` | Billing timeout (ms) |
35
+ | `Billing_NOREPLYCODE` | `'NOREPLY'` | Billing no-reply marker |
36
+ | `DATABASE_SCHEMA_NAME` | `'dbo'` | DB schema prefix used in SQL |
37
+ | `MCR_DSN` | `'MWMCR_DS'` | ODBC DSN for all `PASSTHRU` calls |
38
+ | `AUDIT_SCHEMA_NAME` | `'MCR_AUDIT'` | Audit schema |
39
+ | `CR` | `X'0A'` as char | Newline char |
40
+
41
+ Plain (non-EXTERNAL) DB error constants:
42
+
43
+ | Constant | Value | Meaning |
44
+ |---|---|---|
45
+ | `MCRDBTIMEOUTORDEADLOCKERROR` | `'E0500000'` | SQLCODE −913/−911 (timeout/deadlock) |
46
+ | `MCRDBGENERALERROR` | `'E0599999'` | Any other SQL error |
23
47
 
24
- ### Queue Routing
48
+ Prefer the getter functions over reading constants directly: `GetESBSuccessCode()`, `GetESBUnAuthorizedOperationCode()`, `GetESBInactiveChannelCode()`, `GetESBNotExistChannelCode()`, `GetWSAdapterRsFlowQueue()`, `GetESBCR_NEW_LINE()` — each `RETURNS CHAR` of the corresponding constant.
49
+
50
+ ---
51
+
52
+ ## Queue Routing & Channel Lookups
25
53
 
26
54
  ```esql
27
- -- Set request and response queues based on ServiceCode from message header
28
- -- Reads from MCR_CHANNESBFUNC_TBL database table
29
- CALL SetQueues(IN serviceCode CHARACTER, OUT requestQueue CHARACTER, OUT responseQueue CHARACTER);
55
+ -- Resolve request/response queues for the inbound message and wire them onto the
56
+ -- output environment + MQMD. Reads cache CacheQueueTable (loaded from
57
+ -- dbo.MCR_CHANNAUTHQUEUES_VIEW). Returns '' on success, or an ESB error code
58
+ -- (NOT_EXIST_CHANNEL / UN_AUTHORIZED_OPERATION) on failure.
59
+ CREATE FUNCTION SetQueues(IN rEsbXMLHeader REFERENCE,
60
+ INOUT rOutLocalEnv REFERENCE,
61
+ INOUT rOutRoot REFERENCE) RETURNS CHAR;
62
+ -- On success it sets:
63
+ -- rOutLocalEnv.Destination.MQ.DestinationData[1].queueName (request queue)
64
+ -- rOutRoot.MQMD.ReplyToQ (response queue)
65
+ -- rOutLocalEnv.MQ.GET.QueueName (response queue)
66
+
67
+ -- Output queue for a channel (from dbo.MCR_CHANN_TBL.OUTQUEUE), cached.
68
+ -- Defaults to 'ESBOUT' when not found.
69
+ CREATE FUNCTION getChannelOutQueue(IN ChannelId CHARACTER) RETURNS CHARACTER;
70
+
71
+ -- Numeric CHANNID for a channel name (from dbo.MCR_CHANN_TBL), cached.
72
+ CREATE FUNCTION getEsbChannelId(IN channelName CHARACTER) RETURNS INTEGER;
73
+
74
+ -- Same as above but reports DB failures: sets errorcode and returns 0 on error.
75
+ CREATE FUNCTION getEsbChannelIdWithError(IN channelName CHARACTER,
76
+ INOUT errorcode CHARACTER) RETURNS INTEGER;
77
+
78
+ -- Channel STATUS column (active/inactive flag) from dbo.MCR_CHANN_TBL.
79
+ CREATE FUNCTION getEsbChannelStatus(IN channelName CHARACTER) RETURNS INTEGER;
80
+
81
+ -- Non-cached CHANNID lookups (INTEGER and CHAR variants).
82
+ CREATE FUNCTION getChannelIDByName(IN channelName CHARACTER) RETURNS INTEGER;
83
+ CREATE FUNCTION getChannelIDFromChannelCode(IN channel CHARACTER) RETURNS CHARACTER;
84
+
85
+ -- Invalidate all SHARED routing/error caches (force reload on next call).
86
+ CREATE FUNCTION refreshESBRoutingCache();
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Correlation ID
30
92
 
31
- -- Get output queue for a specific channel
32
- CALL getChannelOutQueue(IN channelId CHARACTER, IN serviceCode CHARACTER, OUT outQueue CHARACTER);
93
+ ```esql
94
+ -- Build a 48-hex-digit correlation-id BLOB (channel prefix + transaction id +
95
+ -- optional offset). offset is the 3-char suffix used by the internal service
96
+ -- caller when one session calls several services; pass '' otherwise.
97
+ CREATE FUNCTION getChannelCorrelationID(IN ChannelId CHAR,
98
+ IN TransactionId CHAR,
99
+ IN offset CHAR) RETURNS BLOB;
33
100
  ```
34
101
 
35
- ### Correlation ID
102
+ ---
103
+
104
+ ## Database Access
36
105
 
37
106
  ```esql
38
- -- Generate a unique correlation ID for tracking this message across systems
39
- CALL getChannelCorrelationID(IN channelId CHARACTER, IN sessionId CHARACTER, OUT correlationId CHARACTER);
107
+ -- PASSTHRU a SELECT to Database.{MCR_DSN}; sets retRow to the result row.
108
+ -- Returns GetESBSuccessCode() on success, MCRDBTIMEOUTORDEADLOCKERROR on
109
+ -- SQLCODE -913/-911, MCRDBGENERALERROR otherwise. Also sets SHARED SQLErrorDesc.
110
+ CREATE FUNCTION MCRDB_Selection(IN sqlString CHAR, INOUT retRow REFERENCE) RETURNS CHAR;
40
111
 
41
- -- Get correlation ID from the ESB channel
42
- CALL getEsbChannelId(IN channelId CHARACTER, OUT esbChannelId CHARACTER);
112
+ -- Array variant: result rows land under retRow.val[].
113
+ CREATE FUNCTION MCRDB_Selection_Array(IN sqlString CHAR, INOUT retRow REFERENCE) RETURNS CHAR;
43
114
  ```
44
115
 
45
- ### Timestamp
116
+ > All DB access in this library uses `PASSTHRU(... TO Database.{MCR_DSN})` against schema `dbo`. The DSN `MWMCR_DS` must be configured on the integration server.
117
+
118
+ ---
119
+
120
+ ## Error-Code Descriptions
121
+
122
+ All three read the `dbo.ESB_ERROR_CODES` table (cached daily into SHARED rows):
46
123
 
47
124
  ```esql
48
- -- Get formatted timestamp string (ISO 8601)
49
- CALL GetTimestampFormat(OUT timestamp CHARACTER);
50
- -- Returns: '2024-01-15T14:30:00.000Z'
125
+ -- Look up English/Arabic description + status by ESB error code.
126
+ CREATE FUNCTION getEsbErrorCodeDescriptionFrom(IN ErrorCode CHARACTER,
127
+ OUT EnglishDescription CHAR, OUT ArabicDescription CHAR, OUT STATUS CHAR);
128
+
129
+ -- Channel-aware variant (takes ChannelID + ServiceCode).
130
+ CREATE FUNCTION getEsbChannlsErrorCodeDescriptionFrom(IN ErrorCode CHARACTER,
131
+ IN ChannelID CHAR, IN ServiceCode CHARACTER,
132
+ OUT EnglishDescription CHAR, OUT ArabicDescription CHAR, OUT STATUS CHAR);
133
+
134
+ -- Map a backend (BE_NAME/BE_CODE) error to the ESB code + descriptions.
135
+ CREATE FUNCTION getBackendEsb_MapErrorCode(IN BackendName CHARACTER,
136
+ IN BackendErrorCode CHARACTER, IN ChannelId CHARACTER,
137
+ OUT EnglishDescription CHAR, OUT ArabicDescription CHAR,
138
+ OUT STATUS CHAR, OUT ESB_CODE CHAR);
51
139
  ```
52
140
 
53
- ### Database Access
141
+ ---
142
+
143
+ ## Response Header Builders (PROCEDUREs — use `CALL`)
54
144
 
55
145
  ```esql
56
- -- Execute a SQL query with error handling
57
- -- DSN is configured at the integration node level
58
- CALL MCRDB_Selection(IN sqlQuery CHARACTER, OUT resultSet ROW);
146
+ -- Copy request-header fields to the response header and fill ResponseStatus
147
+ -- (Status/Code/ArabicMsg/EnglishMsg) from the ESB error code.
148
+ CALL Create_esbXML_Response_Header(esbResponseCode, RequestHeaderRef, ResponseHeaderRef);
149
+
150
+ -- Overload that derives ResponseStatus from a backend error code.
151
+ CALL Create_esbXML_Response_Header_Using_Backend_Code(BackEndName, BackEndCode,
152
+ RequestHeaderRef, ResponseHeaderRef);
153
+
154
+ -- Build the whole response skeleton: creates XMLNSC.<serviceResponseName>.Header
155
+ -- under outputRootRef from inputRootRef and fills it.
156
+ CALL CreateEsbXMLResponseHeaderFromRoot(esbResponseCode, inputRootRef, outputRootRef,
157
+ serviceResponseName);
158
+
159
+ -- Backend-code overload of the above.
160
+ CALL CreateEsbXMLResponseHeaderFromRootUsingBackendCode(BackEndName, BackEndCode,
161
+ inputRootRef, outputRootRef, serviceResponseName);
59
162
  ```
60
163
 
61
- ### Flow Name Utility
164
+ ---
165
+
166
+ ## Timestamp / Format Helpers
167
+
168
+ These return **format pattern strings** to use with `CAST(... AS CHAR FORMAT ...)` — they do **not** return a formatted value.
62
169
 
63
170
  ```esql
64
- -- Strip schema prefix from flow name for use in property lookups
65
- CALL getFlowNameWithouSchema(IN fullFlowName CHARACTER, OUT flowName CHARACTER);
66
- -- Input: 'Qiwa.BS_Account.GetAccountDetails'
67
- -- Output: 'GetAccountDetails'
171
+ CREATE FUNCTION GetTimestampFormat() RETURNS CHAR; -- 'yyyy-MM-dd HH:mm:ss.SSS'
172
+ CREATE FUNCTION GetOMNITimestampFormat() RETURNS CHAR; -- 'yyyy-MM-dd HH:mm:ss.SSSSS'
173
+ CREATE FUNCTION GetPCKGTimestampFormat() RETURNS CHAR; -- 'yyyyMMddHHmmss'
174
+ CREATE FUNCTION GetDateFormat() RETURNS CHAR; -- 'yyyy-MM-dd'
175
+ CREATE FUNCTION GetDefaultCharacterSet() RETURNS INTEGER; -- 1208 (UTF-8 CCSID)
176
+
177
+ -- e.g. format "now" as an ESB timestamp:
178
+ SET ResponseHeader.MWResponseTime = CAST(CURRENT_TIMESTAMP AS CHAR FORMAT GetTimestampFormat());
179
+
180
+ -- Reformat a date string from one pattern to another (NULL-safe).
181
+ CREATE FUNCTION FormatDate(IN inputDate CHARACTER, IN inFormat CHARACTER,
182
+ IN outFormat CHARACTER) RETURNS CHARACTER;
68
183
  ```
69
184
 
70
- ### Response Codes
185
+ ---
186
+
187
+ ## String / Numeric Helpers
71
188
 
72
189
  ```esql
73
- -- Get the standard success code
74
- CALL GetESBSuccessCode(OUT successCode CHARACTER);
75
- -- Returns: '00000000'
190
+ -- Insert a decimal point `point` digits from the right and cast to DECIMAL.
191
+ CREATE FUNCTION formatDecimal(IN amount CHARACTER, IN point CHARACTER) RETURNS CHARACTER;
192
+
193
+ -- Left-pad `id` with '0' to width `len`.
194
+ CREATE FUNCTION padding(IN id CHARACTER, IN len INTEGER) RETURNS CHARACTER;
195
+
196
+ -- Repeat a single char `len` times.
197
+ CREATE FUNCTION charseq(IN aChar CHAR, IN len INTEGER) RETURNS CHARACTER;
198
+
199
+ -- TRUE if the value casts to an integer.
200
+ CREATE FUNCTION IsNumber(IN AmtVal CHARACTER) RETURNS BOOLEAN;
201
+
202
+ -- nth delimited subfield (1-based), e.g. SelectSubField('a b c',' ',2) -> 'b'.
203
+ CREATE FUNCTION SelectSubField(SourceString CHAR, Delimiter CHAR,
204
+ TargetStringPosition INT) RETURNS CHAR;
205
+
206
+ -- Request name -> response name: 'XxRq' -> 'XxRs', else 'Xx' -> 'XxResponse'.
207
+ CREATE FUNCTION getServiceResponseName(IN requestName CHAR) RETURNS CHAR;
208
+
209
+ -- Split S on Delim into Env.Split.Array[1..n] (PROCEDURE — use CALL).
210
+ CALL Split(S, EnvRef, Delim);
76
211
 
77
- -- Get default character set
78
- CALL GetDefaultCharacterSet(OUT charset CHARACTER);
79
- -- Returns: 'UTF-8'
212
+ -- Last segment of the CURRENT flow's broker MessageFlowLabel, split on '.'.
213
+ -- Note: it reads MessageFlowLabel internally and writes Split results under
214
+ -- EnvRef; it does NOT take a flow-name string. Pass an Environment reference.
215
+ CREATE FUNCTION getFlowNameWithouSchema(IN EnvRef REFERENCE) RETURNS CHAR;
80
216
  ```
81
217
 
82
218
  ---
83
219
 
84
- ## Shared Row (In-Memory Cache)
220
+ ## Exception Parsing
85
221
 
86
222
  ```esql
87
- SHARED ROW CacheQueueTable;
223
+ -- Move CurrentError to the most relevant (deepest) exception in the list
224
+ -- (PROCEDURE — use CALL).
225
+ CALL GetLastException(CurrentErrorRef);
226
+
227
+ -- Walk ExceptionList and populate ErrorInfo with FLOW_NAME, NODE_NAME,
228
+ -- ERROR_TYPE, ERROR_TIME, ERROR_SEVERITY, ERROR_NUMBER, ERROR_DETAILS,
229
+ -- MSG_ID, MSG_DATA, CompleteErrorMsg (PROCEDURE — use CALL).
230
+ CALL PARSEExceptionList(InputExceptionList, ErrorInfoRef);
88
231
  ```
89
232
 
90
- `CacheQueueTable` is used by `SetQueues()` to cache queue routing lookups. It persists across message invocations within the same execution group do not clear it manually.
233
+ `Generic_Prepare_Fault` is a `CREATE COMPUTE MODULE` that builds a SOAP fault response from the exception list (uses `PARSEExceptionList`). Reference it as a node's compute module, not as a function.
91
234
 
92
235
  ---
93
236
 
94
- ## Database Tables Referenced
237
+ ## SHARED State (In-Memory Caches)
95
238
 
96
- | Table | Columns | Purpose |
239
+ Declared with `DECLARE <name> SHARED ROW;` (note the order — `DECLARE` first). These persist across invocations within an execution group; do not clear them manually (use `refreshESBRoutingCache()`):
240
+
241
+ `CacheQueueTable`, `CacheChannelOutQueues`/`...Time`, `CacheChannelIds`/`...Time`,
242
+ `CacheBackendMappedCodes`/`...Time` + `ErrorBERecord`,
243
+ `CacheESBCodesDescriptions`/`...Time` + `CashErrorRecord`,
244
+ `CacheESBChannelsCodesDescriptions`/`...Time` + `ErrorRecord`,
245
+ plus `SQLErrorDesc` (last SQL error text) and `DefaultCharacterSet` (1208).
246
+
247
+ ---
248
+
249
+ ## Database Objects Referenced
250
+
251
+ | Object | Columns used | Used by |
97
252
  |---|---|---|
98
- | `MCR_CHANNESBFUNC_TBL` | `ESBFUNCID`, `ESBFUNCNAME`, `REQUEST_QUEUE_NAME`, `RESPONSE_QUEUE_NAME` | Queue routing by service code |
99
- | `MCR_CHANNAUTH_TBL` | `CHANNID`, `ESBFUNCID` | Channel authorization check |
253
+ | `dbo.MCR_CHANNAUTHQUEUES_VIEW` | `ESBFUNCID`, `CHANNID`, `REQUEST_QUEUE_NAME`, `RESPONSE_QUEUE_NAME` | `SetQueues` |
254
+ | `dbo.MCR_CHANN_TBL` | `CHANNID`, `CHANNNAME`, `OUTQUEUE`, `STATUS` | `getChannelOutQueue`, `getEsbChannelId`, `getEsbChannelStatus`, `getChannelIDByName`, `getChannelIDFromChannelCode` |
255
+ | `dbo.ESB_ERROR_CODES` | `STATUS`, `CODE`, `CHANNID`, `AR_DESCRIPTION`, `EN_DESCRIPTION`, `BE_NAME`, `BE_CODE` | the three error-description functions |
256
+
257
+ All reached through `Database.{MCR_DSN}` (`MWMCR_DS`).
100
258
 
101
259
  ---
102
260
 
103
- ## Usage Pattern in ESQL
261
+ ## ESB Header Field Paths
104
262
 
105
- ```esql
106
- -- At top of your ESQL module, no explicit import needed —
107
- -- CommonUtils is part of the shared library automatically
108
-
109
- -- Example: get queues for this service
110
- DECLARE reqQueue CHARACTER;
111
- DECLARE resQueue CHARACTER;
112
- DECLARE serviceCode CHARACTER;
113
- SET serviceCode = InputRoot.XMLNSC.Root.Header.ServiceCode;
114
- CALL SetQueues(serviceCode, reqQueue, resQueue);
115
-
116
- -- Set output destination
117
- SET Environment.Destination.MQ.DestinationData.queueName = reqQueue;
118
-
119
- -- Example: generate correlation ID
120
- DECLARE corrId CHARACTER;
121
- CALL getChannelCorrelationID(
122
- InputRoot.XMLNSC.Root.Header.ChannelId,
123
- InputRoot.XMLNSC.Root.Header.SessionId,
124
- corrId
125
- );
126
- SET OutputRoot.MQMD.CorrelId = CAST(corrId AS BLOB CCSID 1208);
263
+ The ESB message wraps a service element whose name varies per service; the header lives **under that service element**, not a literal `Root`. Reading code uses `InputRoot.XMLNSC.*[<].Header.*` (first child = the service element); the response builders create `OutputRoot.XMLNSC.<serviceResponseName>.Header.*`.
264
+
265
+ Header fields populated/copied by the builders:
266
+
267
+ ```
268
+ .Header.TransactionId
269
+ .Header.ChannelId
270
+ .Header.SessionId
271
+ .Header.ServiceCode
272
+ .Header.RequestTime
273
+ .Header.MWRequestTime
274
+ .Header.MWResponseTime
275
+ .Header.DebugFlag
276
+ .Header.ChannelUserInfo.UserName
277
+ .Header.UDF
278
+ .Header.ResponseStatus.Status
279
+ .Header.ResponseStatus.Code
280
+ .Header.ResponseStatus.EnglishMsg
281
+ .Header.ResponseStatus.ArabicMsg
127
282
  ```
128
283
 
129
284
  ---
130
285
 
131
- ## Standard Header Field Paths
286
+ ## Usage Example
132
287
 
133
288
  ```esql
134
- -- Standard paths for common header fields
135
- InputRoot.XMLNSC.Root.Header.TransactionId
136
- InputRoot.XMLNSC.Root.Header.ChannelId
137
- InputRoot.XMLNSC.Root.Header.ServiceCode
138
- InputRoot.XMLNSC.Root.Header.SessionId
139
- InputRoot.XMLNSC.Root.Header.RequestTime
140
- InputRoot.XMLNSC.Root.Header.ChannelUserInfo.UserName
141
- InputRoot.XMLNSC.Root.Header.ChannelUserInfo.UserPassword -- ALWAYS MASK
142
- InputRoot.XMLNSC.Root.Header.ResponseStatus.Code
143
- InputRoot.XMLNSC.Root.Header.ResponseStatus.Status
144
- InputRoot.XMLNSC.Root.Header.ResponseStatus.EnglishMsg
145
- InputRoot.XMLNSC.Root.Body -- service-specific data
289
+ BROKER SCHEMA com.qiwa.esb.myservice
290
+ PATH Qiwa.Framework.Lib;
291
+
292
+ CREATE COMPUTE MODULE MyFlow_Compute
293
+ CREATE FUNCTION Main() RETURNS BOOLEAN
294
+ BEGIN
295
+ SET OutputRoot = InputRoot;
296
+
297
+ -- Header reference (service element is the first child under XMLNSC)
298
+ DECLARE inHdr REFERENCE TO InputRoot.XMLNSC.*[<].Header;
299
+
300
+ -- Route to the correct request/response queues
301
+ DECLARE rc CHAR;
302
+ SET rc = SetQueues(inHdr, OutputLocalEnvironment, OutputRoot);
303
+ IF rc <> GetESBSuccessCode() AND rc <> '' THEN
304
+ -- rc holds an ESB error code (e.g. not-exist / unauthorized channel)
305
+ RETURN TRUE;
306
+ END IF;
307
+
308
+ -- Generate a correlation id (no offset)
309
+ SET OutputRoot.MQMD.CorrelId =
310
+ getChannelCorrelationID(FIELDVALUE(inHdr.ChannelId), FIELDVALUE(inHdr.TransactionId), '');
311
+
312
+ RETURN TRUE;
313
+ END;
314
+ END MODULE;
146
315
  ```