I am using a Quartz2 route (from) to trigger the job as per the given cron expression. This works when I given the cron as hardcoded e.g.

from("quartz2://group1/trigger1?**cron=0/30+*+*+?+*+*+***&stateful=true")

As the cron expression is being built dynamically, hence I am retrieving it from FileInputStream and providing it to the cousumer route but it doesn't work this way, though the variable has the correct/valid cron. e.g.

final String timerInfo=readFromInputStream(inputStream);
from("quartz2://group1/trigger1?cron="+**timerInfo**"&stateful=true")

Below is the error I am getting after using the variable timerInfo.

Caused by: java.net.URISyntaxException: Illegal character in query at index 47: quartz2://group1/trigger1?cron=0/20+*+*+?+*+*+*

As a solution What I have tried is to encode the timerInfo variable something like this -

final String timerInfo=URLEncoder.encode(readFromInputStream(inputStream), "UTF-8");

After that there is no error but cron is not triggering as per the given value. I think something has gone wrong while encoding. Is there any better solution to resolve the above mentioned error ?

Thanks Deepak

0

There are 0 best solutions below