servicemix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Bohn (JIRA)" <>
Subject [jira] Commented: (SM-1136) PreDestroy being called for each exchange when it's not configured that way.
Date Wed, 09 Jan 2008 15:43:43 GMT


Ryan Bohn commented on SM-1136:

Any word on when this patch will be incorporated into ServiceMix?

> PreDestroy being called for each exchange when it's not configured that way.
> ----------------------------------------------------------------------------
>                 Key: SM-1136
>                 URL:
>             Project: ServiceMix
>          Issue Type: Bug
>          Components: servicemix-bean
>    Affects Versions: 3.2
>            Reporter: Ryan Bohn
>            Priority: Critical
>         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=""
>        xmlns: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.

View raw message