如果dblookup介体放置在迭代介体之后,则不会执行它

时间:2016-10-03 16:38:09

标签: wso2esb

有没有人知道如果dblookup介体放在迭代介体之后并且这两个介体都包含在过滤器介体中,为什么不执行它?请参阅下面的代码段和相应的日志。提前谢谢。

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="DownloadSeq" onError="AppDefaultFailSeq"
      trace="disable" xmlns="http://ws.apache.org/ns/synapse">
      <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
      <dblookup description="DOWNLOAD FILES">
        <connection>
          <pool>
            <dsName>jdbc/dsName</dsName>
          </pool>
        </connection>
        <statement>
          <sql><![CDATA[some sql query]]></sql>
          <result column="id" name="fileId"/>
          <result column="file_name_pattern" name="fileNamePattern"/>
          <result column="uri" name="fileSource"/>
          <result column="file_dest" name="fileDest"/>
        </statement>
      </dblookup>
      <!-- CHECK TO SEE IF A RECORD IS RETURNED. EXIT IF NO RECORD RETURNED -->
      <filter xpath="boolean(get-property('fileId'))">
        <then>
          <fileconnector.search>
            <source>{$ctx:fileSource}</source>
            <filePattern>{$ctx:fileNamePattern}</filePattern>
            <recursiveSearch>False</recursiveSearch>
          </fileconnector.search>
          <log level="full"/>
          <property name="sequence" scope="default" type="STRING" value="after-smooks"/>
          <iterate expression="//ns:result/ns:file" xmlns:ns="http://org.wso2.esbconnectors.FileConnector">
            <target>
              <sequence>
                <log level="full"/>
                <property expression="//ns:file" name="fileName"
                  scope="default" type="STRING"/>
                <!-- DOWNLOAD THE FILE -->
                <fileconnector.move>
                  <source>{$ctx:fileSource}</source>
                  <destination>{$ctx:fileDest}</destination>
                </fileconnector.move>
              </sequence>
            </target>
          </iterate>
          <!-- UPDATE STATUS AS 'P' -->
          <dblookup description="Update status to P">
            <connection>
              <pool>
                <dsName>jdbc/dsName</dsName>
              </pool>
            </connection>
            <statement>
              <sql><![CDATA[some SQL statement]]></sql>
              <parameter expression="get-property('fileId')" type="INTEGER"/>
              <parameter type="CHAR" value="P"/>
            </statement>
          </dblookup>
          <drop/>
        </then>
        <else>
          <drop/>
        </else>
      </filter>
    </sequence>

从日志文件中:

TID: [-1234] [] [2016-10-03 10:48:00,848] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  Start : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:00,849] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  invoking : class org.wso2.carbon.connector.FileMove.mediate() {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:01,396] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  End : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:01,397] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} -  End : Sequence <anonymous> {org.apache.synapse.mediators.base.SequenceMediator}

但是,如果我将dblookup介体放在迭代器介体中,它将按预期工作。请参阅下面的相应日志。

TID: [-1234] [] [2016-10-03 10:33:01,037] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  Start : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,038] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  invoking : class org.wso2.carbon.connector.FileMove.mediate() {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,525] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} -  End : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Start : DBLookup mediator {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Getting a connection from DataSource jdbc/dsName and preparing statement : SELECT update_file_status(?,?) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Setting as parameter : 1 value : 16 as JDBC Type : 4(see java.sql.Types for valid types) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Setting as parameter : 2 value : P as JDBC Type : 1(see java.sql.Types for valid types) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Successfully prepared statement : SELECT update_file_status(?,?) against DataSource : jdbc/dsName {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,527] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  Processing the first row returned : SELECT update_file_status(?,?) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,527] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} -  End : DBLookup mediator {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,528] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} -  End : Sequence <anonymous> {org.apache.synapse.mediators.base.SequenceMediator}

1 个答案:

答案 0 :(得分:1)

在迭代介体中,使用属性continueParent="true"