Hello,

would the following route work correctly with multiple threads? In
beanRef("TestProcessor", "step2") the instance variable mapper is used, so I
suppose it is not thread safe, right? Should I set the mapper as a property
of the exchange?

        from(inputsource)
            .beanRef("TestProcessor", "step1")
            .beanRef("TestProcessor", "step2")
            .beanRef("TestProcessor", "step3")
            .log("${body}")


package testcamel;

import java.util.Map;
import org.apache.camel.Headers;

public class TestProcessor {

    private String generator;
    private JsonMapper mapper;

    public String step1(String filedata, @Headers Map headers) {
        //create mapper for each new message
        mapper = new JsonMapper();
        //do something here
        return "resultFromStep1";

    }

    public String step2(String contentFromStep1) {
        //do something here with mapper
        mapper.doSomething();
        return "resultFromStep2";
    }

    public String step3(String contentFromStep2) {
        //do something here with mapper
        mapper.doSomething();
        return "resultFromStep2";
    }

}



--
View this message in context: 
http://camel.465427.n5.nabble.com/bean-members-with-parallel-processing-tp5749157.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to