2014-03-24 58 views
1

我正在使用以下ESQL代碼將非xml消息(到達輸入隊列)放入審計數據庫(Oracle 10g)中作爲BLOB對象。 當我在IBM WebSphere Message Broker 6.0中使用它時,代碼正在工作。但是最近我遷移到IBM WebSphere Message Broker 7.0,現在非xml消息轉到Backout隊列,而不是被審計到數據庫中。 爲子流的ESQL代碼(即寫入非XML消息到分貝)我使用的是:無法寫入到達MQ隊列的非XML消息到數據庫中

CREATE COMPUTE MODULE "WriteNonXMLToAudit_1_0_WriteNonXMLToAudit" 
CREATE FUNCTION main() RETURNS BOOLEAN BEGIN 
    SET OutputRoot = InputRoot; 

    DECLARE ver CHAR; 
    DECLARE codeName CHAR; 

    SET ver = '1_0_2'; 
    SET codeName = 'WriteNonXMLToAudit.' || 'Version:' || ver; 

    DECLARE aonMSG REFERENCE To "OutputRoot"."BLOB"; 
    DECLARE appError REFERENCE To InputExceptionList; 

    DECLARE msid INTEGER; 
    DECLARE messageType CHAR; 

    DECLARE sourceApplication CHAR; 

    DECLARE mqHdrBlob BLOB; 
    DECLARE mqHdrChar CHAR; 

    DECLARE msgBlob BLOB; 
    DECLARE msgChar CHAR; 
    DECLARE msgUUID CHAR; 

    SET OutputRoot.MQMD.Format = 'MQSTR '; 
    SET OutputRoot.MQMD.CodedCharSetId = 819; 
    SET OutputRoot.MQMD.Encoding = 273; 
    SET OutputRoot."MQRFH2" = NULL; 

    MOVE aonMSG TO "OutputRoot"."BLOB"; 

    SET msgChar = aonMSG; 

    SET messageType = 'NON_STANDARD_MESSAGE'; 
    SET msid = 9998; 

    SET msgUUID = UUIDASCHAR; 
    SET sourceApplication = RTRIM(OutputRoot.MQMD.PutApplName); 

    SET msgChar = CAST(OutputRoot."BLOB"."BLOB" As CHAR CCSID 819 ENCODING OutputRoot.MQMD.Encoding); 

    Insert Into Database.Message_Audit (UUID, MSID, Message_Type, Source_Application, Message_Body) 
    Values (SUBSTRING(msgUUID FROM 1 FOR 35), 
    msid, 
    SUBSTRING(messageType FROM 1 FOR 29), 
    SUBSTRING(sourceApplication FROM (LENGTH(sourceApplication) - 9) FOR 10), 
    msgChar); 

    IF SQLCODE <> 0 THEN 
     RETURN FALSE; 
    END IF; 

    RETURN TRUE; 

END; 

END MODULE; 

主流程如下:

CREATE COMPUTE MODULE "ACIF_AUDIT_1_5_Insert exception into msg" 
CREATE FUNCTION main() RETURNS BOOLEAN BEGIN 
SET OutputRoot = InputRoot; 


CREATE FIRSTCHILD OF OutputRoot.XML.MSG.APP_DATA Name 'APP_ERROR'; 
CREATE LASTCHILD OF OutputRoot.XML.MSG.APP_DATA.APP_ERROR Name 'ERROR_SOURCE' VALUE 

'ACIFBROKER'; 
CREATE LASTCHILD OF OutputRoot.XML.MSG.APP_DATA.APP_ERROR Name 'ERROR_OPERATION' VALUE 'ACIF_AUDIT_Exception'; 
CREATE LASTCHILD OF OutputRoot.XML.MSG.APP_DATA.APP_ERROR Name 'ERROR_CODE' VALUE ''; 
CREATE LASTCHILD OF OutputRoot.XML.MSG.APP_DATA.APP_ERROR Name 'ERROR_STRING'; 
Set OutputRoot.XML.MSG.APP_DATA.APP_ERROR.ERROR_STRING = InputExceptionList; 
CREATE LASTCHILD OF OutputRoot.XML.MSG.APP_DATA.APP_ERROR Name 'ERROR_DETAIL' VALUE 'Exception List'; 

SET OutputRoot."MQRFH2" = NULL; 
SET OutputRoot.MQMD.CodedCharSetId = MQCCSI_INHERIT; /*819*/ 
SET OutputRoot.MQMD.Encoding = MQENC_NATIVE;   /*273*/ 
Set OutputRoot.MQMD.Format = 'MQSTR'; 


RETURN true; 
END; 

END MODULE; 
CREATE COMPUTE MODULE "ACIF_AUDIT_1_5_Insert audit record" 
CREATE FUNCTION main() RETURNS BOOLEAN BEGIN 
SET OutputRoot = InputRoot; 


Declare refAONDataRoot  REFERENCE To InputBody.MSG; 
Declare refSOAPDataRoot  REFERENCE TO InputBody."SOAP-ENV:Envelope"; 
Declare MSGChar   CHAR; 
Declare MSGBlob   BLOB; 
DECLARE intSQLCode  INTEGER; 
DECLARE chrSQLErrorText  CHAR; 

/* Added by Shailen **/ 
DECLARE uuid  CHAR; 
DECLARE msid  INT; 
DECLARE mType  CHAR; 
DECLARE srcApp  CHAR; 
Declare msgRef  REFERENCE TO InputBody; 

If FIELDNAME(refAONDataRoot.AONHEADER) = 'AONHEADER' Then 

    Set MSGBlob = BITSTREAM(refAONDataRoot); 
    Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId); 
    Set msid = refAONDataRoot.AONHEADER.MSID; 

    IF refAONDataRoot.APP_DATA.APP_HEADER.UUID IS NOT NULL THEN 
     SET uuid = refAONDataRoot.APP_DATA.APP_HEADER.UUID; 
    ELSE 
     /* Let check for MESSAGE_ID - BRIDGE Messages */ 
     IF FIELDNAME(refAONDataRoot.APP_DATA.AON_APPLICATION_MESSAGE.HEADER.MESSAGE_ID) IS NOT NULL THEN 
      SET uuid = refAONDataRoot.APP_DATA.AON_APPLICATION_MESSAGE.HEADER.MESSAGE_ID; 
      SET msid = 9999; 
     END IF; 
    END IF; 

IF FIELDNAME(refAONDataRoot.APP_DATA.APP_HEADER.MESSAGE_TYPE) IS NOT NULL THEN 
    SET mType = refAONDataRoot.APP_DATA.APP_HEADER.MESSAGE_TYPE; 
ELSE 
    /* Let check another location - historical message type location */ 
    IF 

FIELDNAME(refAONDataRoot.APP_DATA.AON_APPLICATION_MESSAGE.HEADER.MESSAGE_TYPE) IS NOT NULL THEN 
      SET mType = refAONDataRoot.APP_DATA.AON_APPLICATION_MESSAGE.HEADER.MESSAGE_TYPE; 
     END IF; 
    END IF; 

    Insert Into Database.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY) 
    Values (uuid,msid,mType,refAONDataRoot.AONHEADER.APPLICATION_NAME,'',MSGChar); 

/* 08-11-2004:The following assumes that the flow will throw an error on an database error. 
* As part of this change the flow is being changed to do this, otherwise the message is just thrown away. 

RETURN FALSE; 
*/ 
ElseIf FIELDNAME(refSOAPDataRoot."SOAP-ENV:Header") = 'SOAP-ENV:Header' Then 

    Set MSGBlob = BITSTREAM(refSOAPDataRoot); 
    Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId); 

    Insert Into Database.MQUSER.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY) 
    Values (refSOAPDataRoot."SOAP-ENV:Header".MessageHeader.uuid,'',refSOAPDataRoot."SOAP-ENV:Header".MessageHeader.messageType,'','',MSGChar); 
    /* 08-11-2004:The following assumes that the flow will throw an error on an database error. 
* As part of this change the flow is being changed to do this, otherwise the message is just thrown away. 
RETURN FALSE; 
*/ 
ElseIf FIELDNAME(InputBody.AON_APPLICATION_MESSAGE) IS NOT NULL Then 
    /* This is to audit the message from AME to bridge. 
    * The MESSAGE ID is effectively the UUID for this message. 
    */ 
    MOVE msgRef TO InputBody.AON_APPLICATION_MESSAGE; 
    Set MSGBlob = BITSTREAM(msgRef); 
    Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId); 

    Set msid = '9999'; 
    Set mType = 'Unset'; 
    Set srcApp = 'Unset'; 

    IF FIELDNAME(msgRef.HEADER.MESSAGE_ID) IS NOT NULL THEN 
     SET uuid = msgRef.HEADER.MESSAGE_ID; 
    END IF; 

    IF FIELDNAME(msgRef.HEADER.MSID) IS NOT NULL THEN 
     SET msid = CAST(msgRef.HEADER.MSID AS INT); 
    END IF; 

    IF FIELDNAME(msgRef.HEADER.MESSAGE_TYPE) IS NOT NULL THEN 
     SET mType = msgRef.HEADER.MESSAGE_TYPE; 
    END IF; 

    IF FIELDNAME(msgRef.HEADER.SENDER) IS NOT NULL THEN 
     SET srcApp = msgRef.HEADER.SENDER; 
    END IF; 

    Insert Into Database.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY) 
    Values (uuid,msid,mType,srcApp,'',MSGChar); 

    /* 08-11-2004:The following assumes that the flow will throw an error on an database error. 
    * As part of this change the flow is being changed to do this, otherwise the message is just thrown away. 
    RETURN FALSE; 
    */ 
ElseIf FIELDNAME(InputBody.msg.header.application_name) IS NOT NULL Then 
    /* Then assume this is an ATLAS message. 
    * The MESSAGE ID is effectively the UUID for this message. 
    */ 
    MOVE msgRef TO InputBody.msg; 
    Set MSGBlob = BITSTREAM(msgRef); 
    Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId); 

    Set srcApp = msgRef.header.application_name; 

    IF FIELDNAME(msgRef.header.msid) IS NOT NULL Then 
     Set msid = msgRef.header.msid; 
    ELSE 
     Set msid = '9997'; 
    END IF; 

    Set mType = 'Unset:ATLAS_MESSAGE'; 
    Set uuid = UUIDASCHAR; 

    Insert Into Database.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY) 
    Values (uuid,msid,mType,srcApp,'',MSGChar); 

    /* 08-11-2004:The following assumes that the flow will throw an error on an database error. 
    * As part of this change the flow is being changed to do this, otherwise the message is just thrown away. 
    RETURN FALSE; 
    */  
Else 
    /* We have an XML message, but we do not know what it is. Lets treat is a a NONXML Message. 
    */ 
    RETURN TRUE; 
End If; 

/* 
* Return FALSE - this means that everything was okay in this case. We have wired up the TRUE terminal to handle the case when we have 
* an XML message, but one that is not recognised. NB Non XML messages will cause an error because the MQINPUT node is expecting an XML 
* message. 
*/ 
RETURN FALSE; 

END; 

END MODULE; 

代理日誌:

Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2232E: Error detected whilst handling a previous error in node 'ACIF_AUDIT_1_5.ACIF_ERROR_01'. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbDataFlowNode.cpp: 893: ImbDataFlowNode::logExceptionList: ComIbmMQOutputNode: ACIF_AUDIT_1_5#FCMComposite_1_2 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2230E: Error detected whilst processing a message in node 'ACIF_AUDIT_1_5.Insert audit record'. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbComputeNode.cpp: 489: ImbComputeNode::evaluate: ComIbmComputeNode: ACIF_AUDIT_1_5#FCMComposite_1_4 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2488E: (.ACIF_AUDIT_1_5_Insert audit record.main, 16.1) Error detected whilst executing the SQL statement 'DECLARE refAONDataRoot REFERENCE TO InputBody.MSG;'. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp: 643: SqlStatementGroup::execute: ComIbmComputeNode: ACIF_AUDIT_1_5#FCMComposite_1_4 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2498E: (.ACIF_AUDIT_1_5_Insert audit record.main, 16.39) : An error occurred when navigating to path element '2' of the field reference at the given location. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbRdl/ImbRdlFieldRef.cpp: 1916: SqlFieldReference::navigateAbsoluteToFirst: ComIbmComputeNode: ACIF_AUDIT_1_5#FCMComposite_1_4 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP5009E: XML Parsing Errors have occurred. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/MTI/MTIforBroker/GenXmlParser2/XmlImbParser.cpp: 720: XmlImbParser::parseRightSibling: : 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP5004E: An XML parsing error 'Invalid character (Unicode: 0x2) ' occurred on line 1 column 441 when parsing element 'app_data'. Internal error codes are '196' and ''. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/MTI/MTIforBroker/GenXmlParser2/XmlBrokerAsgardParser.cpp: 730: XmlBrokerAsgardParser::error: : 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2628E: Exception condition detected on input node 'ACIF_AUDIT_1_5.ACIF_AUDIT_01'. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbCommonInputNode.cpp: 1912: ImbCommonInputNode::run: ComIbmMQInputNode: ACIF_AUDIT_1_5#FCMComposite_1_5 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2230E: Error detected whilst processing a message in node 'ACIF_AUDIT_1_5.ACIF_ERROR_01'. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/DataFlowEngine/ImbMqOutputNode.cpp: 864: ImbMqOutputNode::evaluate: ComIbmMQOutputNode: ACIF_AUDIT_1_5#FCMComposite_1_2 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP5010E: XML Writing Errors have occurred. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/MTI/MTIforBroker/GenXmlParser2/XmlImbParser.cpp: 443: XmlImbParser::refreshBitStreamFromElementsInner: ComIbmMQInputNode: ACIF_AUDIT_1_5#FCMComposite_1_5 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP5005E: There are 2 top level elements 'msg,MSG' in the document. : UKS06.7aaf0524-3801-0000-0080-9e3a13c0b2a4: /build/S700_P/src/MTI/MTIforBroker/GenXmlParser2/XmlImbParser.cpp: 954: XmlImbParser::checkForBodyElement: : 
Mar 25 14:50:31 ukvmgstg008 WebSphere Broker v7005[15195]: (UKS06.CONCERT_001)[7]BIP2648E: Message backed out to a queue; node 'ACIF_AUDIT_1_5.ACIF_AUDIT_01'. : UKS06.d0420624-3801-0000-0080-83fda0200698: /build/S700_P/src/DataFlowEngine/ImbMqInputNode.cpp: 2122: ImbCommonInputNode::eligibleForBackout: ComIbmMQInputNode: ACIF_AUDIT_1_5#FCMComposite_1_5 

回答

2

您需要弄清例外列表,找出導致故障的根本原因。如果您沒有失敗終端,錯誤消息將位於系統日誌/事件查看器中。

如果您有錯誤處理,但是您需要確保以合適的方式處理例外列表以報告異常的根本原因。

如果您真的陷入困境,您可以嘗試進行用戶跟蹤並跟蹤受影響的計算節點的執行情況,以嘗試找出故障點。

如果問題是db或db驅動程序問題,則引發的BIP消息應該有一個SQLState和本地錯誤代碼,您可以在db供應商文檔中引用它。

+0

我在經紀日誌中找到了這個: – HyperioN

1

從您的日誌中,我們看到: BIP5005E:文檔中有2個頂級元素「味精,味精」。

有效的XML消息只能有一個頂級元素。我假設你是一個錯字。正確並重試。

提供的日誌顯示您的ESQL沒有問題,只有XML解析。這可能會阻止其他流程運行,或按預期運行。用戶跟蹤將比您的經紀人日誌更有價值。

+0

嗨,感謝您的回覆。 – HyperioN

+0

通過發送應用程序放入隊列的XML消息只有一個頂級標記,即,但是如果您在Mainflow中看到的代碼是: – HyperioN

+0

聲明refAONDataRoot REFERENCE To InputBody.MSG; – HyperioN

相關問題