2016-09-12 5 views
0

入力変数に応じてプロパティが動的であるフローでsftpエンドポイントを使用する方法を理解しようとしています。 だから流れは次のように基本的である:動的プロパティを持つMule sftpエンドポイント

<flow name="dynamicSftpEndpoint"> 
    <sftp:inbound-endpoint name="inbound" connector-ref="SFTP" 
          host="#[sftpHost]" port="#[sftpPort]" 
          user="#[sftpUser]" password="#[sftpPassword]" 
          archiveDir="#[sftpInboundArchive]" 
          responseTimeout="${sftp.responseTimeout}" 
          path="#[sftpInboundPath]"> 
     <file:filename-regex-filter pattern="#[sftpInboundPattern]" caseSensitive="false"/> 
    </sftp:inbound-endpoint> 
    <set-variable variableName="filename" value="#[message.inboundProperties.originalFilename]"/> 
    <log:info message="File '#[filename]' received from endpoint #[market]"/> 
</flow> 

しかし、私は

Caused by: org.mule.api.endpoint.MalformedEndpointException: The endpoint "sftp://#[sftpUser]:#[sftpPassword]@#[sftpHost]:#[sftpPort]/#[sftpInboundPath]" is malformed and cannot be parsed. If this is the name of a global endpoint, check the name is correct, that the endpoint exists, and that you are using the correct configuration (eg the "ref" attribute). Note that names on inbound and outbound endpoints cannot be used to send or receive messages; use a named global endpoint instead.. Only Outbound endpoints can be dynamic 

のような例外を取得私は、発信エンドポイントが動的にできることが最後の文に気づきました。しかし、誰もダイナミックインバウンドエンドポイントの回避策について考えていますか?

答えて

0

受信エンドポイントが代替的に、流れのある動的ことができない

おかげ。

  • 動的EndpointBuilderインタフェースを のサンプルコードを使用してエンドポイントを作成するために使用するJavaのすべての可能な受信エンドポイントと異なるフローを定義し、特定のフローにリダイレクトするように選択フィルタを使用する:

// sftp server connector config String uri = "sftp://" + userDetails + "@" + serverDetails + "/tmp/sftpFolder"; EndpointBuilder endpointBuilder = eventContext.getMuleContext().getEndpointFactory().getEndpointBuilder(uri); InboundEndpoint inboundEndpoint = endpointBuilder.buildInboundEndpoint(); SftpConnector connector = (SftpConnector) inboundEndpoint.getConnector(); connector.connect(); // sftp client connection config SftpClient client = new SftpClient(host); client.setPort(port); client.login(user, password); //client.mkdir("dirFromSftp"); client.changeWorkingDirectory("dirFromSftp"); String[] listFiles = client.listFiles(); for(String file: listFiles) { System.out.println("File : " + file); }

+0

Muleエンドポイントの新機能では、Javaでどのようにビルドするのですか? –

+0

答えにコードサンプルが追加されました –

0

Mule SFTPコネクタは、ダイナミックエンドポイントをサポートしていません。

ただし、スクリプトを使用して、sftp mid flowを介してファイルを読み取ることはできます。次のようなものがあります:

<scripting:transformer> 
      <scripting:script engine="Groovy"> 
       <scripting:text> 
        def endpointBuilder = muleContext.endpointFactory.getEndpointBuilder( 
        "sftp://${sftp.username}@${sftp.host}:${sftp.port}/${sftp.path}?identityFile=${app.home}/${sftp.keyPath}&amp;passphrase=${sftp.passphrase}&amp;connector=sftp-csv") 
        endpointBuilder.addMessageProcessor(new org.mule.routing.MessageFilter(new org.mule.transport.file.filters.FilenameWildcardFilter(sessionVars.expectedFilename))) 
        def inboundEndpoint = endpointBuilder.buildInboundEndpoint() 
        inboundEndpoint.request(30000L) 
       </scripting:text> 
      </scripting:script> 
     </scripting:transformer> 
+0

これも試してみます –

関連する問題