activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r418121 - in /incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker: AbstractConnection.java BrokerStoppedException.java ErrorBroker.java
Date Thu, 29 Jun 2006 19:25:58 GMT
Author: chirino
Date: Thu Jun 29 12:25:57 2006
New Revision: 418121

URL: http://svn.apache.org/viewvc?rev=418121&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQ-780

Added:
    incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/BrokerStoppedException.java
      - copied unchanged from r418119, incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerStoppedException.java
Modified:
    incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java
    incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java

Modified: incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java
URL: http://svn.apache.org/viewvc/incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java?rev=418121&r1=418120&r2=418121&view=diff
==============================================================================
--- incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java
(original)
+++ incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java
Thu Jun 29 12:25:57 2006
@@ -179,10 +179,35 @@
         if (e instanceof IOException) {
             serviceTransportException((IOException) e);
         }
+        
+        // Handle the case where the broker is stopped 
+        // But the client is still connected.
+        else if (e.getClass() == BrokerStoppedException.class ) {
+            if( !disposed ) {
+                if( serviceLog.isDebugEnabled() )
+                	serviceLog.debug("Broker has been stopped.  Notifying client and closing
his connection.");
+                
+                ConnectionError ce = new ConnectionError();
+                ce.setException(e);
+                dispatchSync(ce);
+                
+                // Wait a little bit to try to get the output buffer to flush the exption
notification to the client.
+                try {
+					Thread.sleep(500);
+				} catch (InterruptedException ie) {
+					Thread.currentThread().interrupt();
+				}
+                
+				// Worst case is we just kill the connection before the notification gets to him.
+                ServiceSupport.dispose(this);
+            }
+        }
+        
         else if( !disposed && !inServiceException ) {
             inServiceException = true;
                 try {
-                serviceLog.info("Async error occurred: "+e,e);
+                if( serviceLog.isDebugEnabled() )
+                	serviceLog.debug("Async error occurred: "+e,e);
                 ConnectionError ce = new ConnectionError();
                 ce.setException(e);
                 dispatchAsync(ce);
@@ -201,7 +226,8 @@
             response = command.visit(this);
         } catch ( Throwable e ) {
             if( responseRequired ) {
-                serviceLog.info("Sync error occurred: "+e,e);
+            	if( serviceLog.isDebugEnabled() && e.getClass()!=BrokerStoppedException.class
)
+            		serviceLog.debug("Error occured while processing sync command: "+e,e);
                 response = new ExceptionResponse(e);
             } else {
                 serviceException(e);
@@ -558,6 +584,7 @@
     public void dispatchSync(Command message) {
         processDispatch(message);
     }
+    
     
     public void dispatchAsync(Command message) {
         if( taskRunner==null ) {

Modified: incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java?rev=418121&r1=418120&r2=418121&view=diff
==============================================================================
--- incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
(original)
+++ incubator/activemq/branches/activemq-4.0/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
Thu Jun 29 12:25:57 2006
@@ -19,6 +19,7 @@
 import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.activemq.broker.region.Destination;
 import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.command.ActiveMQDestination;
@@ -37,7 +38,7 @@
 import org.apache.activemq.command.TransactionId;
 
 /**
- * Implementation of the broker where all it's methods throw an IllegalStateException.
+ * Implementation of the broker where all it's methods throw an BrokerStoppedException.
  * 
  * @version $Revision$
  */
@@ -61,132 +62,132 @@
     }
     
     public BrokerId getBrokerId() {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public String getBrokerName() {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 	
     public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable
error) throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void addSession(ConnectionContext context, SessionInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeSession(ConnectionContext context, SessionInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public Connection[] getClients() throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public ActiveMQDestination[] getDestinations() throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws
Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase)
throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void forgetTransaction(ConnectionContext context, TransactionId transactionId)
throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public Destination addDestination(ConnectionContext context, ActiveMQDestination destination)
throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeDestination(ConnectionContext context, ActiveMQDestination destination,
long timeout) throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info)
throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void send(ConnectionContext context, Message message) throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void gc() {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void start() throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void stop() throws Exception {
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void addBroker(Connection connection,BrokerInfo info){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
         
     }
     
     public void removeBroker(Connection connection,BrokerInfo info){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public BrokerInfo[] getPeerBrokerInfos(){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
     
     public void processDispatch(MessageDispatch messageDispatch){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
     
     public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
     
     public boolean isSlaveBroker(){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
     
     public boolean isStopped(){
@@ -194,21 +195,21 @@
     }
     
     public Set getDurableDestinations(){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
 
     public void addDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
         
     }
 
     public void removeDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
         
     }
 
     public boolean isFaultTolerantConfiguration(){
-        throw new IllegalStateException(this.message);
+        throw new BrokerStoppedException(this.message);
     }
     
    



Mime
View raw message