3
votes

Are scheduled messages are also shared when using activemq broker master-slave? I successfully created master-slave by jdbc, but the scheduled messages do not appear in the database. This makes the master-slave broker configuration not really a 100% failover system. Or is there anything I should specificly set up to make this happen?

With this code do I usually create the broker:

BrokerService brokerService = new BrokerService();
brokerService.setBrokerName(brokerName);
brokerService.addConnector("tcp://" + host + ":" + port);
brokerService.setSchedulerSupport(true);

// Allow JMX monitoring
brokerService.setUseJmx(true);
ManagementContext managementContext = new ManagementContext();
managementContext.setConnectorPort(port + 10000);
managementContext.setRmiServerPort(port + 20000);
brokerService.setManagementContext(managementContext);

// Set temp and store limits to 512MB to avoid
// unrealistic-limit-warnings
brokerService.getSystemUsage().getStoreUsage().setLimit(512 * 1024 * 1024);
brokerService.getSystemUsage().getTempUsage().setLimit(512 * 1024 * 1024);

And with this addition I create the master-slave datasource:

Map<String, Object> configuration = entityFactory.getProperties();
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName((String) configuration.get("hibernate.connection.driver_class"));
dataSource.setUrl((String) configuration.get("hibernate.connection.url"));
dataSource.setUsername((String) configuration.get("hibernate.connection.username"));
dataSource.setPassword((String) configuration.get("hibernate.connection.password"));

which I use to set the master-slave jbdcPersistenceAdapter:

JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
adapter.setDataSource(dataSource);
brokerService.setPersistenceAdapter(adapter);

which is followed by starting the brokerService:

brokerService.start();

This code all works fine. The queue is shared between brokers successfully, and the consumers do their job. The consumers sometimes create a producer which uses the failover-URL successfully to find out which broker is in the air. That all works well.

But, the scheduled messages do not appear in the database, and scheduled messages just stop appearing when the broker that has the scheduled message, is shut down.

Thanks!

1

1 Answers

2
votes

Given the following quotes from http://activemq.apache.org/persistence.html:

To achieve high performance of durable messaging in ACtiveMQ V4.x we strongly recommend you use our high performance journal - which is enabled by default.

and from http://activemq.apache.org/masterslave.html:

JDBC Master Slave - Requires a shared database. Also relatively slow as it cannot use the high performance journal

and the following answer (http://bit.ly/1jobMO6):

The scheduler store will use KahaDB based store regardless of the persistence adapter you're using for your messaging store.

it seems that high (and correct?) performance for scheduled message can only be achieved by using a KahaDB based store. To workaround this you might be able to use a shared file system to store the KahaDB database (see http://activemq.apache.org/shared-file-system-master-slave.html). If not, you should find a way to have brokers schedule messages when they are promoted to become the master.