You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Laures <ba...@googlemail.com> on 2011/11/07 15:53:57 UTC

destroy-method not executed on ActiveMQ shutdown

Hi,

i have embedded an additional component into activemq by adding a bean
configuration to the activemq.xml config.

now when activemq is started a bean for my component is created and
initialized with the configured init-method. BUT when activemq is stopped
the destroy-method is not executed.

my config:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

...broker config...

	<bean id="BpMonitor" class="myclass" init-method="start"
destroy-method="stop">
	</bean>
	
</beans>

--
View this message in context: http://activemq.2283324.n4.nabble.com/destroy-method-not-executed-on-ActiveMQ-shutdown-tp3998892p3998892.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: destroy-method not executed on ActiveMQ shutdown

Posted by Torsten Mielke <to...@fusesource.com>.
Hello, 

Yes, that is expected. 
Its Spring who initialized your bean and the broker instance. 
The broker is completely independent of your bean. 
So when you stop the broker it will only stop the broker, not your bean.

Get a reference to you bean from Spring and explicitly call stop on it.



Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com

On Nov 7, 2011, at 3:53 PM, Laures wrote:

> Hi,
> 
> i have embedded an additional component into activemq by adding a bean
> configuration to the activemq.xml config.
> 
> now when activemq is started a bean for my component is created and
> initialized with the configured init-method. BUT when activemq is stopped
> the destroy-method is not executed.
> 
> my config:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd">
> 
> ...broker config...
> 
> 	<bean id="BpMonitor" class="myclass" init-method="start"
> destroy-method="stop">
> 	</bean>
> 	
> </beans>
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/destroy-method-not-executed-on-ActiveMQ-shutdown-tp3998892p3998892.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.