You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by dc...@apache.org on 2002/10/16 23:47:58 UTC

cvs commit: xml-axis/java/src/org/apache/axis/components/jms SonicMQVendorAdapter.java JMSVendorAdapter.java

dchappell    2002/10/16 14:47:58

  Modified:    java/src/org/apache/axis/components/jms
                        SonicMQVendorAdapter.java JMSVendorAdapter.java
  Log:
  Jaime's patch submission from 2 weeks ago.  Cleans up exception handling somewhat in that it allows detection of specific detection of things like connection drop vs. "can't create queue".
  
  Revision  Changes    Path
  1.2       +76 -0     xml-axis/java/src/org/apache/axis/components/jms/SonicMQVendorAdapter.java
  
  Index: SonicMQVendorAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/jms/SonicMQVendorAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SonicMQVendorAdapter.java	24 Sep 2002 23:47:01 -0000	1.1
  +++ SonicMQVendorAdapter.java	16 Oct 2002 21:47:58 -0000	1.2
  @@ -60,6 +60,12 @@
   import javax.jms.ConnectionFactory;
   import javax.jms.QueueConnectionFactory;
   import javax.jms.TopicConnectionFactory;
  +import javax.jms.JMSException;
  +
  +import progress.message.client.EUserAlreadyConnected;
  +import progress.message.client.ENetworkFailure;
  +
  +import progress.message.jclient.ErrorCodes;
   
   /**
    * Defines SonicMQ specific constants for connnection factory creation.
  @@ -219,5 +225,75 @@
           cfConfig = (HashMap)cfConfig.clone();
           cfConfig.put(CONNECTION_FACTORY_CLASS, TCF_CLASS);
           return super.getTopicConnectionFactory(cfConfig);
  +    }
  +
  +    public boolean isRecoverable(Throwable thrown, int action)
  +    {
  +        //the super class cannot be trusted for on exception because it always
  +        //returns false
  +        if(action != ON_EXCEPTION_ACTION && !super.isRecoverable(thrown, action))
  +            return false;
  +
  +        if(!(thrown instanceof JMSException))
  +            return true;
  +
  +        JMSException jmse = (JMSException)thrown;
  +        switch(action)
  +        {
  +            case CONNECT_ACTION:
  +                if(isNetworkFailure(jmse))
  +                    return false;
  +                break;
  +            case SUBSCRIBE_ACTION:
  +
  +                if(isQueueMissing(jmse) || isAnotherSubscriberConnected(jmse))
  +                    return false;
  +                break;
  +
  +            case ON_EXCEPTION_ACTION:
  +                if(isConnectionDropped(jmse))
  +                    return false;
  +                break;
  +
  +        }
  +
  +        return true;
  +    }
  +
  +    public boolean isConnectionDropped(JMSException jmse)
  +    {
  +        return ErrorCodes.testException(jmse, ErrorCodes.ERR_CONNECTION_DROPPED);
  +    }
  +
  +    private boolean isQueueMissing(JMSException jmse)
  +    {
  +        String message = jmse.getMessage();
  +        if(message != null && message.startsWith("Queue not found"))
  +        {
  +            return true;
  +        }
  +        return false;
  +    }
  +
  +    private boolean isAnotherSubscriberConnected(JMSException jmse)
  +    {
  +        Exception linkedException = jmse.getLinkedException();
  +        if(linkedException != null &&
  +           linkedException instanceof EUserAlreadyConnected)
  +        {
  +            return true;
  +        }
  +        return false;
  +    }
  +
  +    private boolean isNetworkFailure(JMSException jmse)
  +    {
  +        Exception linkedException = jmse.getLinkedException();
  +        if(linkedException != null &&
  +           linkedException instanceof ENetworkFailure)
  +        {
  +            return true;
  +        }
  +        return false;
       }
   }
  
  
  
  1.2       +21 -0     xml-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapter.java
  
  Index: JMSVendorAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSVendorAdapter.java	24 Sep 2002 23:47:01 -0000	1.1
  +++ JMSVendorAdapter.java	16 Oct 2002 21:47:58 -0000	1.2
  @@ -63,6 +63,9 @@
   import javax.jms.QueueSession;
   import javax.jms.Topic;
   import javax.jms.TopicSession;
  +import javax.jms.JMSException;
  +import javax.jms.JMSSecurityException;
  +import javax.jms.InvalidDestinationException;
   
   /**
    * SPI Interface that all JMSVendorAdaptors must implement.  Allows for
  @@ -73,6 +76,12 @@
   public abstract class JMSVendorAdapter
   {
   
  +    public static final int SEND_ACTION = 0;
  +    public static final int CONNECT_ACTION = 1;
  +    public static final int SUBSCRIBE_ACTION = 2;
  +    public static final int RECEIVE_ACTION = 3;
  +    public static final int ON_EXCEPTION_ACTION = 4;
  +
       public abstract QueueConnectionFactory getQueueConnectionFactory(HashMap cfProps)
           throws Exception;
   
  @@ -91,5 +100,17 @@
           return session.createTopic(name);
       }
   
  +
  +    public boolean isRecoverable(Throwable thrown, int action)
  +    {
  +        if(thrown instanceof RuntimeException ||
  +           thrown instanceof Error ||
  +           thrown instanceof JMSSecurityException ||
  +           thrown instanceof InvalidDestinationException)
  +            return false;
  +        if(action == ON_EXCEPTION_ACTION)
  +            return false;
  +        return true;
  +    }
   
   }