WSO2 BPS timer event bpmn - java

DO you know if it's possible to setup some timer event/task to wait for some time for receiving some action? For example, I need to set up some mechanism where I invoke timer task which waits for example for 10 seconds then I will restart checking process.
Thanks,

You can try <pick> It implements the deferred choice workflow pattern, i.e. it can wait for several messages and several timers concurrently. The event that occurs first wins and the contained activity will be executed.

So there is a exists for BPMN which we've used for our needs.

Related

In BPM,When an execution arrives in catching event activity, a timer is started but in my case it is getting started after execution is completed

I am new to this BPM , I have create workflow like below one
enter image description here
Currently this timer task is switching status from A to B , but i am using this from manual task as i am unable to trigger it when execution arrives at User task A.
My requirement is to trigger it from User task A as soon as execution arrives at User task A
This is a bit confusing, and maybe it would help if you explained what you are doing. It sounds like what you want is that when the token reaches A, you also have something else occur, and you are trying to do this using a 0 based timer on A? If I want something to happen in parallel to A I'd just put a split before A and have one path lead to A and the other lead to the other thing. The only time this won't work is when you need to hand data from A to the think you want to invoke. For example in IBM BPM if you want to send an e-mail to someone with the task ID in it, you have to put a timer on the task so that the task ID can be part of the timer payload.
If you explain the desired functionality of the model, we might be able to better tell you how to model this.

Start spring scheduling based on some Event

I need to start spring scheduling based on the constraint that my scheduler job will run every 5 seconds after a receive a jms message from other component.
What can be the possible way to implement /handle this scenario ,googled for the same but the solutions ask me to have a property in properties file for enabling scheduling which again is static approach.
Kindly suggest some solutions.
You can use:-
Thread.sleep(long delay) after receiving a message from JMS queue i.e. Thread.sleep(300000);
Basically your problem is not related to a scheduler. The message received from the queue is a trigger to invoke the job in your case.
Whereas the scheduled tasks are the ones which keeps repeating them periodically either based on fixed delay or fixed interval or at specific time.
Your job is event based and not on time based so its not a scheduled
job.

Remove EJB timer tasks from WebSphere Console

I have an EJB application and used EJB Timer to place some tasks(persisted database sequence ID) with expire date/time on it and once time expires remove the tasks from the Timer and invoke some method.
I am in situation that there are bunch of the tasks placed in EJB Timer and whenever Timer Timeouts and it gets each of the tasks from Timer and try to invoke some method that has to update some database associated with task id. I found some how those all tasks are deleted from database during some database moves.
Now Ejb Timer keep repeating the Timeout and the tasks keep throwing exception in logs. I don't the way I do not know how to remove these tasks from EJB Timer so it does not try to call method with each task id which are no longer there.
Any help will be appreciated!
Thanks!
There is no ability to remove timers from the admin console, but you can use the WAS_HOME/bin/cancelEJBTimers command to remove them. You can view them first using the findEJBTimers command.
Use cancelEJBTimer.sh command under /opt/IBM/WebSphere/AppServer/bin
(your path may be different).
Don't put any server name and filter and it will display the instruction. It is very easy to kill the zombie tasks.

Threads and event handling in Java

I am a Java newbie and an Android newbie too. I am working on a game and trying to understand the exact nature of events in Java and Android. I have a few questions to help understand the correct way to do event handling in my app.
Its a network game and so I need to check if the user made a move or not to update the view. Also I need to prompt the user to make a move if he takes too long. For this I have two threads -
Timer thread expires every 10 seconds and calls updateview if needed or prompts user to make a move.
Event thread gets created when user clicks on the screen to make a move or clicks on menu etc.
Is this the correct approach? These two can be fired at any time.
Here are the issues I see with this -
What happens when one thread gets run when the other one is active.
Which thread has precedence if both are started at the same time.
Do events in the timer thread get queued up?
If so can I pick which one in the queue to use?
Can I cancel events in the queue? For e.g. if I have 2 updateview events lined up in the queue I only have to call it once.
Thanks for any inputs.
P
I would suggest reading up on Android AsyncTask.
Consider that you can implement a timer WiTHOUT using a thread. Use a single Handler switching on what and send a postMessageDelayed(what 0,milliseconds) to the handler say every one second. You could set a counter variable to zero and check the flag every one second in the what 0 handler, incrementing the counter by one. If the value is >= ten, post a message and reset the variable to zero. If the user selects an action, reset the instance variable to zero.
A time consuming action can be run in a separate thread that messages the handler, perhaps using what 1, on completion. Or you could run a time consuming action in a separate asyncTask.
JAL

Implementing java FixedTreadPool status listener

It's about an application which is supposed to process (VAD, Loudness, Clipping) a lot of soundfiles (e.g. 100k). At this time, I create as many worker threads (callables) as I can put into memory, and then run all with a threadPool.invokeAll(), write results to file system, unload processed files and continue at step 1. Due to the fact it's an app with a GUI, i don't want to user to feel like the app "is not responding" while processing all soundfiles. (which it does at this time cause invokeAll is blocking). I'm not sure what is a "good" way to fix this. It shall not be possible for the user to do other things while processing, but I'd like to show a progress bar like "10 of 100000 soundfiles are done". So how do I get there? Do I have to create a "watcher thread", so that every worker hold a callback on it? I'm quite new to multi threading, and don't get the idea of such a mechanism.
If you need to know: I'm using SWT/JFace.
You could use an ExecutorCompletionService for this purpose; if you submit each of the Callable tasks in a loop, you can then call the take method of the completion service - receiving tasks one at a time as they finish. Every time you take a task, you can update your GUI.
As another option, you could implement your own ExecutorService that is also an Observable, allowing the publication of updates to subscribing Observers whenever a task is completed.
You should have a look at SwingWorker. It's a good class for doing lengthy operations whilst reporting back progress to the gui and maintaining a responsive gui.
Using a Swing Worker Thread provides some good information.

Categories

Resources