I have a scenario where multiple files will be dropped at a location. I am interested in reading two files out of it as a pair (e.g., 913.xml and 913.pdf). I want to pass both files to a Java component which will merge them.
I know how to merge them but I am not sure how to pass two files at once to my Java component
I can think of two options:
Configure the file inbound endpoint to select say the XML files and in your component use the MuleClient to request the other file,
Configure the file inbound endpoint to select both XML and PDF files and add a collection-aggregator configured with an expression-message-info-mapping that uses the originalFilename property in a correlation ID expression that extracts the file name sans extension from it. Don't forget to set the MULE_CORRELATION_GROUP_SIZE property to 2 before the aggregator.
Related
I have created a logic app where I need to check if my file name contains "ABC" then i need to copy file and paste it in ABC folder Azure else need to check if my file name contains "ZYX" then paste it in ZYX folder in Azure.
In switch function its giving me an error.
"The execution of template action 'Switch' failed: The result of the evaluation of 'scope' action expression '#body('Get_file_content')' is not valid. It is of type 'Object' but is expected to be a value of type 'String, Integer'." [Image1]
or if I am trying to use 2 conditions in parallel branch its giving me the below error.
![Image2]
I also tried conditions, if the file name contains "ABC" then copy paste in ABC folder if false then i tried using another conditions inside the false command.
Also, follow up question would be if I have multiple file name with ABC then can I merge and place it in one file and paste that in ABC folder in Azure Blob
Image using switch function:
Image Conditions using parallel branch:
![Image Conditions using parallel branch]
Attaching the latest screenshot with your suggestion.
enter image description here
i just tried using one and its giving me the error.
enter image description here
Reason for the error : You cannot passfile content as a condition check in the switch Connector.
Solution: In order to get the desired output as described above you need to pass the file name as a condition check in switch control. As we receive the File Name from the SharePoint connector as base64 format we need to decode it to string using **base64ToString(FileName)** to compare the folder names present in the containers/blob.
Here is the code view of the logic app based on the above-discussed requirement.
Also, follow up question would be if I have multiple file name with
ABC then can I merge and place it in one file and paste that in ABC
folder in Azure Blob
Using the above flow, merging of files is not possible since each file is saved in different extensions but override of the file takes place in the blob if you are uploading or updating the same file.
For more information about merging of files using Logic app you can refer this BLOG.
UPDATED ANSWER
Before Comparing the string/ Filename you can use 'Compose' before the 'Condition' Connector and convert the string into lower case.
toLower(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']))
I need to create a file filter (to pick files from a folder) based on the content received from another file.
I set up a route like this:
File1 Url -> pollEnrich(File2 Url with filter, aggregationStrategy) -> log
But the issue is that in pollEnrich, the value obtained from File1 is not available. Hence I am not able to create a filter based on which I have to pick the files from Folder2.
I tried both the filer option in the URL as well as the programmatic filter (by extending GenericFileFilter class). Any suggestions are very much appreciated.
Recall the fact from content-enricher,
pollEnrich only accept one message as response
The pollEnrich will collect single file when call with file component. Thus, you should use file component with fileName option inside pollEnrich to collect single file and use while loop to call pollEnrich multiple time.
I would like to know if someone has been able to send a byte array in the jmeter by mapmessage without the output being a string
As per JMS Publisher documentation it is possible:
The Object message is implemented and works as follow:
Put the JAR that contains your object and its dependencies in jmeter_home/lib/ folder
Serialize your object as XML using XStream
Either put result in a file suffixed with .txt or .obj or put XML content directly in Text Area
Note that if message is in a file, replacement of properties will not occur while it will if you use Text Area.
If it is not something you're looking for - you can always directly call BytesMessage class functions, i.e. writeBytes() from JSR223 Test Elements using Groovy language
Iam trying to automate the testing of a java bundle,Which will process once a file is dropped in a particular folder.
can we drop a file to a folder location automatically using camel,or at a set period of time(not intervals)?
is this possible purely by camel or should we incorporate other frameworks?
sure, you can use the camel-file component to produce (create files somewhere) and consume (read/process files from somewhere) and optionally control the initial/polling delays easily with attributes...
here is a simple example of consuming->processing->producing
from("file://inputdir").process(<dosomething>).to("file://outputdir")
alternatively, you could periodically produce a file and drop it somewhere
from("timer://foo?fixedRate=true&period=60000").process(<createFileContent>").to("file://inputdir");
Although camel could do this by creating a timer endpoint, then setting the file content and writing to a file endpoint, my answer would be to simply use a bash script. No camel needed here.
Pseudo bash script:
while [ true ]
do
cp filefrom fileto
pauze 10s
done
I am new to camel and we are building an EDI engine and our requirement is to read the files from multiple folders then second step is to parse the message type and the receiver id and based on that the messages need to be routed to different folders.
The source, message type, receiver id and destination cannot be hardcoded in camel instead it should be read from the database and the routes need to be built dynamically.
Please let me know what should be the strategy that we need to follow.
Thanks,
Jayadeep
As I understand from your comments, you can read from multiple folders by adding routes dynamically but are facing issue when trying to decide on where to send the messages as the destination , headers etc is being read from database.
Here's how I would do it.
Get the file --> Enrich it with database call and get the receiever id etc --> Use Xpath and get the receiver id etc and set them in propertyor header --> Use XSLT and remove the values that you enriched for database call so now you have the original message ---> Now use router and look at properties/headers to decide the <camel:to> path