mercredi 30 septembre 2015

Tomcat 8 Spring JMS/AWS SQS memory leak

I have a following Spring(Boot) configuration for AWS SQS:

    /**
     * AWS Credentials Bean
     */
    @Bean
    public AWSCredentials awsCredentials() {
        return new BasicAWSCredentials(accessKey, secretAccessKey);
    }

    /**
     * AWS Client Bean
     */
    @Bean(destroyMethod="shutdown")
    public AmazonSQSAsync amazonSQSAsyncClient() {
        AmazonSQSAsync sqsClient = new AmazonSQSAsyncClient(awsCredentials());
        sqsClient.setRegion(regionProvider().getRegion());
        return new AmazonSQSBufferedAsyncClient(sqsClient);
    }

    /**
     * AWS Connection Factory
     */
    @Bean
    public SQSConnectionFactory connectionFactory() {
        SQSConnectionFactory.Builder factoryBuilder = new SQSConnectionFactory.Builder(regionProvider().getRegion());
        factoryBuilder.setAwsCredentialsProvider(awsCredentialsProvider());
        return factoryBuilder.build();
    }

    @Bean
    public AWSCredentialsProvider awsCredentialsProvider() {
        return new StaticCredentialsProvider(awsCredentials());
    }

    @Bean
    public RegionProvider regionProvider() {
        return new StaticRegionProvider(regionName);
    }

    /**
     * Registering MyQueueListener
     */
    @Bean(destroyMethod="shutdown")
    public DefaultMessageListenerContainer defaultMessageListenerContainer() {
        DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
        messageListenerContainer.setConnectionFactory(connectionFactory());
        messageListenerContainer.setDestinationName(queueName);
        messageListenerContainer.setMessageListener(new MessageListenerAdapter(new MyQueueListener(reportJobService)));
        messageListenerContainer.setErrorHandler(new QueueListenerErrorHandler());
        messageListenerContainer.setTaskExecutor(defaultMessageListenerContainerTaskExecutor());
        messageListenerContainer.setMaxConcurrentConsumers(taskExecutorMaxConcurrentConsumers);

        return messageListenerContainer;
    }

    @Bean(destroyMethod="shutdown")
    public Executor defaultMessageListenerContainerTaskExecutor() {
        return Executors.newFixedThreadPool(taskExecutorThreadsNumber);
    }

On Tomcat 8 during the Reload via Tomcat Web Application Manager this configuration leads to the memory leak:

The following web applications were stopped (reloaded, undeployed), but their
classes from previous runs are still loaded in memory, thus causing a memory
leak (use a profiler to confirm):
/domain-api
/domain-api

My Tomcat log does not contain messages about possible memory leaks..

Looks like right now I have a 2 instances of my application(domain-api) up and running.. How to check it and how to fix it ?




Aucun commentaire:

Enregistrer un commentaire