Skip to Content
Technical Articles
Author's profile photo Mandy Krimmel

Cloud Integration – Use Poll-Enrich with SFTP Adapter

This blog describes how to configure the new Poll Enrich pattern in combination with the sftp adapter, elaborating on use cases and different configuration options.

Use Poll Enrich with SFTP Adapter

In general, there are three main use cases for the Poll Enrich pattern:

  • You want to enrich the message payload with additional data retrieved from a file on the sftp server.
  • You want to poll from an sftp server triggered by an external trigger, for example triggered via HTTP call.
  • You need to poll from an sftp server but want to define the configuration in the sftp adapter dynamically, for example from a partner directory.

In this blog, I will focus on the second and third use case. Yet, I will shortly also mention the configuration option for the first use case when discussing the integration flow configuration.

This is the simple integration flow we are going to build:

The flow starts with a HTTP inbound adapter that triggers the message processing. In a subsequent Content Modifier, some properties are defined that are used dynamically in the sftp adapter when polling the file from sftp server. At the very end, the message is sent out to the receiver system.

Let’s start.

In the integration flow, draw a connection from the Sender participant to the Start Message event and select the HTTP adapter; then add a Content Modifier next to it. Configure the HTTP adapter as you like.

In the Content Modifier, you define the properties that are to be used dynamically in the SFTP Adapter. For dynamically configurable settings, refer to the blog Cloud Integration – Dynamically Configure the SFTP Receiver Adapter. The same settings are allowed dynamically in the sftp adapter in the Poll-Enrich pattern. Note that with the first increment (version 1.0 of the Poll Enrich sftp adapter), Proxy Type and Authentication can’t yet be set dynamically.

For my simple scenario, I define the following properties to set them dynamically via XPath from the incoming http request:

Next to the Content Modifier, configure the Poll Enrich step. For this, in the Call section of the modeler, select External Call and then Poll Enrich.

In the Poll Enrich step, we have to configure how the payloads need to be aggregated: the one before the Poll Enrich step and the payload fetched from sftp server need. In addition you configure what to do if no message is found on the sftp server.

The aggregation is configured with the help of the Aggregation Algorithm in the Poll Enrich step:

For our use case (to simply read files via external trigger or via dynamic configuration in the sftp adapter), the Replace option is the correct choice. This algorithm simply replaces the original message (payload and headers) before the Poll Enrich step with the new one fetched from the sftp server.

If you want to enrich your original payload (use case 1), you have to select one of the other two algorithms:

  • Combine XML: This option combines the message polled from the sftp server with the original message in multimapping format. This option makes most sense if both, the original and the polled message, are XML messages.
  • Concatenate: The message polled from the sftp server is added to the existing message. This option is useful for strings.

If you want to get an exception in case no message is found on the sftp server you can select the checkbox Throw Exception if no Message Found. If not selected, the header SAP_PollEnrichMessageFound is set to false if no message can be found during processing. Based on the header you can configure alternative processing.

Having defined the Poll Enrich step, we now need to configure the SFTP adapter. To do so, add another Sender participant and draw a connection from this new Sender participant to the Poll Enrich step. Select the SFTP adapter.

The configuration of the SFTP adapter will look familiar to you because it contains almost the same configuration options as the normal SFTP sender adapter. Some configurations, like the Scheduler tab, are missing because they are not relevant in this pattern, but most settings are equal.

In the configuration we specify the properties defined in the Content Modifier:

As a final step, configure a connection to the Receiver participant to send the message out.

Deploy the flow and trigger it with a payload that provides the necessary data; in my example, I use the following simple payload:

<?xml version='1.0' encoding='UTF-8' ?>
<request>
	<sftp>
	<Directory>test/test1</Directory>
        <File>TestFile*</File>
	</sftp>
</request>

Note that in case no file can be found on the sftp server, the processing continues with the payload before the Poll Enrich step. It is planned to offer specific handling in such a case.

I hope this simple scenario helps you to understand the Poll Enrich pattern.

Planned Extensions:

  • Dynamic Configuration of Proxy Type and Authentication (available after the June 2021 update)
  • Keep File and Process Again option not available (available with July 2021 update)
  • Configure Handling if File is not found on the sftp server (available with August 2021 update)
  • Support FTP adapter in Poll Enrich step

 

Assigned tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Federico Bellizia
      Federico Bellizia

      Hi Mandy,

      this is a dream feature we waited from 4 years, thank you very much, could you ask to your developer to add on Process the option None, a lot of time we just need to read files without variation of timestamp and position.

      We tried some workaround like   take file move on processing folder and at end on workflow put it bak on sftp original folder.

       

      Destination folder doesn't accept properties, headers like parameter and if you put  .  instead .archive  it doesn't work, files disappears on void :).

       

      Thank you and good job!

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      Hello Federico,

      thank you for your nice feedback.

      Concerning option None you mean to simply keep the file and process it again with the next poll? This will come with the next update, it will be called 'Keep File and Process Again'. Note that you need to recreate the sftp channel to get the new version of the polling sftp sender adapter to get this feature.

      Best regards,

      Mandy

       

      Author's profile photo Federico Bellizia
      Federico Bellizia

       

      As you can see there is no way to keep file for next run....

       

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      As said, this feature will come with the next update only. This is in about 2-3 weeks. Afterwards you will find it 🙂

      Best regards

      Mandy

       

      Author's profile photo Pushkar Patel
      Pushkar Patel

      Hi Mandy Krimmel ,
      With Poll Enrich, when I am trying to use SFTP adapter and post processing as delete, its not working. Is there any limitation around deletion the file after processing with Poll Enrich ?

      Thanks,

      Pushkar

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      This should work, maybe there is a problem with permission to delete the file? Maybe check the log files in the sftp server.

      Best regards

      Mandy

      Author's profile photo monica bhosale
      monica bhosale

      Hi Mandy,

      Thank you for sharing this information, it's really efforts saving functionality in middleware. In omy current development we have FTP server ,any tentative date when we are planning to have this functionality for FTP?

       

      Thank you,

      Monica

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      It is planned for the September or October update, depending how well the testing goes.

      Best regards,

      Mandy

      Author's profile photo monica bhosale
      monica bhosale

      Thank you for quick reply and update Mandy, it's really helpful .Just check roadmap plan and it's in Q3, eagerly waiting for this feature as this will help to reduce lots of customize  efforts in development .

      Author's profile photo Jeremy Ma
      Jeremy Ma

      Hi Mandy,  In this SFTP poll enrich processing option for sorting and polling is missing, when will this be available.  Or is this by design where you have to pass the dir/filename as a variable to poll enrich > ftp?

       

      Thanks

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      This is as per design, the sorting does not work together with the poll-enrich step. Because of this this option is not available. If you need a specific file you need to pass the file name as header/property.

      BR

      Mandy

      Author's profile photo Santhosh ReddyKolanu
      Santhosh ReddyKolanu

      Hi Mandy,

       

      Very useful blog.

      I just want to know the differences between Content enricher via SFTP and Poll enricher. I understand that poll enricher has better aggregation strategies.

      Want to know the other differences reason being poll enricher works for sender and Content enricher works with a receiver. However both of these are actually polling SFTP based on the file name, directory details we configure. They poll the file data and enrich as per aggregation strategy.

      Regards,

      Santosh

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      Hello Santosh,

      Content Enricher is always using the response coming back from the receiver to aggregate. It is using a receiver channel. And if you choose a receiver channel you can write files to sftp adapter but not poll files from there. The polling of files in the middle of the flow only works with the poll enricher as this is using a sftp sender channel.

      Content Enricher is usually used with HTTP based adapters that send a response and this response is to be aggregated to the payload.

      Best regards

      Mandy

      Author's profile photo Madina Mendoza
      Madina Mendoza

      Hi Mandy,

       

      Thanks for this. We wanted to check whether the Sender can also be an SFTP? We wanted to be able to process and incoming SFTP file and perform a lookup on another SFTP file using the poll enricher.

       

      Thanks.

       

      Regards,

      Madina

      Author's profile photo Mandy Krimmel
      Mandy Krimmel
      Blog Post Author

      Yes, this is possible.

      BR

      Mandy

      Author's profile photo Madina Mendoza
      Madina Mendoza

      Thanks, Mandy! Indeed the CPI Consultant confirmed this.

       

      Cheers,

      Madina