From 25b6812daaae09572c85cbd99cf527bc278e27d8 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Tue, 26 Feb 2008 14:56:31 +0000 Subject: [PATCH] Added network and fault tolerant flags to ConnectionContext git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@631241 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/activemq/broker/Connection.java | 6 ++++++ .../org/apache/activemq/broker/ConnectionContext.java | 9 +++++++++ .../org/apache/activemq/broker/TransportConnection.java | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/Connection.java b/activemq-core/src/main/java/org/apache/activemq/broker/Connection.java index 1344e5d0df..65237c9374 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/Connection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/Connection.java @@ -104,5 +104,11 @@ public interface Connection extends Service { void serviceExceptionAsync(IOException e); String getConnectionId(); + + /** + * return true if a network connection + * @return + */ + boolean isNetworkConnection(); } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java index 6378c56913..fd260420ee 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/ConnectionContext.java @@ -53,6 +53,7 @@ public class ConnectionContext { private boolean producerFlowControl = true; private MessageAuthorizationPolicy messageAuthorizationPolicy; private boolean networkConnection; + private boolean faultTolerant; private final AtomicBoolean stopping = new AtomicBoolean(); private final MessageEvaluationContext messageEvaluationContext = new MessageEvaluationContext(); private boolean dontSendReponse; @@ -278,4 +279,12 @@ public class ConnectionContext { public void setClientMaster(boolean clientMaster) { this.clientMaster = clientMaster; } + + public boolean isFaultTolerant() { + return faultTolerant; + } + + public void setFaultTolerant(boolean faultTolerant) { + this.faultTolerant = faultTolerant; + } } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java index a4c5ebd1a7..a1175dc059 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -146,6 +146,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi private CountDownLatch dispatchStoppedLatch = new CountDownLatch(1); private ConnectionContext context; private boolean networkConnection; + private boolean faultTolerantConnection; private AtomicInteger protocolVersion = new AtomicInteger(CommandTypes.PROTOCOL_VERSION); private DemandForwardingBridge duplexBridge; private final TaskRunnerFactory taskRunnerFactory; @@ -647,6 +648,7 @@ public class TransportConnection implements Service, Connection, Task, CommandVi context.setConnector(connector); context.setMessageAuthorizationPolicy(getMessageAuthorizationPolicy()); context.setNetworkConnection(networkConnection); + context.setFaultTolerant(faultTolerantConnection); context.setTransactions(new ConcurrentHashMap()); context.setUserName(info.getUserName()); context.setWireFormatInfo(wireFormatInfo); @@ -1076,6 +1078,10 @@ public class TransportConnection implements Service, Connection, Task, CommandVi public synchronized boolean isStarting() { return starting; } + + public synchronized boolean isNetworkConnection() { + return networkConnection; + } protected synchronized void setStarting(boolean starting) { this.starting = starting; @@ -1255,6 +1261,9 @@ public class TransportConnection implements Service, Connection, Task, CommandVi } public Response processConnectionControl(ConnectionControl control) throws Exception { + if(control != null) { + faultTolerantConnection=control.isFaultTolerant(); + } return null; }