Quarkus Camel SFTP route Quartz schedule not starting - apache-camel

I have configured an SFTP Camel route with Quartz scheduling in a Quarkus v1.7.1 app. The app starts up without errors, but the Quartz schedule doesn't actually start because it thinks there is no work to be done.
My route is defined by
from("sftp://sftp.server.com:22/path?"
+ "binary=true&"
+ "streamDownload=true&"
+ "password=*****"
+ "username=user&"
+ "jschLoggingLevel=TRACE&"
+ "antInclude=*.zip&"
+ "scheduler=quartz&"
+ "scheduler.cron=0 0/5 00-23 * * ?")
.to("file://c/Temp/");
In the log I see
[org.apa.cam.com.qua.QuartzComponent] (Quarkus Main Thread) Starting scheduler.
[org.qua.cor.QuartzScheduler] (Quarkus Main Thread) Scheduler DefaultQuartzScheduler-quarkus-camel-ftp_$_NON_CLUSTERED started.
[io.qua.qua.run.QuartzScheduler] (Quarkus Main Thread) No scheduled business methods found - Quartz scheduler will not be started
I expected it to start and poll the FTP server every 5 minutes. But nothing happens. Is my assumption incorrect?

Related

How to immediately shut down Apache camel transactions

So Apache camel has this graceful shutdown feature that waits 300 seconds, and it's really annoying. I say this because I'm running local testing and I get errors where a request will hang, and I want to abort it by shutting my app down. But then I get stuck waiting for 5 mins for all inflight transactions to finish.
I want the ability to disable this graceful shutdown waiting period for my local testing so I can just kill the whole process and start over. Any advice would be appreciated.
You can set shutdown timeout to some lower value. There are many options to set shutdown timeout value:
Spring Boot property - camel.springboot.shutdownTimeout = 1
ShutdownStrategy property - getContext().getShutdownStrategy().setTimeout(1)
With environment variable (camel-main only) - java -DCAMEL_MAIN_SHUTDOWNTIMEOUT=1 ...
At runtime with JMX operation setTimeout() on MBean org.apache.camel:context=MyCamel,type=context,name="MyCamel"
For more details see Graceful shutdown.
In Camel 3.1 and later will be default shutdown timeout reduced to 45s - CAMEL-14336.
Here's the documentation of the spring boot property: https://camel.apache.org/camel-spring-boot/3.7.x/spring-boot.html
camel.springboot.shutdown-timeout | Timeout in seconds to graceful shutdown Camel. | 300 | Integer
Setting camel.springboot.shutdownTimeout = 1 in the application test properties was the easiest way to adjust this.

Apache Camel SWF does not schedule second Activity in the workflow

I have created a sample apache camel swf application based on Spring Boot. It works as expected for the first activity but even though it seems to schedule the second activity, the activity does not get invoked.
Reference to sample application - https://github.com/kpkurian/camel-aws-swf-shopping-cart-wf
The log shows below line
2018-01-18 00:23:32.705 DEBUG 9456 --- [erMasterQueue 1] o.apache.camel.processor.SendProcessor : >>>> aws-swf://activity?activityList=&amazonSWClient=%23swfClient&domainName=name&eventName=<2nd activity name>&version=5.0
The history shows 2nd activity is not scheduled. I can see the WorkflowExecutionCompleted event in the end.
2nd activity not scheduled screenshot

Camel Route for Javamail Not Stopping on Shutdown

I've a simple route
from(
"myQuartz://EMAIL_Route?cron=0+0/5+*+*+*+?")
.routeId("EMAIL_Route")
.shutdownRunningTask(
ShutdownRunningTask.CompleteCurrentTaskOnly)
.beanRef("errorReportProcessor")
.filter((body().isNotNull()))
.to("smtp://smtpHost?From=someone&to=someoneElse&Subject=something").end();
Even if I shutdown the application in Websphere application server, I still continue to get emails. The scheduler/thread is not stopping. In my quartz properties file, I also tried
org.quartz.scheduler.makeSchedulerThreadDaemon=true
but, fruitless. The Camel, Quartz and Mail component version is 2.12.4. Spring 3.2.5.Release. Websphere 8.
SystemOut.log files clearly mentions, the application stopped without errors. However, I can see a java.exe instance running in task-manager.
OK. I found the issue was with missing "root-app-context". Once, I configured the "root-app-context", the Cron-scheduler is now stopping and no more stranded threads. :)
Even the extra configuration to makeSchedulerThreadDaemon was not required.
org.quartz.scheduler.makeSchedulerThreadDaemon=true

Apache Camel "CronScheduledRoutePolicy" - route is not active if the server is restarted between start time and stop time

I am using Camel "CronScheduledRoutePolicy" to have my route (for jms queue) to be active between certain hours.
CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
policy.setRouteStartTime("0 0 9 * * ?");
policy.setRouteStopTime("0 0 18 * * ?");
from("jms:inboundqueue").routePolicy(policy).noAutoStartup()
....
It works fine as expected by starting the route at 9am and stopping it at 6pm, but if the server is restarted between these hours, the route is not active.
is there a way to check if the route should be active during server start up ?

WebSphere HTTP 500 while copying 10 GB file

Configuration:
We have iPlanet web server which sits before WebSphere portal 6.1 cluster (2) deployed in Linux machines.
When user tries to copy a 10 GB file across file systems (NFS mounted), we are using java run time to copy the file across to a different NFS mount, hoping that it would be faster than using any other java libraries.
proc = rt.exec("cp " + fileName + " " + outFileName);
Application deployed is a JSF portlet application.
a) session timeout is 60 mins on the app server and the application
b) we have an Ajax call from the client page to keep the session alive
User receives HTTP 500 within 3 minutes, while our logs show that file is still copying. Not sure why WebSphere is sending HTTP 500?
After 10 minutes are so file is copied, and when he clicks on refresh he can proceed.
Not sure what is causing this HTTP 500.
WebContainer threads are not supposed to be used for long tasks.
He's getting 500 after 3 minutes because that is the time WebSphere decides the thread is hung.
What you should be doing is using a WorkManager to perform that long task and the client can poll to check the status of the task.
If you consider upgrading to WAS v8/v8.5 in the near future a good idea will be to use Asynchronous Servlets for that
The reason that your client receives an HTTP 500 error after a few minutes can happen for a few reasons. Without a stack trace and some relevant logging, it is impossible to know which component within WebSphere "woke up" after 3 minutes and stopped everything. It might be WebSphere's timeout setting for the Web Container thread pool, or it can be some other timeout - should be easily concluded from the logs.
To fix this, you can do one of the following:
Adjust the relevant timeout value (depending, again, on which timeout it is exactly).
Change your design so long-running tasks are executed in the background. You can use WebSphere's Work Manager API for that, or asynchronous beans / servlets.

Resources