In WSO2 ESB, during
JMS messaging, if the session transacted is enabled at axis2.xml,
then when there is a exception occurred at the axiom level of WSO2
ESB, due to invalid message format, then the fault sequence of the
synapse level will not be invoked and as the session transacted
enabled, the message will be sent back to the IBM MQ queue. Due to
that there will be a looping will start to occur at ESB.
Based on the current
implementation it's not possible to handle this exception in WSO2 ESB
side and the available option is to use the poison messaging [1] [2]
in IBM MQ.
1) Go to bin directory of IBM MQ installation. In our case it is /opt/mqm/bin.
2) Execute ./runmqsc ESBQManager and enter into command line.
3) Issue the command - display queue (LOCALQUEUE4) : Here LOCALQUEUE4 is the queue which listened by ESB.
4) You will get displayed with the below:
2) Execute ./runmqsc ESBQManager and enter into command line.
3) Issue the command - display queue (LOCALQUEUE4) : Here LOCALQUEUE4 is the queue which listened by ESB.
4) You will get displayed with the below:
mqm@esbsupport-Latitude-E5450:/opt/mqm/bin$ ./runmqsc ESBQManager 5724-H72 (C) Copyright IBM Corp. 1994, 2015. Starting MQSC for queue manager ESBQManager. display queue(LOCALQUEUE4) 1 : display queue(LOCALQUEUE4) AMQ8409: Display Queue details. QUEUE(LOCALQUEUE4) TYPE(QLOCAL) ACCTQ(QMGR) ALTDATE(2016-10-06) ALTTIME(21.26.43) BOQNAME( ) BOTHRESH(0) CLUSNL( ) CLUSTER( ) CLCHNAME( ) CLWLPRTY(0) CLWLRANK(0) CLWLUSEQ(QMGR) CRDATE(2016-10-06) CRTIME(21.26.43) CURDEPTH(1) CUSTOM( ) DEFBIND(OPEN) DEFPRTY(0) DEFPSIST(NO) DEFPRESP(SYNC) DEFREADA(NO) DEFSOPT(SHARED) DEFTYPE(PREDEFINED) DESCR( ) DISTL(NO) GET(ENABLED) HARDENBO INITQ( ) IPPROCS(0) MAXDEPTH(5000) MAXMSGL(4194304) MONQ(QMGR) MSGDLVSQ(PRIORITY) NOTRIGGER NPMCLASS(NORMAL) OPPROCS(0) PROCESS( ) PUT(ENABLED) PROPCTL(COMPAT) QDEPTHHI(80) QDEPTHLO(20) QDPHIEV(DISABLED) QDPLOEV(DISABLED) QDPMAXEV(ENABLED) QSVCIEV(NONE) QSVCINT(999999999) RETINTVL(999999999) SCOPE(QMGR) SHARE STATQ(QMGR) TRIGDATA( ) TRIGDPTH(1) TRIGMPRI(0) TRIGTYPE(FIRST) USAGE(NORMAL)
5) You can see BOTHRESH(0) and BOQNAME( ) these are the parameters we set to send the poison ack. You can refer [1] [2] for more details.
6) Execute the below command
ALTER QLOCAL(LOCALQUEUE4) BOTHRESH(4) BOQNAME(DLQ4)
Here, BOTHRESH(4) - is the backout threshhold value, which is used to set that after 4-attempts the message will be put to backout queue defined in BOQNAME(DLQ4).
7) After execute the command do a check and you will find the below:
ALTER QLOCAL(LOCALQUEUE4) BOTHRESH(4) BOQNAME(DLQ4) 3 : ALTER QLOCAL(LOCALQUEUE4) BOTHRESH(4) BOQNAME(DLQ4) AMQ8008: WebSphere MQ queue changed. display queue(LOCALQUEUE4) 4 : display queue(LOCALQUEUE4) AMQ8409: Display Queue details. QUEUE(LOCALQUEUE4) TYPE(QLOCAL) ACCTQ(QMGR) ALTDATE(2016-10-06) ALTTIME(21.55.26) BOQNAME(DLQ4) BOTHRESH(4) CLUSNL( ) CLUSTER( ) CLCHNAME( ) CLWLPRTY(0) CLWLRANK(0) CLWLUSEQ(QMGR) CRDATE(2016-10-06) CRTIME(21.26.43) CURDEPTH(0) CUSTOM( ) DEFBIND(OPEN) DEFPRTY(0) DEFPSIST(NO) DEFPRESP(SYNC) DEFREADA(NO) DEFSOPT(SHARED) DEFTYPE(PREDEFINED) DESCR( ) DISTL(NO) GET(ENABLED) HARDENBO INITQ( ) IPPROCS(0) MAXDEPTH(5000) MAXMSGL(4194304) MONQ(QMGR) MSGDLVSQ(PRIORITY) NOTRIGGER NPMCLASS(NORMAL) OPPROCS(0) PROCESS( ) PUT(ENABLED) PROPCTL(COMPAT) QDEPTHHI(80) QDEPTHLO(20) QDPHIEV(DISABLED) QDPLOEV(DISABLED) QDPMAXEV(ENABLED) QSVCIEV(NONE) QSVCINT(999999999) RETINTVL(999999999) SCOPE(QMGR) SHARE STATQ(QMGR) TRIGDATA( ) TRIGDPTH(1) TRIGMPRI(0) TRIGTYPE(FIRST) USAGE(NORMAL)
8) Send a invalid message, here used the IBM MQ GUI to put the message into LOCALQUEUE4. Make sure in axis2.xml the session transacted enabled.
<parameter name="transport.jms.SessionTransacted">true</parameter>
Proxy Service Used for this sample:
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="MyJMSProxyUnformattedMSG2" transports="jms" startOnLoad="true" trace="disable"> <description/> <target> <inSequence> <log level="custom"> <property name="STATUS" value="----------------MyJMSProxyUnformattedMSG Invoked-------------------"/> </log> <log level="full"/> <drop/> </inSequence> </target> <parameter name="transport.jms.Destination">LOCALQUEUE4</parameter> <parameter name="transport.jms.ContentType">application/xml</parameter> </proxy>
The payload put into the queue.
<soapenv:Envelope><soapenv:Header/><soapenv:Body><echo:echoString><in>test</in></echo:echoString></soapenv:Body></soapenv:Envelope>
9) Below is the extracted log after invalid soap message put into queue. You can see after 4-attempts the transaction rolled back. And when you observe the message is transferred to DLQ4.
[2016-10-06 22:01:09,299] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:09,814] DEBUG - JMSMessageReceiver Received new JMS message for service :MyJMSProxyUnformattedMSG2 Destination : null Message ID : ID:414d5120455342514d616e6167657220ce62f65702180120 Correlation ID : null ReplyTo : null Redelivery ? : false Priority : 0 Expiration : 0 Timestamp : 1475771469790 Message Type : null Persistent ? : false [2016-10-06 22:01:09,834] ERROR - JMSMessageReceiver Unknown error processing message org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566) at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:54) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:70) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:76) at org.apache.axis2.transport.jms.JMSUtils.setSOAPEnvelope(JMSUtils.java:172) at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:195) at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:575) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:468) at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606) at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479) at com.ctc.wstx.sr.InputElementStack.resolveAndValidateElement(InputElementStack.java:507) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2977) at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2098) at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2078) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134) at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225) at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34) at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214) ... 16 more [2016-10-06 22:01:09,837] DEBUG - ServiceTaskManager Session for message : ID:414d5120455342514d616e6167657220ce62f65702180120 rolled back [2016-10-06 22:01:09,837] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:09,849] DEBUG - JMSMessageReceiver Received new JMS message for service :MyJMSProxyUnformattedMSG2 Destination : null Message ID : ID:414d5120455342514d616e6167657220ce62f65702180120 Correlation ID : null ReplyTo : null Redelivery ? : true Priority : 0 Expiration : 0 Timestamp : 1475771469790 Message Type : null Persistent ? : false [2016-10-06 22:01:09,850] ERROR - JMSMessageReceiver Unknown error processing message org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566) at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:54) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:70) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:76) at org.apache.axis2.transport.jms.JMSUtils.setSOAPEnvelope(JMSUtils.java:172) at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:195) at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:575) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:468) at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606) at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479) at com.ctc.wstx.sr.InputElementStack.resolveAndValidateElement(InputElementStack.java:507) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2977) at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2098) at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2078) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134) at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225) at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34) at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214) ... 16 more [2016-10-06 22:01:09,851] DEBUG - ServiceTaskManager Session for message : ID:414d5120455342514d616e6167657220ce62f65702180120 rolled back [2016-10-06 22:01:09,851] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:09,851] DEBUG - JMSMessageReceiver Received new JMS message for service :MyJMSProxyUnformattedMSG2 Destination : null Message ID : ID:414d5120455342514d616e6167657220ce62f65702180120 Correlation ID : null ReplyTo : null Redelivery ? : true Priority : 0 Expiration : 0 Timestamp : 1475771469790 Message Type : null Persistent ? : false [2016-10-06 22:01:09,852] ERROR - JMSMessageReceiver Unknown error processing message org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566) at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:54) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:70) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:76) at org.apache.axis2.transport.jms.JMSUtils.setSOAPEnvelope(JMSUtils.java:172) at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:195) at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:575) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:468) at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606) at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479) at com.ctc.wstx.sr.InputElementStack.resolveAndValidateElement(InputElementStack.java:507) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2977) at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2098) at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2078) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134) at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225) at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34) at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214) ... 16 more [2016-10-06 22:01:09,853] DEBUG - ServiceTaskManager Session for message : ID:414d5120455342514d616e6167657220ce62f65702180120 rolled back [2016-10-06 22:01:09,853] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:09,853] DEBUG - JMSMessageReceiver Received new JMS message for service :MyJMSProxyUnformattedMSG2 Destination : null Message ID : ID:414d5120455342514d616e6167657220ce62f65702180120 Correlation ID : null ReplyTo : null Redelivery ? : true Priority : 0 Expiration : 0 Timestamp : 1475771469790 Message Type : null Persistent ? : false [2016-10-06 22:01:09,854] ERROR - JMSMessageReceiver Unknown error processing message org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570) at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566) at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:54) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:70) at org.apache.axis2.format.TextMessageBuilderAdapter.processDocument(TextMessageBuilderAdapter.java:76) at org.apache.axis2.transport.jms.JMSUtils.setSOAPEnvelope(JMSUtils.java:172) at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:195) at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:575) at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:468) at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "soapenv" at [row,col {unknown-source}]: [1,18] at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606) at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479) at com.ctc.wstx.sr.InputElementStack.resolveAndValidateElement(InputElementStack.java:507) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2977) at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2098) at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2078) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134) at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225) at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34) at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214) ... 16 more [2016-10-06 22:01:09,857] DEBUG - ServiceTaskManager Session for message : ID:414d5120455342514d616e6167657220ce62f65702180120 rolled back [2016-10-06 22:01:09,857] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:10,862] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:11,863] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:12,864] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms [2016-10-06 22:01:13,864] DEBUG - ServiceTaskManager Waiting for a message for service : MyJMSProxyUnformattedMSG2 - duration : 1000ms
No comments:
Post a Comment