You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Vitalii Tymchyshyn (JIRA)" <ji...@apache.org> on 2014/07/01 20:28:24 UTC

[jira] [Commented] (CAMEL-7561) ProducerCache used in DefaultProducerTemplate uses stale references after context restart

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

Vitalii Tymchyshyn commented on CAMEL-7561:
-------------------------------------------

So, basically, POJO Producing can't be used if camel contexts are restarted, can it? Should it be documented in the http://camel.apache.org/pojo-producing.html page? As for me it's serious limitation

> 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
>            Assignee: Claus Ibsen
>
> 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)