2

ファイルを外部 Web サービスに送信する必要があります。応答が の1場合、ファイルは削除する必要があります。それ以外の場合、ファイルは保持する必要があります。

ファイル コネクタを使用してファイルを送信し、レコードを Oracle に挿入します。ファイルが送信されるとき、キーはファイル接続のメッセージ ID です。応答が戻ってきたときにこの ID を使用してレコードを更新できるように、メッセージ ID を保持したいと考えています。

MessagePropertiesTransformer を使用してカスタム プロパティを追加しようとしましたが、応答で保持されません。メッセージIDを保持する方法はありますか?

私の設定:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:file="http://www.mulesoft.org/schema/mule/file"
      xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
      xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
      xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
          http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
          http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.1/mule-cxf.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.1/mule-jdbc.xsd
          http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd  
          ">    
  <spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
    <spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/>
    <spring:property name="url" value="jdbc:oracle:thin:user/pass@ip:1521:orcl"/>
  </spring:bean>
  <file:connector name="output" outputAppend="true" outputPattern="#[function:datestamp]-#[header:originalFilename]" />
  <file:connector name="input" streaming="false" recursive="true" autoDelete="false"> 

          <service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" /> 

  </file:connector>
        <jdbc:connector name="jdbcConnector" pollingFrequency="10000" dataSource-ref="jdbcDataSource">
           <jdbc:query key="outboundInsertStatement"
              value="INSERT INTO TEST_MESSAGE (message_id, filename, done) VALUES (#[message:id], 
                    #[header:originalFilename], #[string:0])"/>
        </jdbc:connector> 
        <mulexml:namespace-manager includeConfigNamespaces="true">
                <mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/>
                <mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/>
                <mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/>
                <mulexml:namespace prefix="fullmodel" uri="iesb.dongfang.com"/>
        </mulexml:namespace-manager> 
    <flow name="fileTestFlow1">

         <file:inbound-endpoint path="D:/data/in" moveToDirectory="D:/data/out" moveToPattern="#[message:id]-#[header:originalFilename]" connector-ref="input"/>
            <component class="com.component.FileNameExtract"/> 

         <message-properties-transformer scope="outbound">

                <add-message-property key="test" value="#[message:id]"/>
         </message-properties-transformer>       
         <jdbc:outbound-endpoint queryKey="outboundInsertStatement"/>         
         <cxf:jaxws-client
               clientClass="com.ws.IESBService"
               port="IESBServiceEndpoint"               
               wsdlLocation="classpath:IESBService.wsdl"
               operation="requestInfo"/>               
         <outbound-endpoint address="http://ip:8888/axis2/services/iESBService/" exchange-pattern="request-response">           
         </outbound-endpoint>         
         <xml-entity-decoder-transformer/>                   
         <logger message=" #[header:test] !" level="INFO"></logger>        
    </flow>   
</mule>

更新:「セッション」スコープを試してみましたが、うまくいくと思います。新しい構成:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:file="http://www.mulesoft.org/schema/mule/file"
      xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
      xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
      xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
          http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
          http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.1/mule-cxf.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.1/mule-jdbc.xsd
          http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd  
          ">    
  <spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
    <spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/>
    <spring:property name="url" value="jdbc:oracle:thin:user/pass@ip:1521:orcl"/>
  </spring:bean>
  <file:connector name="output" outputAppend="true" outputPattern="#[function:datestamp]-#[header:originalFilename]" />
  <file:connector name="input" streaming="false" recursive="true" autoDelete="false"> 

          <service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" /> 

  </file:connector>
        <jdbc:connector name="jdbcConnector" pollingFrequency="10000" dataSource-ref="jdbcDataSource">
           <jdbc:query key="outboundInsertStatement"
              value="INSERT INTO TEST_MESSAGE (message_id, filename, done) VALUES (#[message:id], 
                    #[header:originalFilename], #[string:0])"/>
           <jdbc:query key="outboundUpdateStatement"
              value="update TEST_MESSAGE set done='1' where message_id=#[header:SESSION:test] "/>
        </jdbc:connector> 
        <mulexml:namespace-manager includeConfigNamespaces="true">
                <mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/>
                <mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/>
                <mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/>
                <mulexml:namespace prefix="fullmodel" uri="iesb.dongfang.com"/>
        </mulexml:namespace-manager> 
    <flow name="fileTestFlow1">

         <file:inbound-endpoint path="D:/data/in" moveToDirectory="D:/data/out" moveToPattern="#[message:id]-#[header:originalFilename]" connector-ref="input"/>
            <component class="com.component.FileNameExtract"/> 

         <message-properties-transformer scope="outbound">

                <add-message-property key="test" value="#[message:id]"/>
         </message-properties-transformer> 
         <logger message="first #[message:id] " level="INFO"></logger>      
         <jdbc:outbound-endpoint queryKey="outboundInsertStatement"/>         
         <cxf:jaxws-client
               clientClass="com.ws.IESBService"
               port="IESBServiceEndpoint"               
               wsdlLocation="classpath:IESBService.wsdl"
               operation="requestInfo"/>               
         <outbound-endpoint address="http://ip:8888/axis2/services/iESBService/" exchange-pattern="request-response">           
         </outbound-endpoint>         
         <xml-entity-decoder-transformer/>                   
         <jdbc:outbound-endpoint queryKey="outboundUpdateStatement"/>
         <logger message="second #[header:SESSION:test] " level="INFO"></logger>       
    </flow>   
</mule>

ファイルを 1 つずつコピーする場合は問題ありませんが、5 つ以上のファイルをディレクトリにコピーすると、一部のレコードが更新されません。

 Executing SQL statement: 0 row(s) updated
4

1 に答える 1

1

フローが単一のスレッドで実行されるように、JDBC アウトバウンド エンドポイントを request-response に設定します。現在の構成では、2 つの in-only JDBC リクエストがフローから「分離」され、フローから並行して実行されます。

于 2011-10-01T19:42:30.710 に答える