Here is the original process def:
http://static.flickr.com/20/71523252_c5116f6d9a.jpg?v=0

Here is the new process def:
http://static.flickr.com/20/71779978_7df2acc810.jpg?v=0

parallel1 and parallel2 are designed to go into wait states. I then signal 
their respective tokens which causes parallel1b and parallel2b to run. each 
waits 30 seconds before continuing, so I have time to signal the tokens.

Notice the inclusion of a refresh state in each branch before the join. The 
purpose of this state is to cause the branch to exit (no signal). Just before 
falling out, it fires off a thread that is designed to resignal the token. This 
causes the branch to continue past the refresh node with state refreshed.

It works. I've tested it. I was really really close to chucking jBPM 
completely, so this insight saved a headache on my part...

This code is not perfect and I intend on improving today. I want make these 
changes:
1. have the thread wake up every second checking to see if the token is 
finished (I think I should be able to do this).
2. create some sort of symaphore so that a save of state and load of state are 
synchronous for a process instance. Since this could happen across VMs, it will 
be interesting.

Here is the code snippet:
call this in the execute of a class in the node-enter of refresh:
Refresh r = new Refresh(context.getToken().getId());

This is the inner class:
> Note that ProcessWrapper is a convenience class I've created to do common 
> things in jBPM without having to worry about all the details. It is normally 
> called by a URL using jetty...

        // Class to re-signal the token after it falls out of scope
        private class Refresh implements Runnable {
                
                private long tokenId;
                
                public Refresh(long tokenId) {
                        this.tokenId = tokenId;
                        Thread t = new Thread(this);
                        t.start();
                }
                
                public void run() {
                        
                        try {
                                // Sleep for 10 seconds (that should be more 
than enough for the 
                                // persistance of this step to complete)
                                Thread.sleep(10000);
                                
                                // Re-signal 
                                ProcessWrapper wrapper = new ProcessWrapper();
                                log.info("about to signal token from refresh: " 
+ tokenId);
                                wrapper.signalToken(tokenId);
                                log.info("token signaled from refresh: " + 
tokenId);
                                
                        }
                        catch (Exception ex) {
                                log.error("Was unable to refresh token before 
join: " + tokenId);
                        }
                        
                }
                
        }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3911737#3911737

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3911737


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to