From 10a976674edc472181635c5a68f5446067b6216b Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Fri, 21 May 2010 11:40:27 +0000 Subject: [PATCH] possibly resolve https://issues.apache.org/activemq/browse/AMQ-2564 - add test and fix issue with slave replication effecting response correlator when message is queued waiting for space, the id can get out of sync, causing a missed reply to the orignal producer, which would result in a hang git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@946974 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/broker/ft/MasterBroker.java | 3 +- .../MasterSlaveProducerFlowControlTest.java | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveProducerFlowControlTest.java diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java b/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java index 2e7f51620c..46f437123e 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java @@ -341,8 +341,9 @@ public class MasterBroker extends InsertableMutableBrokerFilter { * A message can be dispatched before the super.send() method returns so - * here the order is switched to avoid problems on the slave with * receiving acks for messages not received yet + * copy ensures we don't mess with the correlator and command ids */ - sendSyncToSlave(message); + sendSyncToSlave(message.copy()); super.send(producerExchange, message); } diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveProducerFlowControlTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveProducerFlowControlTest.java new file mode 100644 index 0000000000..b6fe862c78 --- /dev/null +++ b/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveProducerFlowControlTest.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.broker.ft; + +import org.apache.activemq.ProducerFlowControlTest; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy; +import org.apache.activemq.broker.region.policy.VMPendingSubscriberMessageStoragePolicy; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class MasterSlaveProducerFlowControlTest extends ProducerFlowControlTest { + static final Log LOG = LogFactory.getLog(MasterSlaveProducerFlowControlTest.class); + + protected BrokerService createBroker() throws Exception { + BrokerService service = super.createBroker(); + service.start(); + + BrokerService slave = new BrokerService(); + slave.setBrokerName("Slave"); + slave.setPersistent(false); + slave.setUseJmx(false); + + // Setup a destination policy where it takes lots of message at a time. + // so that slave does not block first as there is no producer flow control + // on the master connector + PolicyMap policyMap = new PolicyMap(); + PolicyEntry policy = new PolicyEntry(); + // don't apply the same memory limit as the master in this case + //policy.setMemoryLimit(10); + policy.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy()); + policy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy()); + policy.setProducerFlowControl(true); + policyMap.setDefaultEntry(policy); + + slave.setDestinationPolicy(policyMap); + slave.setMasterConnectorURI(connector.getConnectUri().toString()); + slave.start(); + return service; + } +}