Introduction

This article is an extension of the approach initially described in How to pick up files with filename dynamically specified in message content. In that article, the example use case was to pick up a specific file to be asynchronously transferred to another location.

This article is based on the solution provided for the thread Soap Call retrieving document from FTP Server. In order to synchronously retrieve a file based on the filename specified in the request message, the original approach requires further enhancements.

Approach

To achieve this requirement, the design uses a combination of the original approach together with a Sync-Async bridge (as described in the following document).

AsyncSync & SyncAsync Bridge without BPM

The main changes to the approach are as follows:-

  1. Add a field to store message ID in the target structure of the trigger file
  2. Store the PI message ID of the request into the field above during message mapping
  3. Trigger file created will have PI message ID in the content
  4. Create custom adapter module to be used in the sender channel of the second scenario
  5. The custom module will replace the position of DynamicConfigurationBean (used before NotifyResponseBean)
  6. Logic of the custom module will be to extract the PI message ID from the trigger file, and set the correlation ID in the PI response message

Design & Configuration

The main concepts behind this enhanced approach are similar to the original, so if you intend to implement this I would suggest that you familiarize yourself with the concepts by reading the original article. This article will focus on the enhancements required to achieve the retrieval using an S-A bridge.

iFlow Scenario 1 – Synchronous Request

Message mapping for the request

– Populate the message ID of the request into the target structure

– Change the filename’s extension to end with the trigger extension (i.e. “.trig”)

/wp-content/uploads/2015/04/map_691827.png

UDF to retrieve the request’s message ID

/wp-content/uploads/2015/04/msgid_691826.png

The filename’s extension is changed from “.txt” to “.trig”. This filename is then used in variable substitution as the target filename (refer receiver channel screenshot in previous article).

/wp-content/uploads/2015/04/changefilename_691792.png

Sender channel configuration

The synchronous call will be triggered from a SOAP request message into PI. For the SOAP sender channel, check “Keep Attachments”, this ensures that the file that is picked up as an attachment in the response message will be available back to the calling SOAP program.

/wp-content/uploads/2015/04/soap_sender_691829.png

iFlow Scenario 2 – Synchronous Response

Custom adapter module

To close the S-A bridge, the asynchronous response needs to be correlated back to the original synchronous request. This is achieved by setting the request’s message ID as the correlation ID of the response message. To achieve this, the custom adapter module is developed with the logic below:

  • Extract the message ID from the XML of the response message (which is also the trigger file)
  • Set the message ID as the correlation ID

/wp-content/uploads/2015/04/module_691836.png

Sender channel configuration

The sender SFTP channel for the asynchronous response will poll the directory based on the trigger filename pattern. The actual file to be picked up (in this case a .txt file) is configured in the Additional file section.

Note: To avoid timeout on the synchronous part of the S-A bridge, the polling frequency should be set lower than the synchronous timeout setting.

/wp-content/uploads/2015/04/poll_691840.png

The custom module is set as the first module (replacing DynamicConfigurationBean as shown in the reference S-A bridge article) of the sender channel. An XPath expression to the location of the message ID in the XML is configured as a parameter for the module.

/wp-content/uploads/2015/04/sender2_691830.png

Testing Example

FileABC123.txt is created and uploaded to the directory where it should be picked up from.

/wp-content/uploads/2015/04/filecontent_691834.png

/wp-content/uploads/2015/04/file_691833.png

Using SOAPUI, a synchronous message is triggered specifying the filename to be picked up.

/wp-content/uploads/2015/04/req_691832.png

The first scenario creates a trigger file in the target directory with the same name as the requested file except with a different extension. This trigger file will contain the message ID of the synchronous request.

/wp-content/uploads/2015/04/files2_691837.png

The sender SFTP channel of the second scenario picks up both the trigger file and the .txt file. The .txt file is included in the response message as an attachment.

/wp-content/uploads/2015/04/attach_691838.png

After the files are picked up, the custom module is executed to set the correlation ID and route the message back synchronously to close the S-A bridge.

/wp-content/uploads/2015/04/log_691839.png

In the response section of SOAPUI, the file that was picked up can be viewed as an attachment of the SOAP response message.

/wp-content/uploads/2015/04/response_691835.png

Additional Considerations

If the file to be picked up is an XML file and it is required as the main response message, PayloadSwapBean can be included after the custom module to swap the attachment into the main payload.

Reference

The full source code for the adapter module can be found in the following GitHub repository.

SetCorrelationBean.java at equalize-xpi-modules at GitHub

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply