mirror of https://github.com/apache/activemq.git
The QueueMasterSlaveTest and TopicMasterSlaveTest were hanging on on teardown of the test case due us issuing a transport request() that never returned. Converterted to just issuing a oneway and it seems to have fixed the issue.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@376332 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28ca7515c9
commit
4f6e90108f
|
@ -26,7 +26,6 @@ import org.apache.activemq.command.Command;
|
|||
import org.apache.activemq.command.CommandTypes;
|
||||
import org.apache.activemq.command.ConnectionId;
|
||||
import org.apache.activemq.command.ConnectionInfo;
|
||||
import org.apache.activemq.command.ExceptionResponse;
|
||||
import org.apache.activemq.command.MessageDispatch;
|
||||
import org.apache.activemq.command.ProducerInfo;
|
||||
import org.apache.activemq.command.Response;
|
||||
|
@ -59,6 +58,7 @@ public class MasterConnector implements Service{
|
|||
private Transport remoteBroker;
|
||||
private TransportConnector connector;
|
||||
private AtomicBoolean masterActive=new AtomicBoolean(false);
|
||||
private AtomicBoolean started=new AtomicBoolean(false);
|
||||
IdGenerator idGenerator=new IdGenerator();
|
||||
|
||||
ConnectionInfo connectionInfo;
|
||||
|
@ -75,6 +75,9 @@ public class MasterConnector implements Service{
|
|||
}
|
||||
|
||||
public void start() throws Exception{
|
||||
if( !started.compareAndSet(false, true) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
localBroker=TransportFactory.connect(localURI);
|
||||
remoteBroker=TransportFactory.connect(remoteURI);
|
||||
|
@ -84,17 +87,23 @@ public class MasterConnector implements Service{
|
|||
public void onCommand(Command command){
|
||||
}
|
||||
public void onException(IOException error){
|
||||
if( started.get() ) {
|
||||
serviceLocalException(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
remoteBroker.setTransportListener(new TransportListener(){
|
||||
public void onCommand(Command command){
|
||||
if( started.get() ) {
|
||||
serviceRemoteCommand(command);
|
||||
}
|
||||
}
|
||||
public void onException(IOException error){
|
||||
if( started.get() ) {
|
||||
serviceRemoteException(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
masterActive.set(true);
|
||||
|
@ -146,13 +155,17 @@ public class MasterConnector implements Service{
|
|||
}
|
||||
|
||||
public void stop() throws Exception{
|
||||
if( !started.compareAndSet(true, false) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
masterActive.set(false);
|
||||
try{
|
||||
if (connectionInfo!=null){
|
||||
localBroker.request(connectionInfo.createRemoveCommand());
|
||||
}
|
||||
localBroker.setTransportListener(null);
|
||||
remoteBroker.setTransportListener(null);
|
||||
// if (connectionInfo!=null){
|
||||
// localBroker.request(connectionInfo.createRemoveCommand());
|
||||
// }
|
||||
// localBroker.setTransportListener(null);
|
||||
// remoteBroker.setTransportListener(null);
|
||||
remoteBroker.oneway(new ShutdownInfo());
|
||||
localBroker.oneway(new ShutdownInfo());
|
||||
}catch(IOException e){
|
||||
|
|
|
@ -296,7 +296,7 @@ public class RegionBroker implements Broker {
|
|||
|
||||
public void send(ConnectionContext context, Message message) throws Throwable {
|
||||
message.getMessageId().setBrokerSequenceId(sequenceGenerator.getNextSequenceId());
|
||||
if (message.getTimestamp() > 0 && (message.getBrokerPath() == null | message.getBrokerPath().length == 0)) {
|
||||
if (message.getTimestamp() > 0 && (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) {
|
||||
//timestamp not been disabled and has not passed through a network
|
||||
message.setTimestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue