Technical Articles
How to reuse existing mapping, schema and most importantly scripts from other Integration flows in new Integration Flow.
Introduction :
In lots of projects I have noticed multiple interfaces require a to use same schema , mapping and scripts. Scripts are something which should be written only once and should be reused across different interfaces if needed. For example logging payload or exception script which are used mostly. You dont need to write or copy same code again and again.
CPI has feature to reuse the Archive scripts , mapping and schema which you can get from local file system and other Integration flow. There is option to reuse mapping from ESR as well.
Step1 : Create a new Package or use existing Package.
Step 2: Create an Iflow, go to Resources Tab->
Step 3: Click on Add-> Archive/Schema/Mapping/Script from Local File System or existing Integration Flow form another package.
- If you want to Add Schema -> XSD /WSDL EDMX (Any type)
2. Add Mapping-> MM/OM/XSLT mapping from Local/ESR/Integration Flow
3. Add Script-> File System/ Integration Flow
4. There is option add Archive as well.
Conclusion
Reusing already build scripts will save you lot of build time. You can write few standard scripts at the beginning of the project and can use those across all interfaces.
Hope this will help you in reusing your existing components.
Good one? Keep blogging?
The issue I was trying to solve was that two of the Integration Flows that I have require the same value in the header (it is read from Security Material). So rather than duplicating the groovy script code between the Integration Flows, I wanted to have only one groovy script that I could update, and the changes would be reflected in each of the Integration Flows.
This does not seem to be the way that this works with Resources. From my testing, it looks like the steps above COPY the script to the new integration flow rather than link back to the original.
Here are the steps I took:
What I expected was that the script in Step 2 would be updated since it was linked to the script in step 1. This does not appear to be the case. When I made changes to the original script, they are not seen in the second Integration Flow.
From what I have found, this does not seem like reuse, but instead is a copy the original to each subsequent Integration Flow, and the scripts remain independent.
So is this something that I have done incorrectly, or does the reuse as shown in the original post not work the way I thought it would?
Thanks.
Yes, this post describes copying artifacts between Iflows and not really reusing the same. It is now however possible by creating a Script Collection (or even a Mapping Artifact) in the package where your iflows are located that shall be able to reuse the same script.
Best,
Philippe