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-tp29144656p29144656.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.