[hornetq-commits] JBoss hornetq SVN: r8500 - in trunk: src/main/org/hornetq/core/postoffice and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 2 08:20:33 EST 2009


Author: timfox
Date: 2009-12-02 08:20:31 -0500 (Wed, 02 Dec 2009)
New Revision: 8500

Modified:
   trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
   trunk/src/main/org/hornetq/core/postoffice/PostOffice.java
   trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
   trunk/src/main/org/hornetq/core/server/RoutingContext.java
   trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java
   trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
   trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
Log:
small optimisation to routing

Modified: trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -739,7 +739,7 @@
 
                notificationMessage.putTypedProperties(notifProps);
 
-               postOffice.route(notificationMessage, null);
+               postOffice.route(notificationMessage);
             }
          }
       }

Modified: trunk/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/PostOffice.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/postoffice/PostOffice.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -56,6 +56,8 @@
    
    void route(ServerMessage message, Transaction tx) throws Exception;
    
+   void route(ServerMessage message, RoutingContext context) throws Exception;
+   
    MessageReference reroute(ServerMessage message, Queue queue, Transaction tx) throws Exception;
    
    boolean redistribute(ServerMessage message, final Queue originatingQueue, Transaction tx) throws Exception;

Modified: trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -539,19 +539,22 @@
 
    public void route(final ServerMessage message) throws Exception
    {
-      route(message, null);
+      route(message, (Transaction)null);
    }
-
+   
    public void route(final ServerMessage message, final Transaction tx) throws Exception
    {
+      this.route(message, new RoutingContextImpl(tx));
+   }
+
+   public void route(final ServerMessage message, final RoutingContext context) throws Exception
+   {
       // Sanity check
       if (message.getRefCount() > 0)
       {
          throw new IllegalStateException("Message cannot be routed more than once");
       }
 
-      RoutingContext context = new RoutingContextImpl(tx);
-
       SimpleString address = message.getDestination();
 
       setPagingStore(message);
@@ -661,7 +664,7 @@
 
                message.setDestination(dlaAddress);
 
-               route(message, tx);
+               route(message, context.getTransaction());
             }
          }
       }

Modified: trunk/src/main/org/hornetq/core/server/RoutingContext.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/RoutingContext.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/RoutingContext.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -37,5 +37,7 @@
    List<Queue> getDurableQueues();
    
    int getQueueCount();
+   
+   void clear();
 
 }

Modified: trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -42,6 +42,17 @@
       this.transaction = transaction;
    }
 
+   public void clear()
+   {
+      transaction = null;
+      
+      nonDurableQueues.clear();
+      
+      durableQueues.clear();
+      
+      queueCount = 0;
+   }
+   
    public void addQueue(final Queue queue)
    {
       if (queue.isDurable())

Modified: trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -91,6 +91,7 @@
 import org.hornetq.core.server.LargeServerMessage;
 import org.hornetq.core.server.MessageReference;
 import org.hornetq.core.server.Queue;
+import org.hornetq.core.server.RoutingContext;
 import org.hornetq.core.server.ServerConsumer;
 import org.hornetq.core.server.ServerMessage;
 import org.hornetq.core.server.ServerSession;
@@ -195,6 +196,8 @@
    private boolean closed;
 
    private final Map<SimpleString, CreditManagerHolder> creditManagerHolders = new HashMap<SimpleString, CreditManagerHolder>();
+   
+   private final RoutingContext routingContext = new RoutingContextImpl(null);
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -1965,15 +1968,18 @@
       }
 
       if (tx == null || autoCommitSends)
-      {
-         postOffice.route(msg);
+      {         
       }
       else
       {
-         postOffice.route(msg, tx);
+         routingContext.setTransaction(tx);
       }
+      
+      postOffice.route(msg, routingContext);
+      
+      routingContext.clear();      
    }
-
+   
    private static final class CreditManagerHolder
    {
       CreditManagerHolder(final PagingStore store)

Modified: trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java	2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java	2009-12-02 13:20:31 UTC (rev 8500)
@@ -175,6 +175,12 @@
       
    }
 
+   public void route(ServerMessage message, RoutingContext context) throws Exception
+   {
+      // TODO Auto-generated method stub
+      
+   }
 
 
+
 }
\ No newline at end of file



More information about the hornetq-commits mailing list