Created 09-27-2020 09:46 PM
@MattWho @TimothySpann @Shu_ashu
Currently, I am trying to fetch data from the MongoDB with help of the GetMongo processors which is working fine but in case if any of the required parameters are not valid (i.e. collection name, database name, and so on) it should throw an error which is not happening it is keep on running. In the case of SQL processor (i.e. ExecuteSQL, QueryDatabaseTable, and so on) if any of the required parameters is invalid it throws an error (For example, the password is invalid, table/view does not exist, and so on) expecting the same kind of behavior in case of MongoDB processor.
Is there any way to validate the required parameters.
Created 09-28-2020 06:20 AM
Maybe a bug or oversite. GetMongo is a community processor, post or update a JIRA
Created 09-28-2020 08:29 PM
Thanks, @TimothySpann for the quick reply. Even I have tried the same scenario with the RunMongoAggregation processor it is also keeping running in case of invalid credentials instead of throwing an error.
Created 09-28-2020 10:01 PM
Created 09-29-2020 07:14 AM
It looks like it does normal error checking
Created on 09-29-2020 02:10 PM - edited 09-29-2020 02:14 PM
Hi @vineet_harkut ,
To check if the required parameters are valid in MongoDB processor, what I would do is
Suppose, there is a query like {"key":"someValue","name":"someOtherValue"}.
And "someValue" and "someOtherValue" are values inside the attributes of the incoming flowFile with attribute-names "key" and "name" respectively. Hence, the resulting query in the GetMongo processor will be {"key":"${key}","name":"${name}"}.
Before using the GetMongo processor, I would use RouteOnAttribute processor to check if the input to the query is a valid one.
If the input is correct, I will make a query to the GetMongo processor. If the document for the query is not found, the GetMongo processor will return empty document (empty string) as content in the flowfile only when Send Empty Result is set to true inside the GetMongo processor.
Later, when I use EvaluateJsonPath processor, the flowfile will be routed to "failure" when the flowfile is empty, as empty string is not a valid JSON or to "matched" if the match for the given jsonPath is found.
This will put the same content inside the flowfile as $ corresponds to entire JSON object that we are getting from the input flowfIle.
Now, you can add the remaining logic.