Flow proxy - Message Copy example
Contents
This example demonstrates the use of the Message Copy service together with the Flow Proxy consumer. The Message Copy service creates a copy of a message and sends it to another flow for additional processing.
In this example, the main flow receives an input file and drops it using a File Drop producer. The Message Copy service is used to send a copy of the message to a secondary flow, which processes the copied message and drops the file into a separate folder.
As a result, the original input file is copied and delivered to two different locations: one through the main flow and one through the secondary flow triggered by the Message Copy.
| Item | Value |
|---|---|
ConnectAgent version |
>= 5.2 |
Operating system |
Linux minimal kernel 3.1.xRed Hat 8 / 9 / 10Rocky 8 / Rocky 9 /Rocky 10Windows Server 2016 or higher |
Required applications |
ConnectAgent installed |
Required permissions |
Local administrator access with write permission on the target directory |
Required directories |
Input and output directories |
This example does not require any Resource, Script, Bean or Global Property.
Flow 1
| Step | Component | Purpose |
|---|---|---|
1 |
File Pickup |
Pick up the input file |
2 |
Message Copy |
Send a copy of the message to Flow 2 |
3 |
File Drop |
Drop the file in the output directory |
Flow 2
| Step | Component | Purpose |
|---|---|---|
1 |
Flow Proxy |
Expose the Flow as an endpoint that can be invoked by Flow 1 |
2 |
File Drop |
Drop the file in the alternative output folder |
Flow 1
File Pickup
| Property | Value | Explanation |
|---|---|---|
Pickup Directory |
C:/[…]/Msg_Copy_Flow/input |
Path to the input directory |
Message Copy
| Property | Value | Explanation |
|---|---|---|
Target Flow |
<interface>.FlowProxyFileDrop |
The target Flow to send the message copy to (the name of Flow 2) |
Before you can select Flow 2 as the target Flow, you must configure a Flow Proxy consumer in Flow 2.
File Drop
| Property | Value | Explanation |
|---|---|---|
Output directory |
C:/[…]/Msg_Copy_Flow/Output_1 |
Path to the first output directory |
File Name Header |
file_name |
Specifies the header that will be used to specify the output file name. File_name header contains the original name by default, so the output file will retain the name. |
Flow 2
Flow Proxy
| Property | Value | Explanation |
|---|---|---|
MessagePart Out |
msgprt0 |
Specifies the MessagePart that receives the output message. By default, the value is msgprt0. |
File Drop
| Property | Value | Explanation |
|---|---|---|
Output directory |
C:/[…]/Msg_Copy_Flow/Output_2 |
Path to the second output directory |
File Name Header |
For illustrative purposes, this field will be left empty. This means that no header value will be used to determine the file name. |
Any file can be used for this example. You can drag and drop an existing file, or create a new empty plain text file if preferred.
-
File Pickup consumer is constantly checking for files in the input directory
-
File is dropped on the Input directory
-
File Pickup picks up the file
-
Message Copy sends a Copy of the message (file and contents) to the second flow
-
Flow 2 receives the message
-
Flow 2 drops the file on the "Output_2" folder
-
Flow 1 drops the file on "Output_1"
Note: The execution order of steps 5–7 is not guaranteed. Because the Message Copy service performs an asynchronous operation, Flow 1 and Flow 2 continue processing independently, and either Flow may complete first.
-
The input file has disappeared from the input directory.
-
The file now appears on both of the output directories, but the names are different:
-
The file in Output_1 preserves the file name
-
The file in Output_2 has a random 36-character UID as a name, such as 781ff27a-eeab-41c6-ac6c-25e0b8fe9ef8.
-
| Situation | Expected Result |
|---|---|
Directory Missing |
Flow will automatically create the output directory. |
Disk full |
File Drop returns exception |
File name contains invalid characters such as spaces or colons |
File creation fails due to invalid destination filename. |
To verify and reproduce this example, please follow the instructions below:
-
Create the Input, Output_1 and Output_2 directories
-
Start the ConnectAgent
-
Configure the Flow with the properties described above and create a Bundle
-
Deploy the Interface into the Agent
-
Drop a file in the input directory
-
Verify the output directories.
Here are some ideas to extend this example:
-
Create Flow 3 with the same structure as Flow 2, but configure it to use a different output directory. Add a Message Copy in Flow 2 that routes messages to Flow 3. Verify that the file is written to all three output directories.
-
Add a Header Enricher to Flow 2 to modify the output file name. Then update Flow 2 to use the same output directory as Flow 1. Since each flow generates a different file name, both flows can safely write to the same output directory.
-
Configure Flow 1’s File Pickup to use the Output_2 directory as a backup directory. Disable the Message Copy (set the enabled configuration to False). Run the flow and verify that the behavior remains the same.
-
Add a Message Enricher to Flow 2 to modify the contents of the input file before it is written to the output..
-
Message Copy: https://docs.connectplaza.com/components/wiretap.html
-
Flow Proxy: https://docs.connectplaza.com/components/consumers/channel-proxy-consumer.html
-
File Pickup: https://docs.connectplaza.com/components/consumers/file-consumer.html
-
File Drop: https://docs.connectplaza.com/components/producers/file-producer.html