Following Part 1 of implementation earlier, let us proceed to the next step.
Part 2: File Adapter
Drag and drop a File Adapter from Component Palette on to Components section of composite.xml. Enter OrderFTPClientService for service name.
Enter values for next steps as shown in screenshots below.
Select “Read File” as Operation Type and enter operation name as ReadFTPFile as shown below.
Enter directory for incoming files. MyBay would FTP order files in to this directory. Select Archive processed files checkbox and specify directory for storing archived files. Once order file is success processed, we want to archive it and remove it from original directory for incoming files.
Select checkbox before “Delete files after successful retrieval”.
File Filtering can happen either through wildcards or regular expressions. For normal purposes, wildcard filter would suffice. Regular Expression can be used in advanced cases. Specify “Order*.txt” in the name pattern field.
Check “Files contain Multiple Messages” checkbox as we’ll have more than one order in the incoming file. We can post more than 1 record in a batch. However, this is useful only when the outbound service is capable of consuming records in batches. Database Adapter can process records in batches. For this example, we’ll keep batch size as 1.
In next screen, we can specify file polling frequency. Minimum File Age is an interesting option. File poller will process this file only “minimum file age” time after file is last updated. This is useful when we receive large files that take very long time to be transferred and prevent file pollers from processing the file while its still being FTPed.
In next screen, we need to create a schema to map to an incoming order file. Click on “Define Schema for Native Format” icon at the end of URL field as shown below.
Our order file will be a comma separated file. So, lets choose Delimited option.
Select Order.txt in File name section. This can be found in ./MediatorExample/ftp/input directory of the installation zip file.
For next steps, use the screenshots shown below.
Finally, specify file name for the XSD as FTPFileOrder and Finish. We will now come back to original File Adapter wizard with Schema details populated.
Finally, specify file name for the XSD as FTPFileOrder and Finish. We will now come back to original File Adapter wizard with Schema details populated. Click on Finish to complete File Adapter creation.
Drag and drop another Mediator component from Component Palette to create connector for File Adapter, to convert xml order data into canonical form. Name Mediator as OrderFTPABCS. Connect this component with OrderFTPClientService created earlier.
Drag and drop another Mediator component from Component Palette to create connector for File We need to transform XML data read from FTP File Adapter to canonical form. Double click on OrderFTPABCS.
Under Routing Rules, click on icon next to “Transform Using” field.
Create a new mapper file. field. File name will be automatically populated. We can change it to any name we like.
Right click, drag and drop OrderCollection element on to orderDetailsRequest.
Right click, drag and drop OrderCollection element on to orderDetailsRequest on the right. Uncheck “Match Elements Considering their Ancestor Names”.
Use the screenshot below to map elements.
Finally, connect OrderFTPABCS to OrderABCS. This completes the process of creating File Adapter, transforming data into canonical form and linking it to the Order Management connector to write details to Order Management.
In the next and final step, we shall examine how to create Database Adapter and link it to OrderABCS.