Hi Bastien

Thanks for the detailed report and the test case. Do you mind creating a
JIRA ticket and attach the test case to the JIRA. Then we wont forget, and
will take a look.


On Mon, Apr 8, 2019 at 3:12 PM Bastien Meert <bastien.me...@mainsysgroup.com>
wrote:

> And the test case :
>
> package org.apache.camel.component.jms;
>
> import org.apache.camel.CamelContext;
> import org.apache.camel.EndpointInject;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
>
> import javax.jms.ConnectionFactory;
>
> import static 
> org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
>
> public class JmsInOutTransferExchangeInflightRepositoryFlushTest extends 
> CamelTestSupport {
>
>     @EndpointInject(uri = "mock:result")
>     protected MockEndpoint result;
>
>     @Override
>     protected CamelContext createCamelContext() throws Exception {
>         CamelContext camelContext = super.createCamelContext();
>         ConnectionFactory connectionFactory = 
> CamelJmsTestHelper.createConnectionFactory();
>         camelContext.addComponent("activemq", 
> jmsComponentAutoAcknowledge(connectionFactory));
>         return camelContext;
>     }
>
>     @Test
>     public void testTransferExchangeInOut() throws Exception {
>         result.expectedMessageCount(1);
>
>         template.send("direct:start", new Processor() {
>             @Override
>             public void process(Exchange exchange) throws Exception {
>                 exchange.getIn().setBody(new SerializableRequestDto("Restless 
> Camel"));
>             }
>         });
>
>         assertMockEndpointsSatisfied();
>         Exchange resultExchange = result.getExchanges().get(0);
>         assertEquals(0, 
> resultExchange.getContext().getInflightRepository().size());
>     }
>
>     @Override
>     protected RouteBuilder createRouteBuilder() {
>         return new RouteBuilder() {
>             public void configure() {
>                 from("direct:start")
>                     
> .inOut("activemq:responseGenerator?transferExchange=true&requestTimeout=360000")
>                     .to("mock:result");
>
>                 from("activemq:responseGenerator?transferExchange=true")
>                     .process(new Processor() {
>                         public void process(Exchange exchange) throws 
> Exception {
>                             exchange.getIn().setBody(new 
> SerializableResponseDto(true));
>                         }
>                     });
>             }
>         };
>     }
> }
>
>
> ------------------------------
> Bastien Meert
> Senior software engineer
> Email : bastien.me...@mainsysgroup.com
> Phone : +3210801120
> Mobile : +32472702422
>
>    <http://www.mainsysgroup.com/>
>
>  www.mainsysgroup.com
>
> *Head Office*
> Bastion Tower
> Place du Champ de Mars 5 b21 Marsveldplein
> B-1050 Bruxelles / Brussel
> Phone. : +32 2 733 83 87
> Enterprise N° : BE 0456.540.594
>
> P *Please consider the environment before printing this email*
>
> ------------------------------
> *De :* Bastien Meert
> *Envoyé :* lundi 8 avril 2019 14:17:04
> *À :* users@camel.apache.org
> *Objet :* RE: Issue : Camel not clearing inflight repository.
>
>
> It's strange you do not see the attachment as it is visible in my outbox.
>
>
> I did debug camel code in different version using my test case (copied
> below) and it appears it come from a change of default setting for
> allowUseOriginalMessage in Camel context.
>
>
> In release note 2.18.0 I see :
>
> "Optimize Camel to only enable AllowUseOriginalMessage if in use by error
> handler or OnCompletion <http://camel.apache.org/oncompletion.html>. End
> user who manually access the original message using the Java API must
> configure AllowUseOriginalMessage=true."
>
>
> It appears an other case requiring to set this to true is the case of
> transferExchange=true as the code use to reconstruct the jms message is
> called before adding the Exchange to InflightRepository only if set to true.
>
>
> Is a JIRA still required (I am not sure if the JMS case is cover by "End
> user who manually access the original message using the Java API must
> configure AllowUseOriginalMessage=true" or not.
>
>
> Regards,
>
> Bastien Meert
>
> ------------------------------
> Bastien Meert
> Senior software engineer
> Email : bastien.me...@mainsysgroup.com
> Phone : +3210801120
> Mobile : +32472702422
>
>    <http://www.mainsysgroup.com/>
>
>  www.mainsysgroup.com
>
> *Head Office*
> Bastion Tower
> Place du Champ de Mars 5 b21 Marsveldplein
> B-1050 Bruxelles / Brussel
> Phone. : +32 2 733 83 87
> Enterprise N° : BE 0456.540.594
>
> P *Please consider the environment before printing this email*
>
> ------------------------------
> *De :* Bastien Meert
> *Envoyé :* vendredi 5 avril 2019 16:33:13
> *À :* users@camel.apache.org
> *Objet :* Issue : Camel not clearing inflight repository.
>
>
> Dear all,
>
>
> We encounter a problem of java heap space using jms inOut and
> transferExchange=true option.
>
> The origin of the memory leak is the InflightRepository in camel context
> to never dispose of any messages.
>
>
> It occurs on consumer side with the following logic :
>
> 1. A message is receive through JMS, camel create an Exchange instance and
> add it to the context's inflightRepository.
>
> 2. The exchange received over JMS is parsed and used to set all the
> exchange value, including the exchangeId used as a key in
> inflightRepository. Unfortunately the inflightRepository key is not updated
>
> 3. When the route has finish its job it tries to dispose the message
> (probably using remove(Exchange) methods). But as the exchangeId in the
> Exchange is not the same as key store into InflightRepository, it is not
> removed.
>
> 4. After some time of execution (can be minutes or days regarding volume
> of data exchanged over JMS) the InflightRepository as eat all the heap
> memory space and it ends into a heap space error.
>
>
> I created a small test case (in attachement) based on
> JmsInOutTransferExchangeTest from Jms Component on Github.
> It passed successfully on 2.17.7 (version not failing we use in some of
> our apps), but fail with 2.21.x (version use in the new app).
>
>
> Regards,
>
> Bastien Meert
>
> ------------------------------
> Bastien Meert
> Senior software engineer
> Email : bastien.me...@mainsysgroup.com
> Phone : +3210801120
> Mobile : +32472702422
>
>    <http://www.mainsysgroup.com/>
>
>  www.mainsysgroup.com
>
> *Head Office*
> Bastion Tower
> Place du Champ de Mars 5 b21 Marsveldplein
> B-1050 Bruxelles / Brussel
> Phone. : +32 2 733 83 87
> Enterprise N° : BE 0456.540.594
>
> P *Please consider the environment before printing this email*
>
> ------------------------------
> This e-mail and its attachments may be confidential and are intended
> solely for the use of the individual to whom it is addressed. Any views or
> opinions expressed are solely those of the author and do not necessarily
> represent those of Mainsys. If you are not the intended recipient of this
> e-mail and its attachments, you must take no action based upon them, nor
> must you copy or show them to anyone. Please contact the sender if you
> believe you have received this e-mail in error.
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to