1

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

Deepak S
  • 11
  • 3
  • Looks like generated `timerInfo` string is incorrect at some point. Are you able to somehow catch example value and post it here? – KazikM Dec 10 '20 at 13:25
  • This is what it is generating in the file -- "0/10+*+*+?+*+*+*" – Deepak S Dec 11 '20 at 06:46
  • This is no space, no invalid character found in the cron expression. But still its saying illigal character. But once I do the URLencoding the program runs also trigger the cron. But it doesn't trigger as par the given cron expression – Deepak S Dec 11 '20 at 07:17

0 Answers0