activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raphaël Ramirez (JIRA) <>
Subject [jira] Updated: (AMQ-2245) Allow restart of embedded broker
Date Fri, 20 Nov 2009 16:43:52 GMT


Raphaël Ramirez updated AMQ-2245:


I would like to do the following with an Master-slave with database lock configuration :

- if a database problem occurs (loss of connection, etc.)
- the master looses the database lock : ??"No longer able to keep the exclusive lock so giving
up being a master"?? and a slave become the new master as usual
- but instead of shutting the broker down completely, I'm trying to make it become a slave
(able to become a master again)

I use the attached ActiveMQThreadBrokerFactory in Spring as following (also see AMQ-1273)
: \\
	<bean id="brokerFactory" class="app.messaging.ActiveMQThreadBrokerFactory">
		<property name="brokerService" ref="brokerService"/><!-- start must be false on
this broker -->
		<property name="exceptionHandler" ref="exceptionHandler"/>

  <amq:broker useJmx="true" persistent="true" brokerName="broker2" id="brokerService" start="false">
    	<amq:managementContext useMBeanServer="true" createMBeanServer="false" createConnector="false"/>
<!-- use the JVM MBean server -->
    	<amq:jdbcPersistenceAdapter dataSource="#persistenceDataSource" createTablesOnStartup="true"
useDatabaseLock="true" />
		<amq:transportConnector uri="tcp://localhost:50000" />
		<amq:transportConnector name="stomp" uri="stomp://localhost:50001" />

	<bean id="persistenceDataSource" class="...." init-method="init" destroy-method="close">

	<!-- modified exception handler to avoid logging "Lock wait timeout exceeded" messages
(normal slave behaviour) -->
	<bean id="exceptionHandler" class="app.messaging.LockExceptionHandler"/>
With this configuration, the master->slave behavior works (looping to acquire the lock).
But when the lock is obtained again, it happens that the broker is actually replaced by an
ErrorBroker (replaced during the previous stop):

    protected Broker createBroker() throws Exception {
            public void stop() throws Exception {
                old = ErrorBroker("Broker has been stopped: " + this)
                    // Just ignore additional stop actions.
                    public void stop() throws Exception {

So I get the following stacktrace when nowMasterBroker is called :

INFO | Becoming the master on dataSource:
ERROR | Failed to start ActiveMQ JMS Message Broker.
Reason: Broker has been stopped:$3@1f489d9 Broker has been stopped:$3@1f489d9
	at app.messaging.ActiveMQThreadBrokerFactory$
INFO | ActiveMQ Message Broker (broker2, ID:PC030-52124-1958729374192-0:0)
is shutting down
INFO | Connector tcp://localhost:50001 Stopped
INFO | Connector stomp Stopped
INFO | ActiveMQ JMS Message Broker (broker2, ID:PC030-52124-1958729374192-0:0)
ERROR app.messaging.ActiveMQThreadBrokerFactory | Init brokerService error. Will try again
in 10000 ms

I assume that checking ??forceStart?? in ??BrokerService.getBroker()?? may help by calling
again ??createBroker()?? for an existing (non null) broker.

(Another thing is that with my configuration, setting ??lockAcquireSleepInterval?? in ??<amq:jdbcPersistenceAdapter/>??
in the Spring context has no effect (the default value is always used). This is why I have
to set it (twice) in ??

> Allow restart of embedded broker
> --------------------------------
>                 Key: AMQ-2245
>                 URL:
>             Project: ActiveMQ
>          Issue Type: Improvement
>    Affects Versions: 5.2.0
>            Reporter: Dejan Bosanac
>            Assignee: Dejan Bosanac
>             Fix For: 5.3.0
>         Attachments:
> Currently we don't allow restarting the stopped broker and instead developers need to
create another instance of the broker and start it. Usually this is a desired behavior and
should remain a default one. But we should provide an option to people wanting to start stopped
brokers. The proposed enhancement will introduce 
> {code}
> public void start(boolean force);
> {code}
> method, which will force the broker to start.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message