I am running a Quartz cronjob in my tomcat container, which fires certain schedulers every minute, as shown by the following code:
<bean id="cronjobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="job_detail" />
<property name="cronExpression" value="0 */1 * * * ?" />
</bean>
Now, I intend to write my own unit testing, which needs to fire this Cronjob and then check some consequent output file once the Cronjob is done. In stead of waiting for one minute every time in the unit testing, is it possible to trigger the Cronjob which runs inside my Tomcat, so that the test case won't have to wait for the scheduling interval?
Thanks!
OK, it seems that to keep the container running behind is a better idea...
Related
I am trying to use WSO2 to schedule pooling data call every minutes to a REST API my business has and push that information to our centralize MQTT broker.
I've been reading the documents of the Streaming Integrator, Micro Integrator, Micro Gateway and API Manager and I cannot find any way to schedule REST API calls base on a defined time.
The point of this task is to push data from all our system into our centralize broker and add analyzing tool afterward to benefit from the data created by our systems that is only accessible by the system at this time.
Could someone give me a hint on what should be the right tools for this and maybe the link to some documentation about how to configure time base call if the software wso2 allowed it ?
You can create a WSO2EI scheduled task
You can define a cron job expression for timing and execute a sequence or an implementation class.
example:
<task name="SampleInjectToSequenceTask"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger interval="5"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="sequence"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="sequenceName"
value="SampleSequence"/>
</task>
I need to create parallel running service tasks in my process.
Try to create the simplest flow with async property usage:
With loop cardinality = 5 (for example)
I found that in activiti.xml configuration it's required to add this property:
<property name="asyncExecutorActivate" value="true" />
But flow still runs in one thread.
What i'm missing?
How to activate async correctly?
to activate async parallel execution in the example above - need to set async on Call Service and not on Sub Process
as soon as we use async we have to configure process engine to be async
otherwise you will meet this king of exception:
org.activiti.engine.ActivitiOptimisticLockingException: VariableInstanceEntity[id=15317, name=nrOfActiveInstances, type=integer, longValue=1, textValue=1] was updated by another transaction concurrently
the parameters of activiti engine on wso2bps stored here: conf/activiti.xml
just add the following properties to bean id="processEngineConfiguration"
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
...
<property name="asyncExecutorActivate" value="true" />
<property name="asyncExecutorEnabled" value="true" />
...
</bean>
warn: don't know if it's feature or bug. subprocess will catch correctly all thread endings only if you set async on end events of subprocess...
after those changes, the process from question works great in multithread mode.
We currently call SOAP web services which send back very big responses.
We use Spring-WS (using WebServiceTemplate), JAX-WS client while invoking the web services and the application is run on Jboss EAP 6.0.
We also use SaajSoapMessageFactory currently. I read from forums that AxiomSoapMessageFactory should be used rather than SaajSoapMessageFactory (http://docs.spring.io/spring-ws/site/reference/html/common.html) to improve reading performance.
I made the following modification:
Replaced
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11" />
</property>
</bean>
by
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
<property name="payloadCaching" value="false"/>
</bean>
This change worked fine as expected. But from a performance perspective, I am getting surprising results.
For a test with 50 users concurrently accessing the web service (indirectly via a screen that in turn invokes the web service), the overall response time (moment the button is clicked to the moment the response from the web service is displayed back on the screen) reduced from ~ 27 secs to 22 secs -that's a good 5 second improvement over SaajSoapMessageFactory.
However, when I ran a 100 user test, the response time increased by 2 secs and SaajSoapMessageFactory appears to be better in this case.
Can someone explain the reason for this difference in performance despite AxiomSoapMessageFactory using streaming and avoiding building tree??
I set my schedule item schedule as:
20090326T112200|20990426T112200|127|00:20:00
It should be run every 20 minutes. But it seems this schedule has never run after I deploy them.
The scheduling in web.config looks like this:
<scheduling>
<!-- Time between checking for scheduled tasks waiting to execute -->
<frequency>00:05:00</frequency>
<!-- Agent to process schedules embedded as items in a database -->
<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:10:00">
<param desc="database">core</param>
<param desc="schedule root">/sitecore/system/tasks/schedules</param>
<LogActivity>true</LogActivity>
</agent>
<!-- Agent to process schedules embedded as items in a database -->
<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:10:00">
<param desc="database">master</param>
<param desc="schedule root">/sitecore/system/tasks/schedules</param>
<LogActivity>true</LogActivity>
</agent>
Any help? Thanks.
I come across this post when trying to figure out why scheduled tasks weren't firing and thought i'd post a solution to a specific scenario i had.
The problem i found was that I installed the Sitecore SIM InitializeSpeedBooster.cofig which removes the following which stops scheduled tasks from running.
<processor type="Sitecore.Pipelines.Loader.InitializeScheduler, Sitecore.Kernel">
<patch:delete />
</processor>
Remove that patch:delete from the config and you'll still have a quicker initialisation of Sitecore, but with Scheduled tasks running.
A more detailed explanation can be found on my blog post for Sitecore scheduled tasks not working.
Sitecore will only run scheduled tasks if the application pool has not cycled down. In other words, if your application does not receive enough traffic IIS may cycle down the application pool to conserve resources. To prevent this from happening you could setup a keep-alive service that makes a request to your application on a set interval insuring that the application pool never cycles down.
Scheduling is a consistent problem in ASP.NET applications due to its architecture. Sitecore has attempted to fix this issue, but does a middling job of it, in my opinion. Barbosa describes one definite problem, but Sitecore has a built-in keepalive system you can use. In my web.config (version 6.3), that is configured directly after the DB scheduling agent you posted.
We don't have all the information we need to assess the problem. However, from your comment, it seems that your Last Run field is empty? This is a problem. It must have a value for scheduling to work. Scheduled items only kick off if the time interval between 'Now' and the Last Run value is greater than the time value in the Schedule field.
Here is an example from my Sitecore site that is working correctly (RAW values):
Schedule: 20000101|21000101|127|23:59:00
Last run: 20121126T074001
So... next question is this: Do you see the output from the scheduling agent in your log? First make sure you are logging INFO level. You should see something like this:
1924 10:40:22 INFO Scheduler - Adding agent: Sitecore.Tasks.DatabaseAgent (interval: 00:10:00)
If you DON'T see that, then Sitecore is not kicking off the Scheduler and you should open a Sitecore support request. If you DO see this, then the problem is most likely your Sitecore Schedule or Command items. You should see output from the schedule agent that it is starting/stopping your particular command. This is where error output will occur if your scheduled item is failing. Which brings us to the next step...
Your Schedule item has a Command field, which must link to a valid item under System/Tasks/Commands. That item's Type and Method field actually specific which method is being executed. If those are set correctly, the next step I would take is to create a one-off ASPX page with a single button... which executes this method. If that doesn't work... well, then you know where the problem lies.
Hope this helps.
This is pretty simple question. I am posting this because I couldn't get any satisfying answer. First the background: I have Jenkins job that builds and deploys a web application on to a server. The server takes some time (in the order of 5 to 10 minutes). I would like to setup a job (or modify the existing as required) to rig up the unit test case execution which will test the application. I am thinking of the following approaches. I would like you to validate or suggest any alternatives:
Have an Ant target that waits for a fixed time
Have a custom Ant target which pings the URL and checks for app availability
Thanks in advance for your help.
-Vadiraj.
Waiting for a fixed time has the problem that the time you choose is either to short (build fails) or to long (waste of build time). So I think it would be better to check if the app is available.
I have done something similar for my Selenium tests. I had to wait until the Selenium Remote Server has started. I used the waitfor element. For a detailled documentation see here.
Here is a stripped down version of my ant-Target:
<parallel>
<sequential>
... Start web application server ...
</sequential>
<sequential>
<waitfor maxwait="10" maxwaitunit="minute">
<socket server="localhost" port="8080" />
</waitfor>
<junit>
...
</junit>
</sequential>
</parallel>
If your server is available before the web app is deployed you can try to use the http condition instead of socket to check for a HTTP error code. The conditions are documented here.