You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ursouca <Ca...@ext.ec.europa.eu> on 2016/02/01 15:55:27 UTC

JPAProducer intances are never released!

Dears,

I am using the JPA component to persist some messages into a DB table on
which multiple JPA consumers will consume enrich to send them after in
aggregator.

The routes are expressed exclusively in XML (spring-camel). From the point
of view of the routes everything seems to work well.<p/>
To help me developing, debugging, monitoring I am using Hawtio console.
Therefore I activated the camel JMX agent.
Thanks to Hawtio I saw that the JPAProducers instances ware never
released/closed. Therefore for each single insert in the table I have an new
instance of the JPAProducer instantiated but never released when useless.
I was wondering if I configured wrongly some component of it is a bug
related to my configuration (JMX agent keeping a reference on those
instances of JPAproducer, ...)

Is somebody can help me to figure out if it a misconfiguration or a bug,
will great?

Thanks advance for the help,
Cataldo URSO.

Here is my camelContext (Spring 4.2.4 and camel 2.16.2) configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:util="http://www.springframework.org/schema/util"
xmlns:camel="http://camel.apache.org/schema/spring"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
		http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
		http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring-2.16.2.xsd
		http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">

	<context:property-placeholder location="classpath*:/sep-eval.properties" 
ignore-resource-not-found="true" ignore-unresolvable="true"/>

	<jee:jndi-lookup id="sepEvaDS"
jndi-name="${sep.eva.batch.datasource.xa:jdbc/sepEvaDS}" />

	<bean id="camelJpaVendorAdapter" name="auditJpaVendorAdapter"
		class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
		<property name="database" value="ORACLE" />
		<property name="databasePlatform"
		
value="eu.europa.ec.digit.org.eclipse.persistence.platform.database.Oracle11gPlatform"
/>
		<property name="showSql" value="false" />
		<property name="generateDdl" value="false" />
	</bean>

	<bean id="camelEnabled" class="java.lang.Boolean">
		<constructor-arg value="${sep.eva.service.flow.camel.active:true}" />
	</bean>

	<bean id="camelEntityManagerFactory"
	
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceXmlLocation"
value="classpath*:/META-INF/persistence-camel.xml" />
		<property name="persistenceUnitName" value="camelPU" />
		<property name="jpaVendorAdapter" ref="camelJpaVendorAdapter" />
		<property name="jpaDialect">
			<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
		</property>
		<property name="jpaProperties">
			<props>
				<prop key="eclipselink.target-server">WebLogic_10</prop>
				<prop key="eclipselink.jdbc.batch-writing">Oracle-JDBC</prop>
				<prop key="eclipselink.jdbc.batch-writing.size">300</prop>
				<prop key="eclipselink.order-updates">true</prop>
				<prop key="eclipselink.cache.shared.default">false</prop>
				<prop key="eclipselink.weaving">static</prop>
				<prop
key="eclipselink.logging.logger">eu.europa.ec.digit.util.persistence.eclipse.logging.Slf4jSessionLogger
				</prop>
				<prop key="eclipselink.logging.parameters">true</prop>
				<prop key="eclipselink.persistence-context.flush-mode">auto</prop>
			</props>
		</property>
	</bean>

	<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
		<property name="entityManagerFactory" ref="camelEntityManagerFactory" />
		<property name="transactionManager" ref="transactionManager" />
	</bean>

	<bean id="camelTaskExecutor"
		class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
		<property name="workManagerName" value="SEP-EVA-Camel" />
		<property name="resourceRef" value="true" />
	</bean>

	<bean id="defaultThreadPool"
		name="camelExecutorServiceAdapter defaultThreadPool
defaultThreadPoolProfile"
		class="org.springframework.core.task.support.ExecutorServiceAdapter">
		<constructor-arg ref="camelTaskExecutor" />
	</bean>

	<bean id="metricsRoutePolicyFactory"
	
class="org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory"
/>

	<bean id="grpExAgrStr"
	
class="org.apache.camel.processor.aggregate.GroupedExchangeAggregationStrategy"
/>

	<bean id="wfeNativeJdbcExtractor"
	
class="org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor"
/>

	<bean id="wfelobHandler"
class="org.springframework.jdbc.support.lob.OracleLobHandler">
		<property name="nativeJdbcExtractor" ref="wfeNativeJdbcExtractor" />
	</bean>

	<bean id="wfeRepository"
	
class="org.apache.camel.processor.aggregate.jdbc.JdbcAggregationRepository"
		init-method="start" destroy-method="stop">
		<property name="transactionManager" ref="transactionManager" />
		<property name="repositoryName" value="eva_event_aggregator" />
		<property name="dataSource" ref="sepEvaDS" />
		<property name="lobHandler" ref="wfelobHandler" />
		<property name="useRecovery" value="true" />
		<property name="headersToStoreAsText">
			<list>
				<value>EVALUATION_SESSION_ID</value>
				<value>TARGET_OBJECT_ID</value>
				<value>TARGET_POOL_ID</value>
				<value>TARGET_TYPE</value>
			</list>
		</property>
	</bean>

	<bean id="dump" class="eu.europa.ec.digit.sep.eval.service.flow.Dump" />

	<bean id="wkflEventConsumer"
		class="eu.europa.ec.digit.sep.eval.service.flow.WorkflowEventConsumer" />

	<bean id="workflowManager"
		class="eu.europa.ec.digit.sep.eval.service.flow.WorkflowManager" />

	<bean id="myStrategy"
class="eu.europa.ec.digit.sep.eval.service.flow.GroupedInBodyStrategy" />


	
	<camel:redeliveryPolicyProfile id="evaRedeliveryPolicy"
		maximumRedeliveries="3" allowRedeliveryWhileStopping="false"
		maximumRedeliveryDelay="60000" redeliveryDelay="3000"
		retryAttemptedLogLevel="WARN" />


	
	<camelContext messageHistory="true" autoStartup="true"
		allowUseOriginalMessage="false" runtimeEndpointRegistryEnabled="true"
		shutdownRunningTask="CompleteCurrentTaskOnly"
		typeConverterStatisticsEnabled="true" id="sep-eval-camel-service"
		depends-on="camelEntityManagerFactory defaultThreadPool"
xmlns="http://camel.apache.org/schema/spring">

		<propertyPlaceholder id="camelPropertiesPlaceHolder"
location="classpath:/sep-eval.properties" />

		<jmxAgent disabled="false" onlyRegisterProcessorWithCustomId="false"
			createConnector="false" usePlatformMBeanServer="true"
registerAlways="true"
			registerNewRoutes="true" statisticsLevel="Extended"
			loadStatisticsEnabled="true" includeHostName="true" mask="false"
id="camelAgent" />

		<errorHandler type="DefaultErrorHandler"
			redeliveryPolicyRef="evaRedeliveryPolicy" id="eh" />

		<route id="workflowEventProducer" errorHandlerRef="eh"
			group="Workflow-Event" shutdownRunningTask="CompleteCurrentTaskOnly"
			trace="true"
		
autoStartup="{{sep.eva.service.flow.camel.route.workflowevent.producer.autostartup:true}}"
			startupOrder="10">
			<from uri="direct:wkf-event?synchronous=true" id="wkf-event-ep" />
			<to
uri="jpa://eu.europa.ec.digit.sep.eval.model.WorkflowEvent?persistenceUnit=camelPU"
/>
			<log logName="eu.europa.ec.digit.sep.eval.service.flow.camel"
				message="Register the event [${body}] for later processing"
loggingLevel="DEBUG" />
		</route>

		<route id="workflowEventConsumer" errorHandlerRef="eh"
			group="Workflow-Event" shutdownRunningTask="CompleteCurrentTaskOnly"
			trace="true"
		
autoStartup="{{sep.eva.service.flow.camel.route.workflowevent.consumer.autostartup:true}}"
			startupOrder="1000">
			<from
			
uri="jpa://eu.europa.ec.digit.sep.eval.model.WorkflowEvent?persistenceUnit=camelPU&amp;maximumResults=200&amp;consumer.namedQuery=WorkflowEvent.getEventsAsFIFO&amp;consumer.SkipLockedEntity=true"
/>
			
			<log message="Consumming event [${body}] to enrich it with info needed
for aggregation" loggingLevel="DEBUG" />
			<bean ref="wkflEventConsumer" method="prepareBeforeAggregation"
cache="true" />
			<log logName="eu.europa.ec.digit.sep.eval.service.flow.camel"
			message="Enrichement of the event [${body}] the the new data are stored
in the headers [${headers}]" loggingLevel="DEBUG" />
		</route>

		<route id="eventAggregator" errorHandlerRef="eh" group="Workflow-Event"
			shutdownRunningTask="CompleteCurrentTaskOnly" trace="true"
		
autoStartup="{{sep.eva.service.flow.camel.route.eventaggregation.autostartup:true}}"
			startupOrder="20">
			<description>This route will aggregate all the workflow event emitted by
and over the same proposal.</description>
			<from uri="direct://aggr?synchronous=true" id="aggr-event-ep" />
			<log logName="eu.europa.ec.digit.sep.eval.service.flow.camel"
			message="Sending [${body}]"	loggingLevel="DEBUG" />
			<aggregate aggregationRepositoryRef="wfeRepository"
				executorServiceRef="defaultThreadPool" strategyRef="myStrategy"
				ignoreInvalidCorrelationKeys="true" forceCompletionOnStop="true"
				id="aggregationOnSessionAndTarget">
				<correlationExpression>
				
<simple>[EVAL-SESS:${header.EVALUATION_SESSION_ID}]-[${header.TARGET_TYPE}]-[${header.TARGET_OBJECT_ID}]-[${header.TARGET_POOL_ID}]</simple>
				</correlationExpression>
				<completionTimeout>
				
<simple>{{sep.eva.service.flow.camel.route.eventaggregation.completion.timeout:3500}}</simple>
				</completionTimeout>
				<completionSize>
				
<simple>{{sep.eva.service.flow.camel.route.eventaggregation.completion.size:100}}</simple>
				</completionSize>
				<log logName="eu.europa.ec.digit.sep.eval.service.flow.camel"
				message="Sending out [${body}] with headers [${headers}]"
loggingLevel="DEBUG" />

				<bean ref="workflowManager" cache="true" />
				<log logName="eu.europa.ec.digit.sep.eval.service.flow.camel"
				message="Processed aggragated event [${body}] - headers [${headers}]"
loggingLevel="DEBUG" />
			</aggregate>
		</route>
	</camelContext>

</beans>






--
View this message in context: http://camel.465427.n5.nabble.com/JPAProducer-intances-are-never-released-tp5777101.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JPAProducer intances are never released!

Posted by ursouca <Ca...@ext.ec.europa.eu>.
Dears,

One interresting thing.

When I disable the JMX agent the jpaProducer instances are released and
garbage collected.
It seems to me that is the JMX agent is keeping reference on the JpaProducer
objects making them never released.
Now I am wondering if it is a misconfiguration or it is a bug.
As short time solution, I will disable the JMX agent. But in a mid  term
solution I need to reactivate it because I need to monitor it with HAWTIO.

Br,
Cataldo.



--
View this message in context: http://camel.465427.n5.nabble.com/JPAProducer-intances-are-never-released-tp5777101p5777181.html
Sent from the Camel - Users mailing list archive at Nabble.com.