FAQ
I am trying to upgrade to Camel 2.0 and running into a weird issue. Say i
have the following route:
<route>
<from uri="jms:jms/queue/>
<process ref="someProcessor" />
<to uri="bean1" />
</route>

Here i am not specifying any method name explicitly for bean1 and I am
depending on Camel's bean binding.
The first time a message is pulled from jms:jms/queue, the correct method
(say method1) is invoked on bean1 (matching the exchange's body to the
bean's method parameter types). From next time onwards, Camel is holding the
reference to method1 in bean1's BeanProcessor and is invoking
bean1.method1() for all subsequent messages pulled from jms:jms/queue.

I am noticing this behavior only in Camel 2.0. It was working fine until
Camel 1.6.

Btw, I am using InOut exchange pattern when seding the messages to
jms:jms/queue.

Can anyone please help!!!

Search Discussions

  • Sasidharm at Oct 11, 2009 at 7:24 pm
    Here is a test that illustrates the issue:

    import javax.naming.Context;
    import junit.framework.Assert;
    import org.apache.camel.ContextTestSupport;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.util.jndi.JndiContext;

    public class CamelBeanEndpointTest extends ContextTestSupport {


    public void testRoute() throws Exception {

    String stringBody = "stringBody";
    String stringResponse = (String)template.requestBody("direct:in",
    stringBody);
    Assert.assertEquals(stringBody, stringResponse);

    Integer intBody = 1;
    Integer intResponse = (Integer)template.requestBody("direct:in",
    intBody); //classcastexception
    Assert.assertEquals(1, intResponse.intValue());
    }

    protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
    public void configure() {
    from("direct:in").
    to("bean:myBean");
    }
    };
    }

    @Override
    protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());
    return answer;
    }

    public static class MyBean {

    public Integer intRequest(Integer request) {
    return request;
    }

    public String stringRequest(String request) {
    return request;
    }

    }

    }

    This unit test fails with a ClassCastException when using Camel 2.0. This
    test passes for earlier versions of camel.

    I am dead in the water right now, as our application has routes that depend
    on camel's bean-binding mechanism. I would really appreciate if someone
    could look into this issue.

    Thanks,
    Sasi
  • Willem Jiang at Oct 12, 2009 at 3:42 am
    Hi,

    I just checked the change log of the code, this issue was introduced by
    my change of CAMEL-1777[1].
    So I created a JIRA[2] for it and will did a quick fix for it.

    [1]http://issues.apache.org/activemq/browse/CAMEL-1777
    [2]http://issues.apache.org/activemq/browse/CAMEL-2060

    Willem

    sasidharm wrote:
    Here is a test that illustrates the issue:

    import javax.naming.Context;
    import junit.framework.Assert;
    import org.apache.camel.ContextTestSupport;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.util.jndi.JndiContext;

    public class CamelBeanEndpointTest extends ContextTestSupport {


    public void testRoute() throws Exception {

    String stringBody = "stringBody";
    String stringResponse = (String)template.requestBody("direct:in",
    stringBody);
    Assert.assertEquals(stringBody, stringResponse);

    Integer intBody = 1;
    Integer intResponse = (Integer)template.requestBody("direct:in",
    intBody); //classcastexception
    Assert.assertEquals(1, intResponse.intValue());
    }

    protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
    public void configure() {
    from("direct:in").
    to("bean:myBean");
    }
    };
    }

    @Override
    protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());
    return answer;
    }

    public static class MyBean {

    public Integer intRequest(Integer request) {
    return request;
    }

    public String stringRequest(String request) {
    return request;
    }

    }

    }

    This unit test fails with a ClassCastException when using Camel 2.0. This
    test passes for earlier versions of camel.

    I am dead in the water right now, as our application has routes that depend
    on camel's bean-binding mechanism. I would really appreciate if someone
    could look into this issue.

    Thanks,
    Sasi
  • Willem Jiang at Oct 12, 2009 at 4:57 am
    The patch is committed into the SVN repository.
    http://svn.apache.org/viewvc?rev=824218&view=rev

    Willem

    Willem Jiang wrote:
    Hi,

    I just checked the change log of the code, this issue was introduced by
    my change of CAMEL-1777[1].
    So I created a JIRA[2] for it and will did a quick fix for it.

    [1]http://issues.apache.org/activemq/browse/CAMEL-1777
    [2]http://issues.apache.org/activemq/browse/CAMEL-2060

    Willem

    sasidharm wrote:
    Here is a test that illustrates the issue:

    import javax.naming.Context;
    import junit.framework.Assert;
    import org.apache.camel.ContextTestSupport;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.util.jndi.JndiContext;

    public class CamelBeanEndpointTest extends ContextTestSupport {


    public void testRoute() throws Exception {

    String stringBody = "stringBody";
    String stringResponse = (String)template.requestBody("direct:in",
    stringBody);
    Assert.assertEquals(stringBody, stringResponse);
    Integer intBody = 1;
    Integer intResponse = (Integer)template.requestBody("direct:in",
    intBody); //classcastexception
    Assert.assertEquals(1, intResponse.intValue());
    }
    protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
    public void configure() {
    from("direct:in").
    to("bean:myBean");
    }
    };
    }

    @Override
    protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());
    return answer;
    }

    public static class MyBean {

    public Integer intRequest(Integer request) {
    return request;
    }

    public String stringRequest(String request) {
    return request;
    }

    }
    }

    This unit test fails with a ClassCastException when using Camel 2.0. This
    test passes for earlier versions of camel.

    I am dead in the water right now, as our application has routes that
    depend
    on camel's bean-binding mechanism. I would really appreciate if someone
    could look into this issue.

    Thanks,
    Sasi
  • Sasidharm at Oct 12, 2009 at 5:00 am
    Thanks for looking into this. I will hold off upgrading to Camel 2.0 and wait
    for this to be fixed in the Camel 2.1 release as this is a show stopper for
    us.

    Sasi


    willem.jiang wrote:
    Hi,

    I just checked the change log of the code, this issue was introduced by
    my change of CAMEL-1777[1].
    So I created a JIRA[2] for it and will did a quick fix for it.

    [1]http://issues.apache.org/activemq/browse/CAMEL-1777
    [2]http://issues.apache.org/activemq/browse/CAMEL-2060

    Willem

    sasidharm wrote:
    Here is a test that illustrates the issue:

    import javax.naming.Context;
    import junit.framework.Assert;
    import org.apache.camel.ContextTestSupport;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.util.jndi.JndiContext;

    public class CamelBeanEndpointTest extends ContextTestSupport {


    public void testRoute() throws Exception {

    String stringBody = "stringBody";
    String stringResponse = (String)template.requestBody("direct:in",
    stringBody);
    Assert.assertEquals(stringBody, stringResponse);

    Integer intBody = 1;
    Integer intResponse = (Integer)template.requestBody("direct:in",
    intBody); //classcastexception
    Assert.assertEquals(1, intResponse.intValue());
    }

    protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
    public void configure() {
    from("direct:in").
    to("bean:myBean");
    }
    };
    }

    @Override
    protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());
    return answer;
    }

    public static class MyBean {

    public Integer intRequest(Integer request) {
    return request;
    }

    public String stringRequest(String request) {
    return request;
    }

    }

    }

    This unit test fails with a ClassCastException when using Camel 2.0. This
    test passes for earlier versions of camel.

    I am dead in the water right now, as our application has routes that
    depend
    on camel's bean-binding mechanism. I would really appreciate if someone
    could look into this issue.

    Thanks,
    Sasi
    --
    View this message in context: http://www.nabble.com/Bean-endpoint-in-a-route-is-holding-reference-to-the-last-used-methodName-and-does-not-use-Camel%27s-Bean-binding-for-subsequent-messages-tp25838095p25850540.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Stan Lewis at Oct 13, 2009 at 7:31 pm

    On Sat, Oct 10, 2009 at 4:28 PM, sasidharm wrote:
    I am trying to upgrade to Camel 2.0 and running into a weird issue. Say i
    have the following route:
    <route>
    <from uri="jms:jms/queue/>
    <process ref="someProcessor" />
    <to uri="bean1" />
    </route>

    Here i am not specifying any method name explicitly for bean1 and I am
    depending on Camel's bean binding.
    The first time a message is pulled from jms:jms/queue, the correct method
    (say method1) is invoked on bean1 (matching the exchange's body to the
    bean's method parameter types). From next time onwards, Camel is holding
    the
    reference to method1 in bean1's BeanProcessor and is invoking
    bean1.method1() for all subsequent messages pulled from jms:jms/queue.
    What kind of messages are we talking about here, just text messages? Also
    what parameter types do you have defined in your bean? It would be handy to
    get a test case to investigate further.


    I am noticing this behavior only in Camel 2.0. It was working fine until
    Camel 1.6.

    Btw, I am using InOut exchange pattern when seding the messages to
    jms:jms/queue.

    Can anyone please help!!!


    --
    View this message in context:
    http://www.nabble.com/Bean-endpoint-in-a-route-is-holding-reference-to-the-last-used-methodName-and-does-not-invoke-Camel%27s-Bean-binding-tp25838095p25838095.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Willem Jiang at Oct 14, 2009 at 1:21 am
    Hi Stan,

    This issue[1] has been fixed in the camel 2.1.0-SNAPSHOT :)
    [1] http://issues.apache.org/activemq/browse/CAMEL-2060

    Willem

    Stan Lewis wrote:
    On Sat, Oct 10, 2009 at 4:28 PM, sasidharm wrote:

    I am trying to upgrade to Camel 2.0 and running into a weird issue. Say i
    have the following route:
    <route>
    <from uri="jms:jms/queue/>
    <process ref="someProcessor" />
    <to uri="bean1" />
    </route>

    Here i am not specifying any method name explicitly for bean1 and I am
    depending on Camel's bean binding.
    The first time a message is pulled from jms:jms/queue, the correct method
    (say method1) is invoked on bean1 (matching the exchange's body to the
    bean's method parameter types). From next time onwards, Camel is holding
    the
    reference to method1 in bean1's BeanProcessor and is invoking
    bean1.method1() for all subsequent messages pulled from jms:jms/queue.
    What kind of messages are we talking about here, just text messages? Also
    what parameter types do you have defined in your bean? It would be handy to
    get a test case to investigate further.


    I am noticing this behavior only in Camel 2.0. It was working fine until
    Camel 1.6.

    Btw, I am using InOut exchange pattern when seding the messages to
    jms:jms/queue.

    Can anyone please help!!!


    --
    View this message in context:
    http://www.nabble.com/Bean-endpoint-in-a-route-is-holding-reference-to-the-last-used-methodName-and-does-not-invoke-Camel%27s-Bean-binding-tp25838095p25838095.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedOct 10, '09 at 8:28p
activeOct 14, '09 at 1:21a
posts7
users3
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase