[
https://issues.apache.org/activemq/browse/SM-1136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet updated SM-1136:
--------------------------------
Fix Version/s: 3.3
3.2.2
> PreDestroy being called for each exchange when it's not configured that way.
> ----------------------------------------------------------------------------
>
> Key: SM-1136
> URL: https://issues.apache.org/activemq/browse/SM-1136
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-bean
> Reporter: Ryan Bohn
> Assignee: Guillaume Nodet
> Priority: Critical
> Fix For: 3.2.2, 3.3, servicemix-bean-2008.01
>
> Attachments: fixPreDestroy.patch
>
>
> I have a sender bean and a receiver bean, both configured using
> <bean:endpoint ... bean="#...". The problem is that the PreDestroy method is
> being called after every MessageExchange is finished.
> According to the documentation:
> Attention: The Bean Endpoint schema allows to set a Bean or a Bean Name. The
> Bean will create a single instance of the POJO per endpoint whereas the Bean
> Name will create an instance per request (message exchange).
> I have in my xbean.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
> xmlns:example="http://servicemix.apache.org/example">
> <bean:endpoint service="example:sender" endpoint="senderEndpoint"
> bean="#sender"/>
> <bean:endpoint service="example:receiver" endpoint="receiverEndpoint"
> bean="#receiver"/>
> <bean id="sender" class="example.Sender">
> <property name="target" value="example:receiver"/>
> </bean>
>
> <bean id="receiver" class="example.Receiver">
> </bean>
> </beans>
> The receiver simply implements MessageExchangeListener.
> The PostConstruct and PreDestroy only gets called once on the sender
> The PostConstruct only gets called once on the receiver
> However, the PreDestroy gets called on the receiver for each request.
> I noticed in BeanEndpoint, there is the following method:
> protected void checkEndOfRequest(Request request, Object corId) {
> if (request.getExchange().getStatus() != ExchangeStatus.ACTIVE) {
> ReflectionUtils.callLifecycleMethod(request.getBean(),
> PreDestroy.class);
> //request.setBean(null);
> //request.setExchange(null);
> requests.remove(corId);
> }
> }
> It doesn't look like this class pays any attention to whether the bean is
> supposed to be a single instance of an instance-per-request, which is
> probably the cause of the problem.
> If you need me to attach an example, please let me know.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.