camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-7561) ProducerCache used in DefaultProducerTemplate uses stale references after context restart
Date Mon, 30 Jun 2014 19:29:26 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-7561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14048015#comment-14048015
] 

Claus Ibsen commented on CAMEL-7561:
------------------------------------

This is not a bug, it works as designed.

Any bean that has X injected can use stale references if X is restarted or something.

> ProducerCache used in DefaultProducerTemplate uses stale references after context restart
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-7561
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7561
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.13.1
>            Reporter: Vitalii Tymchyshyn
>
> We've got ProducerTemplate injected into our beans that are used to call direct routes.
Unfortunately after camel context restart we are starting to get 
> DirectConsumerNotAvailableException. It looks like it's because of cache used. The workaround
is to restart a template itself, but it's used in beans that don't know about context restarts.
> Here is a test, only testTemplateRestart works now:
> {noformat}
> public class ContextRestartTest {
>     CamelContext camelContext;
>     ProducerTemplate template;
>     @Before
>     public void makeContext() throws Exception {
>         camelContext = new DefaultCamelContext();
>         camelContext.addRoutes(new RouteBuilder(){
>             @Override
>             public void configure() throws Exception {
>                 from("direct:test").to("log:test");
>             }
>         });
>         camelContext.start();
>         template = camelContext.createProducerTemplate();
>     }
>     @After
>     public void stopContext() throws Exception {
>         template.stop();
>         camelContext.stop();
>     }
>     @Test
>     public void testDefaultURI() throws Exception {
>         template.setDefaultEndpointUri("direct:test");
>         template.sendBody("test");
>         camelContext.stop();
>         camelContext.start();
>         template.sendBody("test");
>     }
>     @Test
>     public void testGivenURI() throws Exception {
>         template.sendBody("direct:test", "test");
>         camelContext.stop();
>         camelContext.start();
>         template.sendBody("direct:test", "test");
>     }
>     @Test
>     public void testTemplateRestart() throws Exception {
>         template.sendBody("direct:test", "test");
>         camelContext.stop();
>         template.stop();
>         template.start();
>         camelContext.start();
>         template.sendBody("direct:test", "test");
>     }
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message