Flow proxy - Flow Sender example
Contents
This example demonstrates the use of the Flow Sender producer together with the Flow Proxy consumer. The Flow Sender hands a message to another flow and does not wait for it.
In this example, the main flow picks up an input file and hands it to a secondary flow with a Flow Sender. The secondary flow drops the file in an output folder.
You split work over two flows like this when more than one flow needs the same next step. Each sending flow points at the same receiving flow, so you build and maintain that step once.
| Item | Value |
|---|---|
ConnectAgent version |
>= 5.2 |
Operating system |
Linux minimal kernel 3.1.x |
Required applications |
ConnectAgent installed |
Required permissions |
Local administrator access with write permission on the target directory |
Required directories |
Input, backup and output directories |
This example does not require any Resource, Script, Bean or Global Property.
Both flows are in one interface, order-handoff.
Flow 1 (pickup-orders)
| Step | Component | Purpose |
|---|---|---|
1 |
File Pickup |
Pick up the input file |
2 |
Flow Sender |
Hand the message to Flow 2 |
Flow 2 (write-orders)
| 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 output folder |
Flow 1
File Pickup
| Property | Value | Explanation |
|---|---|---|
Pickup Directory |
C:/orders/in |
Path to the input directory |
Backup Directory |
C:/orders/backup |
The File Pickup puts a copy of each file it picks up here |
Flow Sender
| Property | Value | Explanation |
|---|---|---|
Output flow |
order-handoff.write-orders |
The Flow to hand the message to (the interface and the name of Flow 2) |
Before you can select Flow 2 as the output flow, you must configure a Flow Proxy consumer in Flow 2.
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:/orders/out |
Path to the 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. |
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 and puts a copy in the backup directory
-
Flow Sender hands the message (file and contents) to the second flow. Flow 1 does not wait for Flow 2.
-
Flow 2 receives the message
-
Flow 2 drops the file on the output folder
-
The input file has disappeared from the input directory.
-
The file now appears in the output directory with the original file name.
-
The backup directory holds a copy with a timestamp in front of the name, such as 20261015-143012123_order.xml.
| Situation | Expected Result |
|---|---|
Directory Missing |
Flow will automatically create the output directory. |
Flow Proxy consumer of Flow 2 is stopped |
The message is not delivered. The agent logs a warning and the message is lost. |
An answer from Flow 2 is needed |
The Flow Sender does not wait for an answer. Use a Flow Gateway service instead, and end Flow 2 with a Message Reply producer. |
To verify and reproduce this example, please follow the instructions below:
-
Create the input, backup and output directories
-
Start the ConnectAgent
-
Configure the Flows with the properties described above and create a Bundle
-
Deploy the Interface into the Agent
-
Drop a file in the input directory
-
Verify the backup and output directories.
Here are some ideas to extend this example:
-
Add a second sending flow with its own File Pickup that also hands its files to Flow 2. Both flows now share one File Drop.
-
To send to a flow in another interface, set Inter-Interface to true on the Flow Sender. The Output flow list then shows the flows of the other interfaces too.
-
Flow Sender: https://docs.connectplaza.com/components/producers/channel-dispatcher.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