Each instance will try to run "SELECT <tablename> FOR UPDATE" to acquire a lock.
I would first check if the "SELECT FOR UPDATE" syntax is supported by your version of SQL Server. I think at one time this syntax was not supported. See http://www.informit.com/articles/article.aspx?p=327394&seqNum=2. If it turns out that MS SQL supports the 'select for update' syntax I would check the database configuration and also make sure none of your dev tools are holding a lock. Let us know how it turned out - ActiveMQ may need an adapter for MS SQL. -Clark www.ttmsolutions.com ActiveMQ reference guide at http://bit.ly/AMQRefGuide test4john wrote: > > Thanks. > > However, change false to true will cause: > > 2010-07-13 10:52:14,515 [Thread-2 ] INFO > ResourceXmlApplicationContext - Refreshing > org.apache.xbean.spring.context.resourcexmlapplicationcont...@96b5c2: > display name > [org.apache.xbean.spring.context.resourcexmlapplicationcont...@96b5c2]; > startup date [Tue Jul 13 10:52:14 EDT 2010]; parent: > org.springframework.web.context.support.xmlwebapplicationcont...@b51404 > 2010-07-13 10:52:14,515 [Thread-2 ] INFO > XBeanXmlBeanDefinitionReader - Loading XML bean definitions from > ServletContext resource [/WEB-INF/activemq.xml] > 2010-07-13 10:52:14,671 [Thread-2 ] INFO > ResourceXmlApplicationContext - Bean factory for application context > [org.apache.xbean.spring.context.resourcexmlapplicationcont...@96b5c2]: > org.springframework.beans.factory.support.defaultlistablebeanfact...@10d9151 > 2010-07-13 10:52:14,765 [Thread-2 ] INFO BrokerService > - Successfully deleted temporary storage > 2010-07-13 10:52:14,781 [Thread-2 ] INFO BrokerService > - Using Persistence Adapter: > JDBCPersistenceAdapter(org.apache.commons.dbcp.basicdatasou...@c017e9) > 2010-07-13 10:52:15,265 [Thread-2 ] INFO JDBCPersistenceAdapter > - Database adapter driver override not found for : > [microsoft_sql_server_jdbc_driver_2_0]. Will use default implementation. > 2010-07-13 10:52:15,359 [Thread-2 ] INFO JDBCPersistenceAdapter > - Database lock driver override not found for : > [microsoft_sql_server_jdbc_driver_2_0]. Will use default implementation. > 2010-07-13 10:52:15,359 [Thread-2 ] INFO DefaultDatabaseLocker > - Attempting to acquire the exclusive lock to become the Master broker > 2010-07-13 10:52:15,375 [Thread-2 ] INFO DefaultDatabaseLocker > - Failed to acquire lock. Sleeping for 1000 milli(s) before trying > again... > 2010-07-13 10:52:16,375 [Thread-2 ] INFO DefaultDatabaseLocker > - Failed to acquire lock. Sleeping for 1000 milli(s) before trying > again... > > > on both brokers. > > sqljdbc4.jar is used. Also the embedded activemq-web-console-5.3.2.war is > used as the broker instead of the standalone one. > > Thanks, > > > > cobrien wrote: >> >> Hi: >> Set useDatabaseLock=true. >> >> -Clark >> >> www.ttmsolutions.com >> ActiveMQ reference guide at >> http://bit.ly/AMQRefGuide >> >> >> >> >> >> >> test4john wrote: >>> >>> Client code start producing msg OK, but if stop broker A in the middle >>> of the loop (expect broker B will take over and continue to produce), >>> exception occurred: >>> >>> Violation of PRIMARY KEY constraint 'PK__ACTIVEMQ_MSGS__7A521F79'. >>> Cannot insert duplicate key in object 'dbo.ACTIVEMQ_MSGS'. >>> at >>> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49) >>> at >>> org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1273) >>> at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1754) >>> at >>> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:231) >>> at >>> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241) >>> at com.verizon.ams.esme.TestJMS.main(TestJMS.java:91) >>> >>> >>> Suspect it is a MS Sql specific problem but not sure .. >>> >>> Any suggestion appreciated ! >>> >>> ----------------------------------- >>> Client code: >>> >>> ConnectionFactory connectionFactory = new >>> ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, >>> ActiveMQConnection.DEFAULT_PASSWORD, >>> >>> "failover:(tcp://A:61616,tcp://B:61616)?randomize=false"); >>> Connection connection = >>> connectionFactory.createConnection(); >>> connection.start(); >>> Session session = connection.createSession(false, >>> Session.AUTO_ACKNOWLEDGE); >>> Queue testQueue = session.createQueue("MYTest"); >>> MessageProducer producer = >>> session.createProducer(testQueue); >>> producer.setDeliveryMode( DeliveryMode.PERSISTENT ); >>> >>> Message testMessage = session.createMessage(); >>> for(int i = 0; i < 30; i++){ >>> testMessage.setStringProperty("testKey" + i, >>> "testValue" + i); >>> producer.send(testMessage); >>> System.out.println("Now " + i + "th msg is produced."); >>> Thread.sleep(1000); >>> } >>> >>> >>> >>> Two brokers configured as: >>> >>> >>> <beans >>> >>> <bean id="mssql-ds" class="org.apache.commons.dbcp.BasicDataSource" >>> destroy-method="close"> >>> <property name="driverClassName" >>> value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> >>> <property name="url" >>> value="jdbc:sqlserver://dbserver:1433;databaseName=dbn;user=user;password=pwd" >>> /> >>> <property name="username" value="user" /> >>> <property name="password" value="pwd" /> >>> </bean> >>> >>> <broker useJmx="false" xmlns="http://activemq.apache.org/schema/core"> >>> >>> <!-- In ActiveMQ 4, you can setup destination policies --> >>> <destinationPolicy> >>> <policyMap> >>> <policyEntries> >>> >>> <policyEntry topic="FOO.>"> >>> <dispatchPolicy> >>> <strictOrderDispatchPolicy/> >>> </dispatchPolicy> >>> <subscriptionRecoveryPolicy> >>> <lastImageSubscriptionRecoveryPolicy/> >>> </subscriptionRecoveryPolicy> >>> </policyEntry> >>> >>> </policyEntries> >>> </policyMap> >>> </destinationPolicy> >>> >>> >>> >>> <persistenceAdapter> >>> <jdbcPersistenceAdapter dataDirectory="activemq-data" >>> dataSource="#mssql-ds" useDatabaseLock="false"/> >>> </persistenceAdapter> >>> >>> >>> >>> <transportConnectors> >>> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" >>> discoveryUri="multicast://default"/> >>> <transportConnector name="stomp" uri="stomp://localhost:61613"/> >>> <transportConnector name="xmpp" uri="xmpp://localhost:61222"/> >>> </transportConnectors> >>> >>> <networkConnectors> >>> <!-- by default just auto discover the other brokers --> >>> <!-- networkConnector name="defaultNetwork" >>> uri="multicast://default"/ --> >>> <!-- >>> <networkConnector name="host1 and host2" >>> uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/> >>> --> >>> </networkConnectors> >>> >>> </broker> >>> >>> <!-- lets create a command agent to respond to admin commands over JMS >>> or XMPP on the ActiveMQ.Agent topic --> >>> <commandAgent xmlns="http://activemq.apache.org/schema/core"/> >>> >>> </beans> >>> >>> >>> >> >> > > -- View this message in context: http://old.nabble.com/MS-Sql-server-Master-Slave-problem-tp29144656p29152101.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.