I created custom background job following instruction.
You can see also discussion regarding this problem.
Created task handler and constructor of task is called every minute. Process method is never called. Also I am getting timeout exception "Orchard.Tasks.BackgroundService - Error while processing background task".
It is interesting that it is possible to add new task, but any query won't work.
I checked table Scheduling_ScheduledTaskRecord and it was locked. I am getting timeout exception in code and SQL Management interface. Lock is released once I turn of site process.
You are describing Scheduled tasks, that run on the background.
In order to trigger the execution of Process you need shcedule the first task (thus starting the loop). Use DateTime.UtcNow to schedule tasks.
You can also use Background Tasks, this way:
public class MyBackgroundService : IBackgroundTask {
public MyBackgroundService() {
}
public void Sweep() {
//Background task execution
//DO some work
}
}
Sweep() will be executed every 60 seconds. I don't know if this suit you, because this will be executed every minute even if the previous task is still running.
Related
In a java EE application I have one scheduledExecutorService with 2 timers on it.
The first via scheduledExecutorService.scheduleAtFixRate(), the second via scheduledExecutorService.schedule().
The first will activate a runnable every 2 seconds, the second will end after 60 seconds.
After the 60 seconds the scheduledExecutorService is stopped, so both timers are gone.
All is working fine with system.out statements in de runnables. But when I put a database read in the runnable of the timer on the 2 second interval the runable is activated only once and looks like to be pausing, the system.out with the read-result is not displayed and schedule is not running the runable every 2 seconds.
After the 60 second, the scheduledExecutorService is stopped and after that the system.out with the result of the database read is shown.
Any idea what may be causing this behaviour?
NB: Based on google-searches I have surrounded the database-read with a try catch catching Throwable but no Throwable is catched...
At first the result of the database was not shown, but that was solved by putting #Stateless and #TransactionType in the class from with the read is actually called.
The actual functionality I try to accomplish is to have two "timers" running. One on a interval of 2 seconds, one only as a count-down max waiting time.
In the 2 second intervals a database check is done to see if a certain value becomes true. If that's the case both timers need to stop and the calling program may continue. If the certain value stays false all the time the calling program may continue if the time of the count-down is done.
I'm trying to create an INTransfer and release it after an INReceipt is made on the Release action within the Move page of the Manufacturing Module. I've been getting an error stating that no inventory is available, but it is not consistent. After doing some digging, I believe it is because the release of the receipt is not finished before I execute my call to INDocumentRelease.ReleaseDoc(). I found that if I add a thread sleep, it will execute no problem every time, but I don't want to force the user to wait X seconds every time they execute that release. Is there a way I can check if the release process thread is complete for the INReceipt and wait if it is not to execute my release?
The problems I am having is that I don't know if there is a way to grab the ID of the PXLongOperation thread that is executing the INReceipt release function. If there is, I know there is a way to execute a PXLongOperation.WaitCompletion() function I can execute. I believe I would execute that right before calling my PXLongOperation if I am able to get the threadID.
Consider usage of IPXCustomInfo. Here I've described how to react on clicking on Abort, but also you can consider how to add reaction on Completed and InProcess cases:
case PXLongRunStatus.Completed:
SomeReactionOnCompleted();
break;
case PXLongRunStatus.InProcess:
SomeReactionOnInProcess();
break;
I had scheduler used in portlet which will be triggering for each 5 minutes.
following are the configurations:
liferay-portlet.xml:
<scheduler-entry>
<scheduler-description>
This scheduler is used to invoke the update and delete results
</scheduler-description>
<scheduler-event-listener-class>com.test.myown.scheduler.action.GetResultsScheduler</scheduler-event-listener-class>
<trigger>
<simple>
<simple-trigger-value>5</simple-trigger-value>
<time-unit>minute</time-unit>
</simple>
</trigger>
</scheduler-entry>
And my class is :
public class GetResultsScheduler implements MessageListener{
public void receive(Message message) throws MessageListenerException {
// some code here
}
}
we are using liferay 6.1,weblogic server
Here the problem is, There are 2 nodes for server ,
Scheduler is triggering for 5 minutes in node1
There is no scheduler triggering in node 2
What I meant say is, scheduler is working in node 1 and not working in node2.
Can any one have any idea about this issue?
I'd say this is expected: When you run some frequent jobs, you might not want to execute them concurrently on each machine, as they'll get in conflict. You've stated that the job must be executed every 5 minutes, not twice every 5 minutes (as it would be if every machine would fire it).
If you take down node1, I'd also expect node2 to take over the duty of executing the scheduled jobs. This will be a good test for the correctness of the assumption stated above.
Also, you shouldn't rely on such jobs to execute in each VM (probably manipulating common state, shared through the classloader). If you modify content that is cached, the cluster communication should take care to invalidate the classes.
If you have problems with this, you're either violating that (my) assumption of the global state in the VM, or you've not configured the cluster cache invalidation correctly.
I'm a complete noob with JavaFX 2 - (started this morning with a HelloWorld that I'm adapting).
I need to update a Text node with the result of a background thread. Is there anything special I need to be aware of with JavaFX2 or is it simply enough to submit a callable and update the text. A pointer to a tutorial would be appreciated.
After calculating the results, running the
Platform.runLater(new Runnable() {
#Override
public void run() {
// Update the text node with calculated results
}
});
at the end of the same background thread is enough in normal situations. This link also maybe helpful:
Execute task in background in JavaFX.
Platform.runLater() will run later on the JavaFX application thread - which is fine if the executed content is a quick running task (e.g. inexpensive computation without I/O or just a call to update the UI). Use a Timeline for animation or timer based things. Otherwise a Task or Service based solution, for which there is a tutorial. Don't ever read or write from objects involved in an active scenegraph (even updates triggered by binds) off of the JavaFX application thread. Some further discussion and examples are in this forum thread.
This might seem like a silly thing to say, the final branch in a parallel activity so I'll clarify. It's a parallel activity with three branches each containing a simple create task, on task changed and complete task. The branch containing the task that is last to complete seems to break. So every task works in it's own right, but the last one encounters a problem.
Say the user clicks the final tasks link to open the attached infopath form and submits that. Execution gets to the event handler for that onTaskChanged where a taskCompleted variable gets set to true which will exit the while loop. I've successfully hit a breakpoint on this line so I know that happens. However the final activity in that branch, the completeTask doesn't get hit.
When submit is clicked in the final form, the operation in progess screen says of for quite a while before returning to the workflow status page. The task that was opened and submitted says "Not Started".
I can disable any of the branches to leave only two, but the same problem happens with the last to be completed. Earlier on in the workflow I do essencially the same thing. I have another 3 branch parallel activity with each brach containing a task. This one works correctly which leads me to believe that it might be a problem with having two parallel activites in the same sequential workflow.
I've considered the possibility that it might be a correlation token problem. The token that every task branch uses is unique to that branch and it's owner activity name is est to that of the branch. It stands to reason that if the task complete variable is indeed getting set to true but the while loop isn't being exited, then there's a wire crossing with the variable somewhere. However I'd still have thought that the task status back on the workflow status page would at least say that the task is in progress.
This is a frustrating show stopper of a bug for me. Any thoughts or suggestions would be much appricated so I can investigate them.
my workflow scenario is to reassign task to it's originator after due date of the task expires, by firing a delay activity.
in my workflow I have a parallel replicator which is used to assign(create) different tasks to different users at the same time.Inside replicator I used a listen activity so in the left branch there is a OnTaskChanged activity+...+ completetask1, In the right branch of listenActivity there is a Delay Activity followed by a CompleteTask2 activity and a code activity to reassign task to task originator.I'm sure about the correlation tokens on both completetasks activities.every thing works fine on the left branch but error occurs in the right branch which contains Delay activity-->Completetask activity.
let consider that we have two tasks assigned to 2 users and they have one hour to complete their tasks, but they didn't.so Delay activity fires for both tasks.then in workflow first task will be completed but for the second task it makes error.
I think the problem is with taskid property of the completetask.it doesn't updated with the second task id, so it tries to complete a task which has been completed.