You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Flooooo <fl...@gmail.com> on 2008/04/14 00:07:47 UTC

Beanflow - Activity.fail() in run() => Stackoverflow

Hy, I am complete newbie to apache beanflow. Unfortunately i couldn't find
any good documentation on it, aport from
 API Doc: 
http://servicemix.apache.org/maven/servicemix-beanflow/apidocs/index.html
 Short Overview: http://docs.huihoo.com/apache/servicemix/beanflow.html


Now i have  the following problem: If I call the fail() method in the
run()-method of an a AbstractActivity => the run method gets called again
(therefore the fail() gets executed => run() => fail() => run() ... =>
stackoverflow)

Here my code:

        public static class Task1 extends AbstractActivity {

		public void startWithTimeout(Timer arg0, long arg1) {
			throw new UnsupportedOperationException("startWithTimeout not
implemented");
		}

		public void run() {
			System.out.println("Task1.start");
			try {
				Thread.sleep((long)Math.random() * 5000);
			} catch (InterruptedException e) {
			}
			System.out.println("Task1.finish");
		}
	}
	
	public static class Task2 extends AbstractActivity {

		public void startWithTimeout(Timer arg0, long arg1) {
			throw new UnsupportedOperationException("startWithTimeout not
implemented");
		}

		public void run() {
			// why gets run() called, if fail() is called?
			// => stackoverflow !!!
			System.out.println("Task2.start");
			try {
				Thread.sleep((long)Math.random() * 5000);
			} catch (InterruptedException e) {
			}
			this.fail("failed");
			System.out.println("Task2.finish (failed)");
		}
	}
	
	public static void main(String[] args) {
		
		JoinAll flow = new JoinAll(new Task1(), new Task2());
		
		// why does fail-fast not work
		flow.setFailFast(true);
		
		System.out.println("flow.start");
		flow.start();
		System.out.println("flow.end");
	}


I guess i do misunderstand the use of activities and flows somehow ... can
anybody help me with that?

if i put something like

             public void run() {
			if(this.isFailed() || this.isStopped())
				return;
                     ....
             }

=> it works, ... but the fail-fast of the JoinAll() still does not work
(both activities get executed)

thanks, flo
-- 
View this message in context: http://www.nabble.com/Beanflow---Activity.fail%28%29-in-run%28%29-%3D%3E-Stackoverflow-tp16668810p16668810.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.