You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Cristian3001 <cr...@autodata.net> on 2007/05/28 16:01:33 UTC

Problems with ActiveMQ4.1.1 - Master/Slave brokers

Hi,

I'm having the following scenario: 
1. two brokers with active MQ 4.1.1: one broker was configured as Master,
and the other one Slave
2. one consumer

>From the main app there is no problem sending messages to the brokers. When
I shutdown the master, all the messages are in slave's queue as expected.

The problem is that the consumer has to be restarted each time I've changed
the broker:
1. 1st scenario:
    - I start up the master broker;
    - then the slave broker;
    - I start up the consumer;
    - send messages and observed that all the requests are trapped in the
queue; none is consumed by the listener;
    - restart the listener, and all the messages start to be consumed;
    - after that the listener works just fine, consuming all the requests
sent, without been required to restarted over again.

2. 2nd secenario:
    - both master and slave brokers are started;
    - shut down the master broker;
    - send messages and observed that all the requests are trapped in the
queue; none is consumed by the listener;
    - restart the listener, and all the messages start to be consumed;
    - after that the listener works just fine, consuming all the requests
sent, without been required to restarted over again.


Thank you for any suggestion.
-- 
View this message in context: http://www.nabble.com/Problems-with-ActiveMQ4.1.1---Master-Slave-brokers-tf3828185s2354.html#a10836705
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with ActiveMQ4.1.1 - Master/Slave brokers

Posted by Cristian3001 <cr...@autodata.net>.
Hi Venkatesh,


The master:

<beans>
	<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
/>
	<broker brokerName="localhost" useJmx="true"
xmlns="http://activemq.org/config/1.0">
		<destinationPolicy>
			<policyMap>
				<policyEntries>
					<policyEntry topic="FOO.>">
						<dispatchPolicy>
							<strictOrderDispatchPolicy />
						</dispatchPolicy>
						<subscriptionRecoveryPolicy>
							<lastImageSubscriptionRecoveryPolicy />
						</subscriptionRecoveryPolicy>
					</policyEntry>
				</policyEntries>
			</policyMap>
		</destinationPolicy>
		<persistenceAdapter>


 
			<journaledJDBC journalLogFiles="5" dataDirectory="../data"
dataSource="#derby-ds"/> 

		</persistenceAdapter>
		<transportConnectors>
			<transportConnector uri="tcp://localhost:61617"/>
		</transportConnectors>
		<networkConnectors>
			<networkConnector name="default-nc" uri="multicast://default"/>
		</networkConnectors>
	</broker>
 
	<bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
		<property name="databaseName" value="derbydb"/>
		<property name="createDatabase" value="create"/>
	</bean>
</beans>


On the slave I have:

<beans>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

<broker brokerName="localhost2" useJmx="true"
masterConnectorURI="tcp://localhost:61617"
shutdownOnMasterFailure="false" xmlns="http://activemq.org/config/1.0">
	<destinationPolicy>
		<policyMap>
			<policyEntries>
				<policyEntry topic="FOO.>">
					<dispatchPolicy>
						<strictOrderDispatchPolicy />
					</dispatchPolicy>
					<subscriptionRecoveryPolicy>
					<lastImageSubscriptionRecoveryPolicy />
					</subscriptionRecoveryPolicy>
				</policyEntry>
			</policyEntries>
		</policyMap>
	</destinationPolicy>
<persistenceAdapter> 
	<journaledJDBC journalLogFiles="5" dataDirectory="../data"
dataSource="#derby-ds"/>
</persistenceAdapter>
<transportConnectors>
	<transportConnector uri="tcp://localhost:61627"/>
</transportConnectors>
<networkConnectors>
	<networkConnector name="default-nc" uri="multicast://default"/>
</networkConnectors>
</broker>

<bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
	<property name="databaseName" value="derbydb"/>
	<property name="createDatabase" value="create"/>
</bean>
 
</beans>



On the spring context file:

<!-- Create pooled JMS ConnectionFactory of ActiveMQ -->
	<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
	  	<property name="connectionFactory">
	       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
	    	  	<property name="brokerURL"
value="failover:(${Report.Broker.URL},${Report.Broker.URL2})?jms.redeliveryPolicy.allPrefetchValues=${allPrefetchValues}&amp;jms.redeliveryPolicy.initialRedeliveryDelay=${initialRedeliveryDelay}&amp;jms.redeliveryPolicy.maximumRedeliveries=${maximumRedeliveries}&amp;jms.redeliveryPolicy.useCollisionAvoidance=${useCollisionAvoidance}"
/>
	       </bean>
	     </property>
	</bean>


Where

Report.Broker.URL=tcp://192.168.0.100:61617
Report.Broker.URL2=tcp:// 192.168.0.101:61627
allPrefetchValues=1
initialRedeliveryDelay=30000
maximumRedeliveries=3
useCollisionAvoidance=true

Regards,
Cristian




rvenkat23 wrote:
> 
> Hi
> 
> I am also facing the same problem. When the master is killed and slave
> becomes the master the messages already placed in the queue are stuck. But
> its able to process the new message produced after slave becomes the
> master. 
> 
> We are using ActiveMQ 4.1.1. what am i doing wrong? Can any one post
> working master / slave example with configuration please.
> 
> Here is our config (shared file system):
> 
> 
>  <broker brokerName="broker61650" useJmx="true" persistent="true"
> xmlns="http://activemq.org/config/1.0">
> 
>  <persistenceAdapter>
>         <journaledJDBC journalLogFiles="5"
> dataDirectory="/SAN/jms/test/"/>
>  </persistenceAdapter>
> 
>     <transportConnectors>
>        <transportConnector name="openwire" uri="tcp://localhost:61650"/>
>     </transportConnectors>
> </broker>
> 
> Thanks,
> Venkatesh.
> 
> 
> Cristian3001 wrote:
>> 
>> I've solved the problem by adding the following to the failover
>> definition in my spring configuration files of the listener:
>> 
>> <property name="brokerURL"
>> value="failover:(${host1},${host2})?jms.redeliveryPolicy.allPrefetchValues=${allPrefetchValues}&amp;jms.redeliveryPolicy.initialRedeliveryDelay=${initialRedeliveryDelay}&amp;jms.redeliveryPolicy.maximumRedeliveries=${maximumRedeliveries}&amp;jms.redeliveryPolicy.useCollisionAvoidance=${useCollisionAvoidance}"
>> />
>> 
>> before it was just: 
>> 
>> <property name="brokerURL" value="failover:(${host1},${host2})" />
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-ActiveMQ4.1.1---Master-Slave-brokers-tp10836705p17758198.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with ActiveMQ4.1.1 - Master/Slave brokers

Posted by rvenkat23 <rv...@yahoo.com>.
Hi

I am also facing the same problem. When the master is killed and slave
becomes the master the messages already placed in the queue are stuck. But
its able to process the new message produced after slave becomes the master. 

We are using ActiveMQ 4.1.1. what am i doing wrong? Can any one post working
master / slave example with configuration please.

Here is our config (shared file system):


 <broker brokerName="broker61650" useJmx="true" persistent="true"
xmlns="http://activemq.org/config/1.0">

 <persistenceAdapter>
        <journaledJDBC journalLogFiles="5" dataDirectory="/SAN/jms/test/"/>
 </persistenceAdapter>

    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://localhost:61650"/>
    </transportConnectors>
</broker>

Thanks,
Venkatesh.


Cristian3001 wrote:
> 
> I've solved the problem by adding the following to the failover definition
> in my spring configuration files of the listener:
> 
> <property name="brokerURL"
> value="failover:(${host1},${host2})?jms.redeliveryPolicy.allPrefetchValues=${allPrefetchValues}&amp;jms.redeliveryPolicy.initialRedeliveryDelay=${initialRedeliveryDelay}&amp;jms.redeliveryPolicy.maximumRedeliveries=${maximumRedeliveries}&amp;jms.redeliveryPolicy.useCollisionAvoidance=${useCollisionAvoidance}"
> />
> 
> before it was just: 
> 
> <property name="brokerURL" value="failover:(${host1},${host2})" />
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-ActiveMQ4.1.1---Master-Slave-brokers-tp10836705s2354p17411749.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with ActiveMQ4.1.1 - Master/Slave brokers

Posted by Cristian3001 <cr...@autodata.net>.
I've solved the problem by adding the following to the failover definition in
my spring configuration files of the listener:

<property name="brokerURL"
value="failover:(${host1},${host2})?jms.redeliveryPolicy.allPrefetchValues=${allPrefetchValues}&amp;jms.redeliveryPolicy.initialRedeliveryDelay=${initialRedeliveryDelay}&amp;jms.redeliveryPolicy.maximumRedeliveries=${maximumRedeliveries}&amp;jms.redeliveryPolicy.useCollisionAvoidance=${useCollisionAvoidance}"
/>

before it was just: 

<property name="brokerURL" value="failover:(${host1},${host2})" />
-- 
View this message in context: http://www.nabble.com/Problems-with-ActiveMQ4.1.1---Master-Slave-brokers-tf3828185s2354.html#a10840281
Sent from the ActiveMQ - User mailing list archive at Nabble.com.