[jboss-cvs] jboss-jms/src/main/org/jboss/jms/server/plugin ...

Timothy Fox tim.fox at jboss.com
Thu Jul 27 15:01:55 EDT 2006


  User: timfox  
  Date: 06/07/27 15:01:55

  Modified:    src/main/org/jboss/jms/server/plugin  JDBCChannelMapper.java
  Log:
  Mainly http://jira.jboss.com/jira/browse/JBMESSAGING-434 plus a few other bits and pieces
  
  Revision  Changes    Path
  1.18      +347 -331  jboss-jms/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JDBCChannelMapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- JDBCChannelMapper.java	17 Jul 2006 17:14:46 -0000	1.17
  +++ JDBCChannelMapper.java	27 Jul 2006 19:01:55 -0000	1.18
  @@ -40,6 +40,7 @@
   import org.jboss.jms.server.plugin.contract.ChannelMapper;
   import org.jboss.jms.server.subscription.DurableSubscription;
   import org.jboss.jms.server.subscription.Subscription;
  +import org.jboss.jms.util.ExceptionUtil;
   import org.jboss.jms.util.MessagingJMSException;
   import org.jboss.logging.Logger;
   import org.jboss.messaging.core.local.CoreDestination;
  @@ -59,7 +60,6 @@
   
   /**
    * JDBC Implementation of ChannelMapper
  - * 
    * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  @@ -196,6 +196,8 @@
      
      protected void startService() throws Exception
      {
  +      try
  +      {
         if (ds == null)
         {
            InitialContext ic = new InitialContext();
  @@ -218,6 +220,11 @@
         
         log.debug(this + " started");
      }
  +      catch (Throwable t)
  +      {
  +         throw ExceptionUtil.handleJMXInvocation(t, this + " startService");
  +      } 
  +   }
      
      protected void stopService() throws Exception
      {
  @@ -241,6 +248,8 @@
         return (JBossDestination)idMap.get(new Long(coreDestinationId));
      }
       
  +   
  +    
      public void deployCoreDestination(boolean isQueue, 
                                        String destName,
                                        MessageStore ms, 
  @@ -248,9 +257,7 @@
                                        MemoryManager mm,
                                        int fullSize, 
                                        int pageSize, 
  -                                     int downCacheSize) throws JMSException
  -   {
  -      try
  +                                     int downCacheSize) throws Exception
         {         
            if (log.isTraceEnabled()) { log.trace("creating core destination for " + destName); }
            
  @@ -351,15 +358,9 @@
            log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
                      pageSize  + ", downCacheSize=" + downCacheSize + ") deployed");
         }
  -      catch (Exception e)
  -      {
  -         log.error("Failed to deploy core destination", e);
  -         throw new MessagingJMSException("Failed to deploy core destination", e);        
  -      }
  -   }
      
      public CoreDestination undeployCoreDestination(boolean isQueue, String destName)
  -      throws JMSException
  +      throws Exception
      {
         Map m = isQueue ? queues : topics;
         
  @@ -400,12 +401,80 @@
      }
      
      
  +   public void deployTemporaryCoreDestination(boolean isQueue, 
  +            String destName,
  +            long id,
  +            MessageStore ms, 
  +            PersistenceManager pm,
  +            MemoryManager mm,
  +            int fullSize, 
  +            int pageSize, 
  +            int downCacheSize) throws Exception
  +   {        
  +      if (log.isTraceEnabled()) { log.trace("creating temporary core destination for " + destName); }
  +      
  +      CoreDestination cd = getCoreDestinationInternal(isQueue, destName);
  +      if (cd != null)
  +      {
  +         throw new JMSException("Destination " + destName + " already deployed");
  +      }      
  +      
  +      if (isQueue)
  +      {
  +         //We allocate an executor for the queue from the rotating pool
  +         QueuedExecutor executor = (QueuedExecutor)queuedExecutorPool.get(destName);
  +         
  +         cd = new Queue(id, ms, pm, mm, false, fullSize, pageSize, downCacheSize, executor);                 
  +         
  +         queues.put(destName, cd);
  +      }
  +      else
  +      {
  +         cd = new Topic(id, fullSize, pageSize, downCacheSize);
  +         
  +         topics.put(destName, cd);         
  +      }
  +      
  +      //Put in id map too
  +      
  +      JBossDestination jbd ;
  +      
  +      if (isQueue)
  +      {
  +         jbd = new JBossQueue(destName);
  +      }
  +      else
  +      {
  +         jbd =  new JBossTopic(destName);
  +      }
  +      
  +      idMap.put(new Long(id), jbd);
  +      
  +      log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
  +               pageSize  + ", downCacheSize=" + downCacheSize + ") deployed");
  +   }
  +   
  +   public CoreDestination undeployTemporaryCoreDestination(boolean isQueue, String destName)
  +      throws Exception
  +   {
  +      Map m = isQueue ? queues : topics;
  +      
  +      CoreDestination dest = (CoreDestination)m.remove(destName);
  +      
  +      if (dest != null)
  +      {      
  +         idMap.remove(new Long(dest.getId())); 
  +      }
  +      
  +      return dest;
  +   }
  +   
      public DurableSubscription getDurableSubscription(String clientID,
                                                        String subscriptionName,                                                         
                                                        MessageStore ms,
                                                        PersistenceManager pm,
                                                        MemoryManager mm)
  -      throws JMSException
  +      throws Exception
      {
         // Look in memory first
         DurableSubscription sub = getDurableSubscription(clientID, subscriptionName);
  @@ -416,8 +485,6 @@
         }
         
         //Now look in the db
  -      try
  -      {         
            Connection conn = null;
            PreparedStatement ps  = null;
            ResultSet rs = null;
  @@ -506,19 +573,6 @@
               wrap.end();
            }
         }
  -      catch (JMSException e)
  -      {
  -         throw e;
  -      }
  -      catch (Exception e)
  -      {
  -         final String msg = "Failed to get subscription";
  -         log.error(msg, e);
  -         JMSException e2 = new JMSException(msg);
  -         e2.setLinkedException(e);
  -         throw e2;
  -      }      
  -   }
        
      public DurableSubscription createDurableSubscription(String topicName,
                                                            String clientID,
  @@ -527,23 +581,17 @@
                                                            boolean noLocal,                                                            
                                                            MessageStore ms,
                                                            PersistenceManager pm,
  -                                                         MemoryManager mm) throws JMSException
  +                                                         MemoryManager mm) throws Exception
      {
         Selector sel = selector == null ? null : new Selector(selector);
         
         long id;
  -      try
  -      {
  +
            //First insert a row in the db
            id = this.getNextId();
            
            insertMappingRow(id, TYPE_DURABLE_SUB, topicName, subscriptionName, clientID,
                             selector, new Boolean(noLocal));
  -      }
  -      catch (Exception e)
  -      {
  -         throw new MessagingJMSException("Failed to create durable subscription", e);
  -      }
         
         return createDurableSubscriptionInternal(id, topicName, clientID, subscriptionName, sel,
                                                  noLocal, ms, pm, mm);          
  @@ -552,12 +600,10 @@
      public Subscription createSubscription(String topicName, String selector, boolean noLocal,
                                             MessageStore ms, PersistenceManager pm,
                                             MemoryManager mm)
  -      throws JMSException
  +      throws Exception
      {
         Selector sel = selector == null ? null : new Selector(selector);
   
  -      try
  -      {
            long id = this.getNextId();
            
            Topic topic = (Topic)getCoreDestinationInternal(false, topicName);
  @@ -575,18 +621,11 @@
                                    topic.getFullSize(), topic.getPageSize(),
                                    topic.getDownCacheSize(), executor, sel, noLocal);
         }
  -      catch (Exception e)
  -      {
  -         throw new MessagingJMSException("Failed to create durable subscription", e);        
  -      }
  -   }
      
      
      
      public boolean removeDurableSubscription(String clientID, String subscriptionName)
  -      throws JMSException
  -   {
  -      try
  +      throws Exception
         {
            DurableSubscription removed = removeDurableSubscriptionInMemory(clientID, subscriptionName);
            
  @@ -602,14 +641,9 @@
               return false;
            }
         }
  -      catch (Exception e)
  -      {
  -         throw new MessagingJMSException("Failed to remove durable subscription", e);        
  -      }
  -   }
      
      //FIXME - This doesn't belong here
  -   public String getPreConfiguredClientID(String username) throws JMSException
  +   public String getPreConfiguredClientID(String username) throws Exception
      {
         try
         {
  @@ -799,14 +833,10 @@
      protected List loadDurableSubscriptionsForTopic(String topicName,                                               
                                                      MessageStore ms,
                                                      PersistenceManager pm,
  -                                                   MemoryManager mm) throws JMSException
  -   {      
  -      try
  +                                                   MemoryManager mm) throws Exception
         {         
            List result = new ArrayList();
            
  -         try
  -         {
               Connection conn = null;
               PreparedStatement ps  = null;
               ResultSet rs = null;
  @@ -876,23 +906,9 @@
                  }
                  wrap.end();
               }
  -         }
  -         catch (Exception e)
  -         {
  -            final String msg = "Failed to get durable subscription";
  -            log.error(msg, e);
  -            JMSException e2 = new JMSException(msg);
  -            e2.setLinkedException(e);
  -            throw e2;
  -         }
                    
            return result;
         }
  -      catch (Exception e)
  -      {
  -         throw new MessagingJMSException("Failed to load durable subscriptions for topic", e);        
  -      }
  -   }
   
      
   
  
  
  



More information about the jboss-cvs-commits mailing list