[ https://issues.apache.org/activemq/browse/SM-504?page=comments#action_36665 ] Andreas Held commented on SM-504: ---------------------------------
To add some more information: The first time, the steps are being executed from Workflow.java:102, I believe that this is the problem, as this calls DefaultState.set and SynchronousNotifier.run. This then exexcutes all the listeners and calls Workflow.run again. o be honest, I do not quite understand line DefaultState.java:73. What is the meaning fo the notifiers? Regards Andreas. > Beanflow: Multiple execution of beanflow steps > ---------------------------------------------- > > Key: SM-504 > URL: https://issues.apache.org/activemq/browse/SM-504 > Project: ServiceMix > Issue Type: Bug > Affects Versions: incubation > Environment: Windows2K, running ServiceMix under JBoss4.0.3SP1 > Reporter: Andreas Held > Assigned To: james strachan > > Consider the following simple Beanflow example: > public class TestWorkflow extends Workflow<String> { > private static Logger log = > Logger.getLogger(TestWorkflow.class.getName()); > public static int count = 0; > public TestWorkflow() { > super("startStep"); > } > public String startStep() { > count += 1; > log.info("Workflow: Validation"); > // next step > return "persistenceStep"; > } > public String persistenceStep() { > count += 1; > log.info("Workflow: Persistence"); > // next step > return "transferStep"; > } > public String transferStep() { > count += 1; > log.info("Workflow: Transfer"); > // next step > return "stop"; > } > } > If I write a JUnit test case with assertEquals(workflow.count, 3); then > this will fail, as count has a value of 5. Looking at the log shows the > following output: > 08:19:26,335 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: startStep > 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.startStep()] > FileActWorkflow: Validation > 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: persistenceStep > 08:19:26,351 INFO > [ch.bbp.igt.comm.ServiceMix.TestWorkflow.persistenceStep()] > FileActWorkflow: Persistence > 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: persistenceStep > 08:19:26,351 INFO > [ch.bbp.igt.comm.ServiceMix.TestWorkflow.persistenceStep()] > FileActWorkflow: Persistence > 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: transferStep > 08:19:26,351 INFO > [ch.bbp.igt.comm.ServiceMix.TestWorkflow.transferStep()] > FileActWorkflow: Transfer > 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: transferStep > 08:19:26,351 INFO > [ch.bbp.igt.comm.ServiceMix.TestWorkflow.transferStep()] > FileActWorkflow: Transfer > 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: stop > 08:19:26,367 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About > to execute step: stop > This means, all steps but the start step are executed twice! This > corresponds to count being 5 in the end! > JUnit Testcase : > public class WorkflowTest extends TestCase { > public WorkflowTest(String s) { > super(s); > } > protected void setUp() { > } > protected void tearDown() { > } > public void testTest() throws Exception { > TestWorkflow workflow = new TestWorkflow(); > workflow.start(); > Thread.sleep(2000); > assertEquals(3, workflow.count); > } > public static Test suite() { > TestSuite suite = new TestSuite(); > suite.addTest(new WorkflowTest("testTest")); > return suite; > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira