I did a test class to present the problem.
In this class below has another leak in relation to producers.


LeakOfMemory.java
<http://camel.465427.n5.nabble.com/file/n5777276/LeakOfMemory.java>  

In this class basically I have two routes, one of which is always removed
and added again infinitely.

Using JConsole one realizes that each adding a new producer is created and
removing it is not removed.
This producer is associated with the fragment
onException (Exception.class) .handled (true) .to ("direct: routeError");

<http://camel.465427.n5.nabble.com/file/n5777276/Jconsole.png> 

The code snippet where I insert the idempotent of service is


final JdbcMessageIdRepository jdbcMessageIdRepository =
getIdempotentRepository(
                                                                                
route.getInComponent().getId());

// @formatter:off
                                                                        
from(fromEndpoint)
                                                                                
        .process(new TypeConversionProcessor())
                                                                                
        .routeId(route.getId())
                                                                                
        .setProperty(CamelConstants.RECIPIENTS_TO_PROCESS, constant(new
HashSet()))
                                                                                
        .setHeader(CamelConstants.ROUTE_ID_HEADER,
constant(route.getId()))
                                                                                
        .setHeader(CamelConstants.ROUTE_HEADER, constant(route))
                                                                                
        .setHeader(CamelConstants.ROUTE_STRUCTURE,
constant(route.getStructure().toString()))
                                                                                
        .setHeader(CamelConstants.INBOUND_ENDPOINT_TYPE,
constant(route.getInComponent().getType()))
                                                                                
        .setHeader(CamelConstants.INBOUND_EDITABILITY_ROUTE,
constant(route.getEditabilityRule()))
                                                                                
        .setHeader(CamelConstants.IS_LOADBALANCED_HEADER,
constant(Boolean.valueOf(true)))
                                                                                
        .setHeader(CamelConstants.PARENT_ENDPOINT_ID_HEADER,
constant(parentId))
                                                                                
        .process(new SqlPreProcessor())
                                                                                
        .process("contentTypePreProcessor")
                                                                                
        .filter(new Predicate() {
                                                                                
                                @Override
                                                                                
                                public boolean matches(final Exchange exchange) 
{
                                                                                
                                        return
Boolean.valueOf(exchange.getIn().getHeader(CamelConstants.ALLOW_INBOUND_MESSAGE).toString());
                                                                                
                                }
                                                                                
        }).choice()
                                                                                
        
.when(header(CamelConstants.INBOUND_EDITABILITY_ROUTE).isNotNull())
                                                                                
                        .convertBodyTo(String.class)
                                                                                
                        .process("administratableDocumentProcessor")
                                                                                
                .endChoice()
                                                                                
        
.when(header(CamelConstants.INBOUND_ENDPOINT_TYPE).isEqualTo(EndpointType.JDBC))
                                                                                
                        
.idempotentConsumer(header(CamelConstants.ROW_ID_HEADER),
jdbcMessageIdRepository)
                                                                                
                        .to("seda:loadBalancePrepare")
                                                                                
                .endChoice()
                                                                                
        
.when(header(CamelConstants.PARENT_ENDPOINT_ID_HEADER).isNotNull())
                                                                                
                        .filter(childFilter)
                                                                                
                        .aggregate(header(PARENT_ENDPOINT_ID_HEADER), new
ChildEndpointAggregator())
                                                                                
                        .completionSize(children).completionTimeout(timeout)
                                                                                
                        .process("childEndpointParameterOrganiser")
                                                                                
                        .process(new Processor() {
                                                                                
                                        @Override
                                                                                
                                        public void process(final Exchange 
exchange) throws Exception
{
                                                                                
                                                childFilter.reset();
                                                                                
                                        }
                                                                                
                        })
                                                                                
                        .to("seda:loadBalancePrepare")
                                                                                
                        .end()
                                                                                
                .endChoice()
                                                                                
                .otherwise()
                                                                                
                        .to("seda:loadBalancePrepare")
                                                                                
        .end();
                                                                        // 
@formatter:on

public JdbcMessageIdRepository getIdempotentRepository(final String
endpointId) {

                final JdbcMessageIdRepository repository = new
JdbcMessageIdRepository(applicationDataSource, endpointId);

                // Need to override default for SQL Server as doesn't allow 
repository
                // to specify a value for timestamp columns
                repository.setCreateString(
                                "CREATE TABLE CAMEL_MESSAGEPROCESSED 
(processorName VARCHAR(255),
messageId VARCHAR(100), createdAt VARCHAR(100))");

                return repository;
        }




--
View this message in context: 
http://camel.465427.n5.nabble.com/Leak-of-Memory-using-JdbcMessageIdRepository-tp5777242p5777276.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to