1

To fetch Filename in SFTP write connector, i have stored filename in variable and writing file(staging), after it written in directory. from different flow i need to move same file to output location both flows are not interlinked.

we dont have Session variable in Mule4 to achieve this scenario. Could anyone let me know how to store variable like filename(with timestamp) in one flow and read it from different flow.

EX: filename pattern "test" ++ "_" ++ now() as Date {format: "yyyyMMdd"} ++ "_" ++ (now() as String {format: "HH:mm:ss"}) ++ '.txt'

4

1 回答 1

1

Session vars wouldn't help as they need to be serialized on an event and as the flows are not interlinked, this wouldn't work.

To share state between different flows you can use the Object Store. This is a Key-Value based store that can be in-memory or persistent.

It will allow you to store your filename in one flow:

    <os:store key="#[vars.filename]" objectStore="${objectStore}" />

And retrieve it another flow ():

    <os:retrieve-all objectStore="${objectStore}"/>

Or this will retrieve all keys:

    <os:retrieve-all-keys objectStore="${objectStore}"/>

And then use a foreach to iterate all keys and perform your logic.

Or you can retrieve a specific key for example:

There's lot of other operations available on the ObjectStore connector. Here are the official docs: https://docs.mulesoft.com/object-store/

And here are some example configs:

https://github.com/mulesoft/mule-objectstore-connector/tree/master/src/test/resources

于 2019-04-02T07:16:34.820 回答