<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>commits@activemq.apache.org Archives</title>
<link rel="self" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/?format=atom"/>
<link href="http://mail-archives.apache.org/mod_mbox/activemq-commits/"/>
<id>http://mail-archives.apache.org/mod_mbox/activemq-commits/</id>
<updated>2009-12-08T04:25:52Z</updated>
<entry>
<title>svn commit: r888227 [2/2] - in /activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker: jmx/ region/ region/policy/</title>
<author><name>cmacnaug@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091208022731.9012723889D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091208022731-9012723889D0@eris-apache-org%3e</id>
<updated>2009-12-08T02:27:30Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java (original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java Tue Dec  8 02:27:30 2009
@@ -76,7 +76,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-
 /**
  * The Queue is a List of MessageEntry objects that are dispatched to matching
  * subscriptions.
@@ -86,10 +85,10 @@
 public class Queue extends BaseDestination implements Task, UsageListener {
     protected static final Log LOG = LogFactory.getLog(Queue.class);
     protected final TaskRunnerFactory taskFactory;
-    protected TaskRunner taskRunner;    
+    protected TaskRunner taskRunner;
     protected final List&lt;Subscription&gt; consumers = new ArrayList&lt;Subscription&gt;(50);
     protected PendingMessageCursor messages;
-    private final LinkedHashMap&lt;MessageId,QueueMessageReference&gt; pagedInMessages = new LinkedHashMap&lt;MessageId,QueueMessageReference&gt;();
+    private final LinkedHashMap&lt;MessageId, QueueMessageReference&gt; pagedInMessages = new LinkedHashMap&lt;MessageId, QueueMessageReference&gt;();
     // Messages that are paged in but have not yet been targeted at a subscription
     private List&lt;QueueMessageReference&gt; pagedInPendingDispatch = new ArrayList&lt;QueueMessageReference&gt;(100);
     private MessageGroupMap messageGroupOwners;
@@ -99,16 +98,16 @@
     private ExecutorService executor;
     protected final LinkedList&lt;Runnable&gt; messagesWaitingForSpace = new LinkedList&lt;Runnable&gt;();
     private final Object dispatchMutex = new Object();
-    private boolean useConsumerPriority=true;
-    private boolean strictOrderDispatch=false;
+    private boolean useConsumerPriority = true;
+    private boolean strictOrderDispatch = false;
     private QueueDispatchSelector dispatchSelector;
-    private boolean optimizedDispatch=false;
+    private boolean optimizedDispatch = false;
     private boolean firstConsumer = false;
     private int timeBeforeDispatchStarts = 0;
     private int consumersBeforeDispatchStarts = 0;
     private CountDownLatch consumersBeforeStartsLatch;
     private AtomicLong pendingWakeups = new AtomicLong();
-    
+
     private final Runnable sendMessagesWaitingForSpaceTask = new Runnable() {
         public void run() {
             asyncWakeup();
@@ -116,25 +115,24 @@
     };
     private final Runnable expireMessagesTask = new Runnable() {
         public void run() {
-            expireMessages();          
+            expireMessages();
         }
     };
     private final Object iteratingMutex = new Object() {};
     private static final Scheduler scheduler = Scheduler.getInstance();
-    
-    private static final Comparator&lt;Subscription&gt;orderedCompare = new Comparator&lt;Subscription&gt;() {
+
+    private static final Comparator&lt;Subscription&gt; orderedCompare = new Comparator&lt;Subscription&gt;() {
 
         public int compare(Subscription s1, Subscription s2) {
             //We want the list sorted in descending order
             return s2.getConsumerInfo().getPriority() - s1.getConsumerInfo().getPriority();
-        }        
+        }
     };
-               
-    public Queue(BrokerService brokerService, final ActiveMQDestination destination, MessageStore store,DestinationStatistics parentStats,
-                 TaskRunnerFactory taskFactory) throws Exception {
+
+    public Queue(BrokerService brokerService, final ActiveMQDestination destination, MessageStore store, DestinationStatistics parentStats, TaskRunnerFactory taskFactory) throws Exception {
         super(brokerService, store, destination, parentStats);
-        this.taskFactory=taskFactory;       
-        this.dispatchSelector=new QueueDispatchSelector(destination);
+        this.taskFactory = taskFactory;
+        this.dispatchSelector = new QueueDispatchSelector(destination);
     }
 
     public List&lt;Subscription&gt; getConsumers() {
@@ -146,13 +144,13 @@
     // make the queue easily visible in the debugger from its task runner threads
     final class QueueThread extends Thread {
         final Queue queue;
-        public QueueThread(Runnable runnable, String name,
-                Queue queue) {
+
+        public QueueThread(Runnable runnable, String name, Queue queue) {
             super(runnable, name);
             this.queue = queue;
         }
     }
-    
+
     public void initialize() throws Exception {
         if (this.messages == null) {
             if (destination.isTemporary() || broker == null || store == null) {
@@ -169,10 +167,9 @@
             this.systemUsage = brokerService.getSystemUsage();
             memoryUsage.setParent(systemUsage.getMemoryUsage());
         }
-        
-        this.taskRunner =
-            taskFactory.createTaskRunner(this, "Queue:" + destination.getPhysicalName());
-        
+
+        this.taskRunner = taskFactory.createTaskRunner(this, "Queue:" + destination.getPhysicalName());
+
         super.initialize();
         if (store != null) {
             // Restore the persistent messages.
@@ -218,12 +215,12 @@
                     public boolean hasSpace() {
                         return true;
                     }
-                    
+
                     public boolean isDuplicate(MessageId id) {
                         return false;
                     }
                 });
-            }else {
+            } else {
                 int messageCount = store.getMessageCount();
                 destinationStatistics.getMessages().setCount(messageCount);
             }
@@ -231,22 +228,20 @@
     }
 
     /*
-     * Holder for subscription and pagedInMessages as a browser
-     * needs access to existing messages in the queue that have
-     * already been dispatched
+     * Holder for subscription and pagedInMessages as a browser needs access to
+     * existing messages in the queue that have already been dispatched
      */
     class BrowserDispatch {
         ArrayList&lt;QueueMessageReference&gt; messages;
         QueueBrowserSubscription browser;
-        
-        public BrowserDispatch(QueueBrowserSubscription browserSubscription,
-                Collection&lt;QueueMessageReference&gt; values) {
-            
-            messages =  new ArrayList&lt;QueueMessageReference&gt;(values);
+
+        public BrowserDispatch(QueueBrowserSubscription browserSubscription, Collection&lt;QueueMessageReference&gt; values) {
+
+            messages = new ArrayList&lt;QueueMessageReference&gt;(values);
             browser = browserSubscription;
             browser.incrementQueueRef();
         }
-        
+
         void done() {
             try {
                 browser.decrementQueueRef();
@@ -259,57 +254,57 @@
             return browser;
         }
     }
-   
+
     LinkedList&lt;BrowserDispatch&gt; browserDispatches = new LinkedList&lt;BrowserDispatch&gt;();
 
     public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
         // synchronize with dispatch method so that no new messages are sent
         // while setting up a subscription. avoid out of order messages,
         // duplicates, etc.
-        synchronized(dispatchMutex) {
-        
+        synchronized (dispatchMutex) {
+
             sub.add(context, this);
             destinationStatistics.getConsumers().increment();
 
             // needs to be synchronized - so no contention with dispatching
             synchronized (consumers) {
-            	
-            	// set a flag if this is a first consumer
-            	if (consumers.size() == 0) {
-            		firstConsumer = true;
-            		if (consumersBeforeDispatchStarts != 0) {
-            			consumersBeforeStartsLatch = new CountDownLatch(consumersBeforeDispatchStarts - 1);
-            		}
-            	} else {
-                	if (consumersBeforeStartsLatch != null) {
-                		consumersBeforeStartsLatch.countDown();
-                	}
-            	}
-            	
+
+                // set a flag if this is a first consumer
+                if (consumers.size() == 0) {
+                    firstConsumer = true;
+                    if (consumersBeforeDispatchStarts != 0) {
+                        consumersBeforeStartsLatch = new CountDownLatch(consumersBeforeDispatchStarts - 1);
+                    }
+                } else {
+                    if (consumersBeforeStartsLatch != null) {
+                        consumersBeforeStartsLatch.countDown();
+                    }
+                }
+
                 addToConsumerList(sub);
                 if (sub.getConsumerInfo().isExclusive()) {
                     Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer();
-                    if(exclusiveConsumer==null) {
-                        exclusiveConsumer=sub;
-                    }else if (sub.getConsumerInfo().getPriority() &gt; exclusiveConsumer.getConsumerInfo().getPriority()){
-                        exclusiveConsumer=sub;
+                    if (exclusiveConsumer == null) {
+                        exclusiveConsumer = sub;
+                    } else if (sub.getConsumerInfo().getPriority() &gt; exclusiveConsumer.getConsumerInfo().getPriority()) {
+                        exclusiveConsumer = sub;
                     }
                     dispatchSelector.setExclusiveConsumer(exclusiveConsumer);
                 }
             }
-            
-            if (sub instanceof QueueBrowserSubscription ) { 
+
+            if (sub instanceof QueueBrowserSubscription) {
                 QueueBrowserSubscription browserSubscription = (QueueBrowserSubscription) sub;
-            	
+
                 // do again in iterate to ensure new messages are dispatched
                 pageInMessages(false);
-                
-            	synchronized (pagedInMessages) {
-            	    if (!pagedInMessages.isEmpty()) {
-            	        BrowserDispatch browserDispatch = new BrowserDispatch(browserSubscription, pagedInMessages.values());
-            	        browserDispatches.addLast(browserDispatch);
-            	    }
-            	}
+
+                synchronized (pagedInMessages) {
+                    if (!pagedInMessages.isEmpty()) {
+                        BrowserDispatch browserDispatch = new BrowserDispatch(browserSubscription, pagedInMessages.values());
+                        browserDispatches.addLast(browserDispatch);
+                    }
+                }
             }
             if (!(this.optimizedDispatch || isSlave())) {
                 wakeup();
@@ -322,30 +317,23 @@
         }
     }
 
-    public void removeSubscription(ConnectionContext context, Subscription sub, long lastDeiveredSequenceId)
-            throws Exception {
+    public void removeSubscription(ConnectionContext context, Subscription sub, long lastDeiveredSequenceId) throws Exception {
         destinationStatistics.getConsumers().decrement();
         // synchronize with dispatch method so that no new messages are sent
         // while removing up a subscription.
-        synchronized(dispatchMutex) {
+        synchronized (dispatchMutex) {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("remove sub: " + sub + ", lastDeliveredSeqId: " + lastDeiveredSequenceId
-                        + ", dequeues: " + getDestinationStatistics().getDequeues().getCount()
-                        + ", dispatched: " + getDestinationStatistics().getDispatched().getCount()
-                        + ", inflight: " + getDestinationStatistics().getInflight().getCount());
+                LOG.debug("remove sub: " + sub + ", lastDeliveredSeqId: " + lastDeiveredSequenceId + ", dequeues: " + getDestinationStatistics().getDequeues().getCount() + ", dispatched: "
+                        + getDestinationStatistics().getDispatched().getCount() + ", inflight: " + getDestinationStatistics().getInflight().getCount());
             }
             synchronized (consumers) {
                 removeFromConsumerList(sub);
                 if (sub.getConsumerInfo().isExclusive()) {
-                    Subscription exclusiveConsumer = dispatchSelector
-                            .getExclusiveConsumer();
+                    Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer();
                     if (exclusiveConsumer == sub) {
                         exclusiveConsumer = null;
                         for (Subscription s : consumers) {
-                            if (s.getConsumerInfo().isExclusive()
-                                    &amp;&amp; (exclusiveConsumer == null
-                                    || s.getConsumerInfo().getPriority() &gt; exclusiveConsumer
-                                            .getConsumerInfo().getPriority())) {
+                            if (s.getConsumerInfo().isExclusive() &amp;&amp; (exclusiveConsumer == null || s.getConsumerInfo().getPriority() &gt; exclusiveConsumer.getConsumerInfo().getPriority())) {
                                 exclusiveConsumer = s;
 
                             }
@@ -355,12 +343,12 @@
                 }
                 ConsumerId consumerId = sub.getConsumerInfo().getConsumerId();
                 getMessageGroupOwners().removeConsumer(consumerId);
-                
+
                 // redeliver inflight messages
                 List&lt;QueueMessageReference&gt; list = new ArrayList&lt;QueueMessageReference&gt;();
                 for (MessageReference ref : sub.remove(context, this)) {
-                    QueueMessageReference qmr = (QueueMessageReference)ref;
-                    if( qmr.getLockOwner()==sub ) {
+                    QueueMessageReference qmr = (QueueMessageReference) ref;
+                    if (qmr.getLockOwner() == sub) {
                         qmr.unlock();
                         // only increment redelivery if it was delivered or we have no delivery information
                         if (lastDeiveredSequenceId == 0 || qmr.getMessageId().getBrokerSequenceId() &lt;= lastDeiveredSequenceId) {
@@ -369,7 +357,7 @@
                     }
                     list.add(qmr);
                 }
-                
+
                 if (!list.isEmpty()) {
                     doDispatch(list);
                 }
@@ -401,32 +389,33 @@
             }
             return;
         }
-        if(memoryUsage.isFull()) {
+        if (memoryUsage.isFull()) {
             isFull(context, memoryUsage);
             fastProducer(context, producerInfo);
             if (isProducerFlowControl() &amp;&amp; context.isProducerFlowControl()) {
-                if(warnOnProducerFlowControl) {
+                if (warnOnProducerFlowControl) {
                     warnOnProducerFlowControl = false;
-                    LOG.info("Usage Manager memory limit reached on " +getActiveMQDestination().getQualifiedName() + ". Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it." +
-                            " See http://activemq.apache.org/producer-flow-control.html for more info");
+                    LOG.info("Usage Manager Memory Limit reached on " + getActiveMQDestination().getQualifiedName()
+                            + ". Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it."
+                            + " See http://activemq.apache.org/producer-flow-control.html for more info");
                 }
-                
+
                 if (systemUsage.isSendFailIfNoSpace()) {
-                    throw new javax.jms.ResourceAllocationException("Usage Manager memory limit reached. Stopping producer (" + message.getProducerId() + ") to prevent flooding " +getActiveMQDestination().getQualifiedName() + "." +
-                            " See http://activemq.apache.org/producer-flow-control.html for more info");
+                    throw new javax.jms.ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + message.getProducerId() + ") to prevent flooding "
+                            + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
                 }
-    
+
                 // We can avoid blocking due to low usage if the producer is sending
                 // a sync message or
                 // if it is using a producer window
                 if (producerInfo.getWindowSize() &gt; 0 || message.isResponseRequired()) {
                     // copy the exchange state since the context will be modified while we are waiting
                     // for space.
-                    final ProducerBrokerExchange producerExchangeCopy = producerExchange.copy(); 
+                    final ProducerBrokerExchange producerExchangeCopy = producerExchange.copy();
                     synchronized (messagesWaitingForSpace) {
                         messagesWaitingForSpace.add(new Runnable() {
                             public void run() {
-    
+
                                 try {
                                     // While waiting for space to free up... the
                                     // message may have expired.
@@ -437,7 +426,7 @@
                                     } else {
                                         doMessageSend(producerExchangeCopy, message);
                                     }
-    
+
                                     if (sendProducerAck) {
                                         ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize());
                                         context.getConnection().dispatchAsync(ack);
@@ -446,7 +435,7 @@
                                         response.setCorrelationId(message.getCommandId());
                                         context.getConnection().dispatchAsync(response);
                                     }
-    
+
                                 } catch (Exception e) {
                                     if (!sendProducerAck &amp;&amp; !context.isInRecoveryMode()) {
                                         ExceptionResponse response = new ExceptionResponse(e);
@@ -456,7 +445,7 @@
                                 }
                             }
                         });
-    
+
                         // If the user manager is not full, then the task will not
                         // get called..
                         if (!memoryUsage.notifyCallbackWhenNotFull(sendMessagesWaitingForSpaceTask)) {
@@ -466,18 +455,14 @@
                         context.setDontSendReponse(true);
                         return;
                     }
-    
+
                 } else {
-    
-                    // Producer flow control cannot be used, so we have do the flow
-                    // control at the broker
-                    // by blocking this thread until there is space available.
-                    while (!memoryUsage.waitForSpace(1000)) {
-                        if (context.getStopping().get()) {
-                            throw new IOException("Connection closed, send aborted.");
-                        }
+
+                    if (memoryUsage.isFull()) {
+                        waitForSpace(context, memoryUsage, "Usage Manager Memory Limit is full. Producer (" + message.getProducerId() + ") stopped to prevent flooding "
+                                + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
                     }
-    
+
                     // The usage manager could have delayed us by the time
                     // we unblock the message could have expired..
                     if (message.isExpired()) {
@@ -502,19 +487,15 @@
         synchronized (sendLock) {
             if (store != null &amp;&amp; message.isPersistent()) {
                 if (systemUsage.getStoreUsage().isFull()) {
-                    final String logMessage = "Usage Manager Store is Full. Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." +
-                            " See http://activemq.apache.org/producer-flow-control.html for more info";
-                    LOG.info(logMessage);
+
+                    String logMessage = "Usage Manager Store is Full. Producer (" + message.getProducerId() + ") stopped to prevent flooding " + getActiveMQDestination().getQualifiedName() + "."
+                            + " See http://activemq.apache.org/producer-flow-control.html for more info";
+
                     if (systemUsage.isSendFailIfNoSpace()) {
                         throw new javax.jms.ResourceAllocationException(logMessage);
                     }
-                }
-                while (!systemUsage.getStoreUsage().waitForSpace(1000)) {
-                    if (context.getStopping().get()) {
-                        throw new IOException(
-                                "Connection closed, send aborted.");
-                    }
-                    LOG.debug(this  + ", waiting for store space... msg: " + message);
+
+                    waitForSpace(context, systemUsage.getStoreUsage(), logMessage);
                 }
                 message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());
                 store.addMessage(context, message);
@@ -553,12 +534,12 @@
             sendMessage(context, message);
         }
     }
-    
+
     private void expireMessages() {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Expiring messages ..");
         }
-        
+
         // just track the insertion count
         List&lt;Message&gt; browsedMessages = new AbstractList&lt;Message&gt;() {
             int size = 0;
@@ -582,9 +563,9 @@
         asyncWakeup();
     }
 
-    public void gc(){
+    public void gc() {
     }
-    
+
     public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack, MessageReference node) throws IOException {
         messageConsumed(context, node);
         if (store != null &amp;&amp; node.isPersistent()) {
@@ -617,8 +598,8 @@
         synchronized (messages) {
             size = messages.size();
         }
-        return "Queue: destination=" + destination.getPhysicalName() + ", subscriptions=" + consumers.size() + ", memory=" + memoryUsage.getPercentUsage() + "%, size=" + size
-               + ", in flight groups=" + messageGroupOwners;
+        return "Queue: destination=" + destination.getPhysicalName() + ", subscriptions=" + consumers.size() + ", memory=" + memoryUsage.getPercentUsage() + "%, size=" + size + ", in flight groups="
+                + messageGroupOwners;
     }
 
     public void start() throws Exception {
@@ -633,25 +614,25 @@
         doPageIn(false);
     }
 
-    public void stop() throws Exception{
+    public void stop() throws Exception {
         if (taskRunner != null) {
             taskRunner.shutdown();
         }
         if (this.executor != null) {
             this.executor.shutdownNow();
         }
-        
+
         scheduler.cancel(expireMessagesTask);
-        
+
         if (messages != null) {
             messages.stop();
         }
-        
+
         systemUsage.getMemoryUsage().removeUsageListener(this);
         if (memoryUsage != null) {
             memoryUsage.stop();
         }
-        if (store!=null) {
+        if (store != null) {
             store.stop();
         }
     }
@@ -662,7 +643,6 @@
         return destination;
     }
 
-    
     public MessageGroupMap getMessageGroupOwners() {
         if (messageGroupOwners == null) {
             messageGroupOwners = getMessageGroupMapFactory().createMessageGroupMap();
@@ -693,7 +673,7 @@
     public void setMessages(PendingMessageCursor messages) {
         this.messages = messages;
     }
-    
+
     public boolean isUseConsumerPriority() {
         return useConsumerPriority;
     }
@@ -709,7 +689,6 @@
     public void setStrictOrderDispatch(boolean strictOrderDispatch) {
         this.strictOrderDispatch = strictOrderDispatch;
     }
-    
 
     public boolean isOptimizedDispatch() {
         return optimizedDispatch;
@@ -718,21 +697,22 @@
     public void setOptimizedDispatch(boolean optimizedDispatch) {
         this.optimizedDispatch = optimizedDispatch;
     }
-	public int getTimeBeforeDispatchStarts() {
-		return timeBeforeDispatchStarts;
-	}
-
-	public void setTimeBeforeDispatchStarts(int timeBeforeDispatchStarts) {
-		this.timeBeforeDispatchStarts = timeBeforeDispatchStarts;
-	}
-
-	public int getConsumersBeforeDispatchStarts() {
-		return consumersBeforeDispatchStarts;
-	}
-
-	public void setConsumersBeforeDispatchStarts(int consumersBeforeDispatchStarts) {
-		this.consumersBeforeDispatchStarts = consumersBeforeDispatchStarts;
-	}
+
+    public int getTimeBeforeDispatchStarts() {
+        return timeBeforeDispatchStarts;
+    }
+
+    public void setTimeBeforeDispatchStarts(int timeBeforeDispatchStarts) {
+        this.timeBeforeDispatchStarts = timeBeforeDispatchStarts;
+    }
+
+    public int getConsumersBeforeDispatchStarts() {
+        return consumersBeforeDispatchStarts;
+    }
+
+    public void setConsumersBeforeDispatchStarts(int consumersBeforeDispatchStarts) {
+        this.consumersBeforeDispatchStarts = consumersBeforeDispatchStarts;
+    }
 
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -741,19 +721,18 @@
         return result;
     }
 
-    public Message[] browse() {    
+    public Message[] browse() {
         List&lt;Message&gt; l = new ArrayList&lt;Message&gt;();
         doBrowse(l, getMaxBrowsePageSize());
         return l.toArray(new Message[l.size()]);
     }
-    
-    
+
     public void doBrowse(List&lt;Message&gt; l, int max) {
         final ConnectionContext connectionContext = createConnectionContext();
         try {
             pageInMessages(false);
             List&lt;MessageReference&gt; toExpire = new ArrayList&lt;MessageReference&gt;();
-            synchronized(dispatchMutex) {
+            synchronized (dispatchMutex) {
                 synchronized (pagedInPendingDispatch) {
                     addAll(pagedInPendingDispatch, l, max, toExpire);
                     for (MessageReference ref : toExpire) {
@@ -776,17 +755,16 @@
                         }
                     }
                 }
-                
+
                 if (l.size() &lt; getMaxBrowsePageSize()) {
                     synchronized (messages) {
                         try {
                             messages.reset();
                             while (messages.hasNext() &amp;&amp; l.size() &lt; max) {
-                                MessageReference node = messages.next();        
+                                MessageReference node = messages.next();
                                 if (node.isExpired()) {
                                     if (broker.isExpired(node)) {
-                                        messageExpired(connectionContext,
-                                                createMessageReference(node.getMessage()));
+                                        messageExpired(connectionContext, createMessageReference(node.getMessage()));
                                     }
                                     messages.remove();
                                 } else {
@@ -801,16 +779,14 @@
                         }
                     }
                 }
-            } 
+            }
         } catch (Exception e) {
             LOG.error("Problem retrieving message for browse", e);
-        }     
+        }
     }
 
-    private void addAll(Collection&lt;QueueMessageReference&gt; refs,
-            List&lt;Message&gt; l, int maxBrowsePageSize, List&lt;MessageReference&gt; toExpire) throws Exception {
-        for (Iterator&lt;QueueMessageReference&gt; i = refs.iterator(); i.hasNext()
-                &amp;&amp; l.size() &lt; getMaxBrowsePageSize();) {
+    private void addAll(Collection&lt;QueueMessageReference&gt; refs, List&lt;Message&gt; l, int maxBrowsePageSize, List&lt;MessageReference&gt; toExpire) throws Exception {
+        for (Iterator&lt;QueueMessageReference&gt; i = refs.iterator(); i.hasNext() &amp;&amp; l.size() &lt; getMaxBrowsePageSize();) {
             QueueMessageReference ref = i.next();
             if (ref.isExpired()) {
                 toExpire.add(ref);
@@ -844,8 +820,7 @@
                                 break;
                             }
                         } catch (IOException e) {
-                            LOG.error("got an exception retrieving message "
-                                    + id);
+                            LOG.error("got an exception retrieving message " + id);
                         }
                     }
                 } finally {
@@ -858,10 +833,10 @@
         return null;
     }
 
-    public void purge() throws Exception {   
+    public void purge() throws Exception {
         ConnectionContext c = createConnectionContext();
         List&lt;MessageReference&gt; list = null;
-        do {        
+        do {
             doPageIn(true);
             synchronized (pagedInMessages) {
                 list = new ArrayList&lt;MessageReference&gt;(pagedInMessages.values());
@@ -870,11 +845,11 @@
             for (MessageReference ref : list) {
                 try {
                     QueueMessageReference r = (QueueMessageReference) ref;
-                        removeMessage(c,(IndirectMessageReference) r);
+                    removeMessage(c, (IndirectMessageReference) r);
                 } catch (IOException e) {
                 }
             }
-            
+
         } while (!pagedInMessages.isEmpty() || this.destinationStatistics.getMessages().getCount() &gt; 0);
         gc();
         this.destinationStatistics.getMessages().setCount(0);
@@ -922,15 +897,14 @@
             synchronized (pagedInMessages) {
                 set.addAll(pagedInMessages.values());
             }
-            List &lt;MessageReference&gt;list = new ArrayList&lt;MessageReference&gt;(set);
+            List&lt;MessageReference&gt; list = new ArrayList&lt;MessageReference&gt;(set);
             for (MessageReference ref : list) {
                 IndirectMessageReference r = (IndirectMessageReference) ref;
                 if (filter.evaluate(context, r)) {
 
                     removeMessage(context, r);
                     set.remove(r);
-                    if (++movedCounter &gt;= maximumMessages
-                            &amp;&amp; maximumMessages &gt; 0) {
+                    if (++movedCounter &gt;= maximumMessages &amp;&amp; maximumMessages &gt; 0) {
                         return movedCounter;
                     }
                 }
@@ -976,24 +950,23 @@
         int count = 0;
         Set&lt;MessageReference&gt; set = new CopyOnWriteArraySet&lt;MessageReference&gt;();
         do {
-            int oldMaxSize=getMaxPageSize();
+            int oldMaxSize = getMaxPageSize();
             setMaxPageSize((int) this.destinationStatistics.getMessages().getCount());
             doPageIn(true);
             setMaxPageSize(oldMaxSize);
             synchronized (pagedInMessages) {
                 set.addAll(pagedInMessages.values());
             }
-            List &lt;MessageReference&gt;list = new ArrayList&lt;MessageReference&gt;(set);
+            List&lt;MessageReference&gt; list = new ArrayList&lt;MessageReference&gt;(set);
             for (MessageReference ref : list) {
                 IndirectMessageReference r = (IndirectMessageReference) ref;
                 if (filter.evaluate(context, r)) {
-                    
-                    r.incrementReferenceCount();                    
+
+                    r.incrementReferenceCount();
                     try {
                         Message m = r.getMessage();
                         BrokerSupport.resend(context, m, dest);
-                        if (++movedCounter &gt;= maximumMessages
-                                &amp;&amp; maximumMessages &gt; 0) {
+                        if (++movedCounter &gt;= maximumMessages &amp;&amp; maximumMessages &gt; 0) {
                             return movedCounter;
                         }
                     } finally {
@@ -1005,15 +978,16 @@
         } while (count &lt; this.destinationStatistics.getMessages().getCount());
         return movedCounter;
     }
-    
+
     /**
      * Move a message
+     * 
      * @param context connection context
      * @param m message
      * @param dest ActiveMQDestination
      * @throws Exception
      */
-    public boolean moveMessageTo(ConnectionContext context,Message m,ActiveMQDestination dest) throws Exception {
+    public boolean moveMessageTo(ConnectionContext context, Message m, ActiveMQDestination dest) throws Exception {
         QueueMessageReference r = createMessageReference(m);
         BrokerSupport.resend(context, m, dest);
         removeMessage(context, r);
@@ -1036,7 +1010,7 @@
      * @return the number of messages removed
      */
     public int moveMatchingMessagesTo(ConnectionContext context, String selector, ActiveMQDestination dest) throws Exception {
-        return moveMatchingMessagesTo(context, selector, dest,Integer.MAX_VALUE);
+        return moveMatchingMessagesTo(context, selector, dest, Integer.MAX_VALUE);
     }
 
     /**
@@ -1051,9 +1025,7 @@
      * Moves the messages matching the given filter up to the maximum number of
      * matched messages
      */
-    public int moveMatchingMessagesTo(ConnectionContext context,
-            MessageReferenceFilter filter, ActiveMQDestination dest,
-            int maximumMessages) throws Exception {
+    public int moveMatchingMessagesTo(ConnectionContext context, MessageReferenceFilter filter, ActiveMQDestination dest, int maximumMessages) throws Exception {
         int movedCounter = 0;
         Set&lt;MessageReference&gt; set = new CopyOnWriteArraySet&lt;MessageReference&gt;();
         do {
@@ -1068,20 +1040,18 @@
                     // We should only move messages that can be locked.
                     moveMessageTo(context, ref.getMessage(), dest);
                     set.remove(r);
-                    if (++movedCounter &gt;= maximumMessages
-                            &amp;&amp; maximumMessages &gt; 0) {
+                    if (++movedCounter &gt;= maximumMessages &amp;&amp; maximumMessages &gt; 0) {
                         return movedCounter;
                     }
                 }
             }
-        } while (set.size() &lt; this.destinationStatistics.getMessages().getCount()
-                &amp;&amp; set.size() &lt; maximumMessages);
+        } while (set.size() &lt; this.destinationStatistics.getMessages().getCount() &amp;&amp; set.size() &lt; maximumMessages);
         return movedCounter;
     }
-    
+
     BrowserDispatch getNextBrowserDispatch() {
         synchronized (pagedInMessages) {
-            if( browserDispatches.isEmpty() ) {
+            if (browserDispatches.isEmpty()) {
                 return null;
             }
             return browserDispatches.removeFirst();
@@ -1094,93 +1064,93 @@
      * @see org.apache.activemq.thread.Task#iterate()
      */
     public boolean iterate() {
-        boolean pageInMoreMessages = false;   
-        synchronized(iteratingMutex) {
-            
+        boolean pageInMoreMessages = false;
+        synchronized (iteratingMutex) {
+
             // do early to allow dispatch of these waiting messages
-            synchronized(messagesWaitingForSpace) {
+            synchronized (messagesWaitingForSpace) {
                 while (!messagesWaitingForSpace.isEmpty() &amp;&amp; !memoryUsage.isFull()) {
                     Runnable op = messagesWaitingForSpace.removeFirst();
                     op.run();
                 }
             }
-            
+
             BrowserDispatch rd;
-	        while ((rd = getNextBrowserDispatch()) != null) {
-	            pageInMoreMessages = true;
-	            
-	            try {
-	                MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
-	                msgContext.setDestination(destination);
-	    
-	                QueueBrowserSubscription browser = rd.getBrowser();
-	                for (QueueMessageReference node : rd.messages) {
-	                    if (!node.isAcked()) {
-	                        msgContext.setMessageReference(node);
-	                        if (browser.matches(node, msgContext)) {
-	                            browser.add(node);
-	                        }
-	                    }
-	                }
-	                                    
+            while ((rd = getNextBrowserDispatch()) != null) {
+                pageInMoreMessages = true;
+
+                try {
+                    MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
+                    msgContext.setDestination(destination);
+
+                    QueueBrowserSubscription browser = rd.getBrowser();
+                    for (QueueMessageReference node : rd.messages) {
+                        if (!node.isAcked()) {
+                            msgContext.setMessageReference(node);
+                            if (browser.matches(node, msgContext)) {
+                                browser.add(node);
+                            }
+                        }
+                    }
+
                     rd.done();
 
-	            } catch (Exception e) {
-	                LOG.warn("exception on dispatch to browser: " + rd.getBrowser(), e);
-	            }
-	        }
-	        
-	        if (firstConsumer) {
-	        	firstConsumer = false;
-	        	try {
-	        		if (consumersBeforeDispatchStarts &gt; 0) {
-	        			int timeout = 1000; // wait one second by default if consumer count isn't reached  
-	        			if (timeBeforeDispatchStarts &gt; 0) {
-	        				timeout = timeBeforeDispatchStarts;
-	        			}
-	        			if (consumersBeforeStartsLatch.await(timeout, TimeUnit.MILLISECONDS)) {
-	        				if (LOG.isDebugEnabled()) {
-	        					LOG.debug(consumers.size() + " consumers subscribed. Starting dispatch.");
-	        				}
-	        			} else {
-	        				if (LOG.isDebugEnabled()) {
-	        					LOG.debug(timeout + " ms elapsed and " +  consumers.size() + " consumers subscribed. Starting dispatch.");
-	        				}
-	        			}
-	        		}	        		
-	        		if (timeBeforeDispatchStarts &gt; 0 &amp;&amp; consumersBeforeDispatchStarts &lt;= 0) {
-	        			iteratingMutex.wait(timeBeforeDispatchStarts);
-	        			if (LOG.isDebugEnabled()) {
-	        				LOG.debug(timeBeforeDispatchStarts + " ms elapsed. Starting dispatch.");
-	        			}
-	        		}
-	        	} catch (Exception e) {
-	        		LOG.error(e);
-	        	}
-	        }
-	        
-	        synchronized (messages) {
-	            pageInMoreMessages |= !messages.isEmpty();
-	        }               
-	        
-	        // Kinda ugly.. but I think dispatchLock is the only mutex protecting the 
-	        // pagedInPendingDispatch variable. 	        
-	        synchronized(dispatchMutex) {
-	            pageInMoreMessages |= !pagedInPendingDispatch.isEmpty();
-	        } 
-	        
-	        // Perhaps we should page always into the pagedInPendingDispatch list if 
-	        // !messages.isEmpty(), and then if !pagedInPendingDispatch.isEmpty()
-	        // then we do a dispatch.
-	        if (pageInMoreMessages) {
-	            try {
-	               pageInMessages(false);
-	               
-	            } catch (Throwable e) {
-	                LOG.error("Failed to page in more queue messages ", e);
+                } catch (Exception e) {
+                    LOG.warn("exception on dispatch to browser: " + rd.getBrowser(), e);
+                }
+            }
+
+            if (firstConsumer) {
+                firstConsumer = false;
+                try {
+                    if (consumersBeforeDispatchStarts &gt; 0) {
+                        int timeout = 1000; // wait one second by default if consumer count isn't reached  
+                        if (timeBeforeDispatchStarts &gt; 0) {
+                            timeout = timeBeforeDispatchStarts;
+                        }
+                        if (consumersBeforeStartsLatch.await(timeout, TimeUnit.MILLISECONDS)) {
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug(consumers.size() + " consumers subscribed. Starting dispatch.");
+                            }
+                        } else {
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug(timeout + " ms elapsed and " + consumers.size() + " consumers subscribed. Starting dispatch.");
+                            }
+                        }
+                    }
+                    if (timeBeforeDispatchStarts &gt; 0 &amp;&amp; consumersBeforeDispatchStarts &lt;= 0) {
+                        iteratingMutex.wait(timeBeforeDispatchStarts);
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug(timeBeforeDispatchStarts + " ms elapsed. Starting dispatch.");
+                        }
+                    }
+                } catch (Exception e) {
+                    LOG.error(e);
+                }
+            }
+
+            synchronized (messages) {
+                pageInMoreMessages |= !messages.isEmpty();
+            }
+
+            // Kinda ugly.. but I think dispatchLock is the only mutex protecting the 
+            // pagedInPendingDispatch variable. 	        
+            synchronized (dispatchMutex) {
+                pageInMoreMessages |= !pagedInPendingDispatch.isEmpty();
+            }
+
+            // Perhaps we should page always into the pagedInPendingDispatch list if 
+            // !messages.isEmpty(), and then if !pagedInPendingDispatch.isEmpty()
+            // then we do a dispatch.
+            if (pageInMoreMessages) {
+                try {
+                    pageInMessages(false);
+
+                } catch (Throwable e) {
+                    LOG.error("Failed to page in more queue messages ", e);
                 }
-	        }        
-	        return pendingWakeups.decrementAndGet() &gt; 0;
+            }
+            return pendingWakeups.decrementAndGet() &gt; 0;
         }
     }
 
@@ -1189,8 +1159,9 @@
             public boolean evaluate(ConnectionContext context, MessageReference r) {
                 return messageId.equals(r.getMessageId().toString());
             }
+
             public String toString() {
-                return "MessageIdFilter: "+messageId;
+                return "MessageIdFilter: " + messageId;
             }
         };
     }
@@ -1214,22 +1185,22 @@
 
     protected void removeMessage(ConnectionContext c, QueueMessageReference r) throws IOException {
         removeMessage(c, null, r);
-        synchronized(dispatchMutex) {            
+        synchronized (dispatchMutex) {
             synchronized (pagedInPendingDispatch) {
                 pagedInPendingDispatch.remove(r);
             }
         }
     }
-    
-    protected void removeMessage(ConnectionContext c, Subscription subs,QueueMessageReference r) throws IOException {
+
+    protected void removeMessage(ConnectionContext c, Subscription subs, QueueMessageReference r) throws IOException {
         MessageAck ack = new MessageAck();
         ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
         ack.setDestination(destination);
         ack.setMessageID(r.getMessageId());
         removeMessage(c, subs, r, ack);
     }
-    
-    protected void removeMessage(ConnectionContext context,Subscription sub,final QueueMessageReference reference,MessageAck ack) throws IOException {
+
+    protected void removeMessage(ConnectionContext context, Subscription sub, final QueueMessageReference reference, MessageAck ack) throws IOException {
         reference.setAcked(true);
         // This sends the ack the the journal..
         if (!ack.isInTransaction()) {
@@ -1241,13 +1212,13 @@
                 acknowledge(context, sub, ack, reference);
             } finally {
                 context.getTransaction().addSynchronization(new Synchronization() {
-                
+
                     public void afterCommit() throws Exception {
                         getDestinationStatistics().getDequeues().increment();
                         dropMessage(reference);
                         wakeup();
                     }
-                
+
                     public void afterRollback() throws Exception {
                         reference.setAcked(false);
                     }
@@ -1256,38 +1227,38 @@
         }
         if (ack.isPoisonAck()) {
             // message gone to DLQ, is ok to allow redelivery
-            synchronized(messages) {
+            synchronized (messages) {
                 messages.rollback(reference.getMessageId());
             }
         }
 
     }
-    
+
     private void dropMessage(QueueMessageReference reference) {
         reference.drop();
         destinationStatistics.getMessages().decrement();
-        synchronized(pagedInMessages) {
+        synchronized (pagedInMessages) {
             pagedInMessages.remove(reference.getMessageId());
         }
     }
-    
-    public void messageExpired(ConnectionContext context,MessageReference reference) {
-        messageExpired(context,null,reference);
+
+    public void messageExpired(ConnectionContext context, MessageReference reference) {
+        messageExpired(context, null, reference);
     }
-    
-    public void messageExpired(ConnectionContext context,Subscription subs, MessageReference reference) {
+
+    public void messageExpired(ConnectionContext context, Subscription subs, MessageReference reference) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("message expired: " + reference);
         }
         broker.messageExpired(context, reference);
         destinationStatistics.getExpired().increment();
         try {
-            removeMessage(context,subs,(QueueMessageReference)reference);
+            removeMessage(context, subs, (QueueMessageReference) reference);
         } catch (IOException e) {
-            LOG.error("Failed to remove expired Message from the store ",e);
+            LOG.error("Failed to remove expired Message from the store ", e);
         }
     }
-    
+
     protected ConnectionContext createConnectionContext() {
         ConnectionContext answer = new ConnectionContext(new NonCachedMessageEvaluationContext());
         answer.setBroker(this.broker);
@@ -1298,17 +1269,18 @@
 
     final void sendMessage(final ConnectionContext context, Message msg) throws Exception {
         if (!msg.isPersistent() &amp;&amp; messages.getSystemUsage() != null) {
-        	if (systemUsage.getTempUsage().isFull()) {
-                final String logMessage = "Usage Manager Temp Store is Full. Stopping producer (" + msg.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." +
-                        " See http://activemq.apache.org/producer-flow-control.html for more info";
-                LOG.info(logMessage);
+            if (systemUsage.getTempUsage().isFull()) {
+                final String logMessage = "Usage Manager Temp Store is Full. Stopping producer (" + msg.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "."
+                        + " See http://activemq.apache.org/producer-flow-control.html for more info";
                 if (systemUsage.isSendFailIfNoSpace()) {
                     throw new javax.jms.ResourceAllocationException(logMessage);
                 }
+
+                waitForSpace(context, messages.getSystemUsage().getTempUsage(), logMessage);
             }
-            messages.getSystemUsage().getTempUsage().waitForSpace();
+
         }
-        synchronized(messages) {
+        synchronized (messages) {
             messages.addMessageLast(msg);
         }
         destinationStatistics.getEnqueues().increment();
@@ -1321,7 +1293,7 @@
         }
         wakeup();
     }
-    
+
     public void wakeup() {
         if (optimizedDispatch || isSlave()) {
             iterate();
@@ -1334,12 +1306,12 @@
     private void asyncWakeup() {
         try {
             pendingWakeups.incrementAndGet();
-            this.taskRunner.wakeup();    
+            this.taskRunner.wakeup();
         } catch (InterruptedException e) {
             LOG.warn("Async task tunner failed to wakeup ", e);
         }
     }
-  
+
     private boolean isSlave() {
         return broker.getBrokerService().isSlave();
     }
@@ -1347,14 +1319,13 @@
     private List&lt;QueueMessageReference&gt; doPageIn(boolean force) throws Exception {
         List&lt;QueueMessageReference&gt; result = null;
         List&lt;QueueMessageReference&gt; resultList = null;
-        synchronized(dispatchMutex) {
+        synchronized (dispatchMutex) {
             int toPageIn = Math.min(getMaxPageSize(), messages.size());
             if (LOG.isDebugEnabled()) {
-                LOG.debug(destination.getPhysicalName() + " toPageIn: "  + toPageIn + ", Inflight: "
-                        + destinationStatistics.getInflight().getCount()
-                        + ", pagedInMessages.size " + pagedInMessages.size());
+                LOG.debug(destination.getPhysicalName() + " toPageIn: " + toPageIn + ", Inflight: " + destinationStatistics.getInflight().getCount() + ", pagedInMessages.size "
+                        + pagedInMessages.size());
             }
-           
+
             if (isLazyDispatch() &amp;&amp; !force) {
                 // Only page in the minimum number of messages which can be dispatched immediately.
                 toPageIn = Math.min(getConsumerMessageCountBeforeFull(), toPageIn);
@@ -1378,7 +1349,7 @@
                             } else {
                                 result.add(ref);
                                 count++;
-                            }   
+                            }
                         }
                     } finally {
                         messages.release();
@@ -1387,7 +1358,7 @@
                 // Only add new messages, not already pagedIn to avoid multiple dispatch attempts
                 synchronized (pagedInMessages) {
                     resultList = new ArrayList&lt;QueueMessageReference&gt;(result.size());
-                    for(QueueMessageReference ref : result) {
+                    for (QueueMessageReference ref : result) {
                         if (!pagedInMessages.containsKey(ref.getMessageId())) {
                             pagedInMessages.put(ref.getMessageId(), ref);
                             resultList.add(ref);
@@ -1404,8 +1375,8 @@
 
     private void doDispatch(List&lt;QueueMessageReference&gt; list) throws Exception {
         boolean doWakeUp = false;
-        synchronized(dispatchMutex) {
-       
+        synchronized (dispatchMutex) {
+
             synchronized (pagedInPendingDispatch) {
                 if (!pagedInPendingDispatch.isEmpty()) {
                     // Try to first dispatch anything that had not been
@@ -1427,20 +1398,20 @@
                     }
                 }
             }
-        } 
+        }
         if (doWakeUp) {
             // avoid lock order contention
             asyncWakeup();
         }
     }
-    
+
     /**
      * @return list of messages that could get dispatched to consumers if they
      *         were not full.
      */
     private List&lt;QueueMessageReference&gt; doActualDispatch(List&lt;QueueMessageReference&gt; list) throws Exception {
         List&lt;Subscription&gt; consumers;
-        
+
         synchronized (this.consumers) {
             if (this.consumers.isEmpty() || isSlave()) {
                 // slave dispatch happens in processDispatchNotification
@@ -1451,15 +1422,15 @@
 
         List&lt;QueueMessageReference&gt; rc = new ArrayList&lt;QueueMessageReference&gt;(list.size());
         Set&lt;Subscription&gt; fullConsumers = new HashSet&lt;Subscription&gt;(this.consumers.size());
-        
+
         for (MessageReference node : list) {
             Subscription target = null;
-            int interestCount=0;
+            int interestCount = 0;
             for (Subscription s : consumers) {
-            	if (s instanceof QueueBrowserSubscription) {
-            		interestCount++;
-            		continue;
-            	}
+                if (s instanceof QueueBrowserSubscription) {
+                    interestCount++;
+                    continue;
+                }
                 if (dispatchSelector.canSelect(s, node)) {
                     if (!fullConsumers.contains(s)) {
                         if (!s.isFull()) {
@@ -1474,23 +1445,22 @@
                     }
                     interestCount++;
                 } else {
-                	// makes sure it gets dispatched again
-                	if (!node.isDropped() &amp;&amp; !((QueueMessageReference)node).isAcked() &amp;&amp; (!node.isDropped() || s.getConsumerInfo().isBrowser())) {
-                		interestCount++;
-                	}
+                    // makes sure it gets dispatched again
+                    if (!node.isDropped() &amp;&amp; !((QueueMessageReference) node).isAcked() &amp;&amp; (!node.isDropped() || s.getConsumerInfo().isBrowser())) {
+                        interestCount++;
+                    }
                 }
             }
-            
-            if ((target == null &amp;&amp; interestCount&gt;0) || consumers.size() == 0) {
+
+            if ((target == null &amp;&amp; interestCount &gt; 0) || consumers.size() == 0) {
                 // This means all subs were full or that there are no consumers...
-                rc.add((QueueMessageReference)node);
+                rc.add((QueueMessageReference) node);
             }
 
             // If it got dispatched, rotate the consumer list to get round robin distribution. 
-            if (target != null &amp;&amp; !strictOrderDispatch &amp;&amp; consumers.size() &gt; 1 &amp;&amp;
-                    !dispatchSelector.isExclusiveConsumer(target)) {
+            if (target != null &amp;&amp; !strictOrderDispatch &amp;&amp; consumers.size() &gt; 1 &amp;&amp; !dispatchSelector.isExclusiveConsumer(target)) {
                 synchronized (this.consumers) {
-                    if( removeFromConsumerList(target) ) {
+                    if (removeFromConsumerList(target)) {
                         addToConsumerList(target);
                         consumers = new ArrayList&lt;Subscription&gt;(this.consumers);
                     }
@@ -1498,15 +1468,13 @@
             }
         }
 
-        
         return rc;
     }
 
-
     protected void pageInMessages(boolean force) throws Exception {
-            doDispatch(doPageIn(force));
+        doDispatch(doPageIn(force));
     }
-    
+
     private void addToConsumerList(Subscription sub) {
         if (useConsumerPriority) {
             consumers.add(sub);
@@ -1515,42 +1483,43 @@
             consumers.add(sub);
         }
     }
-    
+
     private boolean removeFromConsumerList(Subscription sub) {
         return consumers.remove(sub);
     }
-    
+
     private int getConsumerMessageCountBeforeFull() throws Exception {
         int total = 0;
         boolean zeroPrefetch = false;
         synchronized (consumers) {
             for (Subscription s : consumers) {
-            	zeroPrefetch |= s.getPrefetchSize() == 0;
-            	int countBeforeFull = s.countBeforeFull();
+                zeroPrefetch |= s.getPrefetchSize() == 0;
+                int countBeforeFull = s.countBeforeFull();
                 total += countBeforeFull;
             }
         }
-        if (total==0 &amp;&amp; zeroPrefetch){
-        	total=1;
+        if (total == 0 &amp;&amp; zeroPrefetch) {
+            total = 1;
         }
         return total;
     }
 
-    /* 
-     * In slave mode, dispatch is ignored till we get this notification as the dispatch
-     * process is non deterministic between master and slave.
-     * On a notification, the actual dispatch to the subscription (as chosen by the master) 
-     * is completed. 
-     * (non-Javadoc)
-     * @see org.apache.activemq.broker.region.BaseDestination#processDispatchNotification(org.apache.activemq.command.MessageDispatchNotification)
+    /*
+     * In slave mode, dispatch is ignored till we get this notification as the
+     * dispatch process is non deterministic between master and slave. On a
+     * notification, the actual dispatch to the subscription (as chosen by the
+     * master) is completed. (non-Javadoc)
+     * 
+     * @see
+     * org.apache.activemq.broker.region.BaseDestination#processDispatchNotification
+     * (org.apache.activemq.command.MessageDispatchNotification)
      */
-    public void processDispatchNotification(
-            MessageDispatchNotification messageDispatchNotification) throws Exception {
+    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception {
         // do dispatch
         Subscription sub = getMatchingSubscription(messageDispatchNotification);
         if (sub != null) {
             MessageReference message = getMatchingMessage(messageDispatchNotification);
-            sub.add(message);   
+            sub.add(message);
             sub.processMessageDispatchNotification(messageDispatchNotification);
         }
     }
@@ -1558,25 +1527,25 @@
     private QueueMessageReference getMatchingMessage(MessageDispatchNotification messageDispatchNotification) throws Exception {
         QueueMessageReference message = null;
         MessageId messageId = messageDispatchNotification.getMessageId();
-        
-       synchronized(dispatchMutex) {
+
+        synchronized (dispatchMutex) {
             synchronized (pagedInPendingDispatch) {
-               for(QueueMessageReference ref : pagedInPendingDispatch) {
-                   if (messageId.equals(ref.getMessageId())) {
-                       message = ref;
-                       pagedInPendingDispatch.remove(ref);
-                       break;
-                   }
-               }
+                for (QueueMessageReference ref : pagedInPendingDispatch) {
+                    if (messageId.equals(ref.getMessageId())) {
+                        message = ref;
+                        pagedInPendingDispatch.remove(ref);
+                        break;
+                    }
+                }
             }
-    
+
             if (message == null) {
                 synchronized (pagedInMessages) {
                     message = pagedInMessages.get(messageId);
                 }
             }
-            
-            if (message == null) {            
+
+            if (message == null) {
                 synchronized (messages) {
                     try {
                         messages.setMaxBatchSize(getMaxPageSize());
@@ -1595,28 +1564,25 @@
                     }
                 }
             }
-            
+
             if (message == null) {
                 Message msg = loadMessage(messageId);
                 if (msg != null) {
                     message = this.createMessageReference(msg);
                 }
-            }          
-            
-        } 
+            }
+
+        }
         if (message == null) {
-            throw new JMSException(
-                    "Slave broker out of sync with master - Message: "
-                    + messageDispatchNotification.getMessageId()
-                    + " on " + messageDispatchNotification.getDestination()
-                    + " does not exist among pending(" + pagedInPendingDispatch.size() + ") for subscription: "
-                    + messageDispatchNotification.getConsumerId());
+            throw new JMSException("Slave broker out of sync with master - Message: " + messageDispatchNotification.getMessageId() + " on " + messageDispatchNotification.getDestination()
+                    + " does not exist among pending(" + pagedInPendingDispatch.size() + ") for subscription: " + messageDispatchNotification.getConsumerId());
         }
         return message;
     }
 
     /**
      * Find a consumer that matches the id in the message dispatch notification
+     * 
      * @param messageDispatchNotification
      * @return sub or null if the subscription has been removed before dispatch
      * @throws JMSException
@@ -1639,4 +1605,20 @@
             asyncWakeup();
         }
     }
+
+    private final void waitForSpace(ConnectionContext context, Usage&lt;?&gt; usage, String warning) throws IOException, InterruptedException {
+        long start = System.currentTimeMillis();
+        long nextWarn = start + blockedProducerWarningInterval;
+        while (!usage.waitForSpace(1000)) {
+            if (context.getStopping().get()) {
+                throw new IOException("Connection closed, send aborted.");
+            }
+
+            long now = System.currentTimeMillis();
+            if (now &gt;= nextWarn) {
+                LOG.info(warning + " (blocking for: " + (now - start) / 1000 + "s)");
+                nextWarn = now + blockedProducerWarningInterval;
+            }
+        }
+    }
 }

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java (original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java Tue Dec  8 02:27:30 2009
@@ -41,6 +41,7 @@
 import org.apache.activemq.thread.TaskRunnerFactory;
 import org.apache.activemq.thread.Valve;
 import org.apache.activemq.transaction.Synchronization;
+import org.apache.activemq.usage.Usage;
 import org.apache.activemq.util.SubscriptionKey;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -59,11 +60,11 @@
  * 
  * @version $Revision: 1.21 $
  */
-public class Topic  extends BaseDestination  implements Task{
+public class Topic extends BaseDestination implements Task {
     protected static final Log LOG = LogFactory.getLog(Topic.class);
     private final TopicMessageStore topicStore;
     protected final CopyOnWriteArrayList&lt;Subscription&gt; consumers = new CopyOnWriteArrayList&lt;Subscription&gt;();
-    protected final Valve dispatchValve = new Valve(true);   
+    protected final Valve dispatchValve = new Valve(true);
     private DispatchPolicy dispatchPolicy = new SimpleDispatchPolicy();
     private SubscriptionRecoveryPolicy subscriptionRecoveryPolicy;
     private final ConcurrentHashMap&lt;SubscriptionKey, DurableTopicSubscription&gt; durableSubcribers = new ConcurrentHashMap&lt;SubscriptionKey, DurableTopicSubscription&gt;();
@@ -71,24 +72,22 @@
     private final LinkedList&lt;Runnable&gt; messagesWaitingForSpace = new LinkedList&lt;Runnable&gt;();
     private final Runnable sendMessagesWaitingForSpaceTask = new Runnable() {
         public void run() {
-                try {
-                    Topic.this.taskRunner.wakeup();
-                } catch (InterruptedException e) {
-                }
+            try {
+                Topic.this.taskRunner.wakeup();
+            } catch (InterruptedException e) {
+            }
         };
     };
-   
 
-    public Topic(BrokerService brokerService, ActiveMQDestination destination, TopicMessageStore store, DestinationStatistics parentStats,
-                 TaskRunnerFactory taskFactory) throws Exception {
+    public Topic(BrokerService brokerService, ActiveMQDestination destination, TopicMessageStore store, DestinationStatistics parentStats, TaskRunnerFactory taskFactory) throws Exception {
         super(brokerService, store, destination, parentStats);
-        this.topicStore=store;
+        this.topicStore = store;
         //set default subscription recovery policy
-        subscriptionRecoveryPolicy= new NoSubscriptionRecoveryPolicy();
+        subscriptionRecoveryPolicy = new NoSubscriptionRecoveryPolicy();
         this.taskRunner = taskFactory.createTaskRunner(this, "Topic  " + destination.getPhysicalName());
     }
-    
-    public void initialize() throws Exception{
+
+    public void initialize() throws Exception {
         super.initialize();
         if (store != null) {
             int messageCount = store.getMessageCount();
@@ -140,7 +139,7 @@
             }
         } else {
             sub.add(context, this);
-            DurableTopicSubscription dsub = (DurableTopicSubscription)sub;
+            DurableTopicSubscription dsub = (DurableTopicSubscription) sub;
             durableSubcribers.put(dsub.getSubscriptionKey(), dsub);
         }
     }
@@ -171,7 +170,7 @@
         // we are recovering a subscription to avoid out of order messages.
         dispatchValve.turnOff();
         try {
-        	
+
             if (topicStore == null) {
                 return;
             }
@@ -195,21 +194,20 @@
                 }
             }
             // Do we need to create the subscription?
-            if(info==null){
-                info=new SubscriptionInfo();
+            if (info == null) {
+                info = new SubscriptionInfo();
                 info.setClientId(clientId);
                 info.setSelector(selector);
                 info.setSubscriptionName(subscriptionName);
-                info.setDestination(getActiveMQDestination()); 
+                info.setDestination(getActiveMQDestination());
                 // This destination is an actual destination id.
-                info.setSubscribedDestination(subscription.getConsumerInfo().getDestination()); 
+                info.setSubscribedDestination(subscription.getConsumerInfo().getDestination());
                 // This destination might be a pattern
                 synchronized (consumers) {
                     consumers.add(subscription);
-                    topicStore.addSubsciption(info,subscription.getConsumerInfo().isRetroactive());
+                    topicStore.addSubsciption(info, subscription.getConsumerInfo().isRetroactive());
                 }
             }
-            
 
             final MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
             msgContext.setDestination(destination);
@@ -223,7 +221,7 @@
                                 subscription.add(message);
                             }
                         } catch (IOException e) {
-                           LOG.error("Failed to recover this message " + message);
+                            LOG.error("Failed to recover this message " + message);
                         }
                         return true;
                     }
@@ -235,7 +233,7 @@
                     public boolean hasSpace() {
                         return true;
                     }
-                    
+
                     public boolean isDuplicate(MessageId id) {
                         return false;
                     }
@@ -277,23 +275,24 @@
             return;
         }
 
-        if(memoryUsage.isFull()) {
+        if (memoryUsage.isFull()) {
             isFull(context, memoryUsage);
             fastProducer(context, producerInfo);
-            
+
             if (isProducerFlowControl() &amp;&amp; context.isProducerFlowControl()) {
-                
-                if(warnOnProducerFlowControl) {
+
+                if (warnOnProducerFlowControl) {
                     warnOnProducerFlowControl = false;
-                    LOG.info("Usage Manager memory limit reached for " +getActiveMQDestination().getQualifiedName() + ". Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it." +
-                            " See http://activemq.apache.org/producer-flow-control.html for more info");
+                    LOG.info("Usage Manager memory limit reached for " + getActiveMQDestination().getQualifiedName()
+                            + ". Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it."
+                            + " See http://activemq.apache.org/producer-flow-control.html for more info");
                 }
-                
+
                 if (systemUsage.isSendFailIfNoSpace()) {
-                    throw new javax.jms.ResourceAllocationException("Usage Manager memory limit reached. Stopping producer (" + message.getProducerId() + ") to prevent flooding " +getActiveMQDestination().getQualifiedName() + "." +
-                            " See http://activemq.apache.org/producer-flow-control.html for more info");
+                    throw new javax.jms.ResourceAllocationException("Usage Manager memory limit reached. Stopping producer (" + message.getProducerId() + ") to prevent flooding "
+                            + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
                 }
-   
+
                 // We can avoid blocking due to low usage if the producer is sending
                 // a sync message or
                 // if it is using a producer window
@@ -301,9 +300,9 @@
                     synchronized (messagesWaitingForSpace) {
                         messagesWaitingForSpace.add(new Runnable() {
                             public void run() {
-                                
+
                                 try {
-    
+
                                     // While waiting for space to free up... the
                                     // message may have expired.
                                     if (message.isExpired()) {
@@ -312,7 +311,7 @@
                                     } else {
                                         doMessageSend(producerExchange, message);
                                     }
-    
+
                                     if (sendProducerAck) {
                                         ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize());
                                         context.getConnection().dispatchAsync(ack);
@@ -321,7 +320,7 @@
                                         response.setCorrelationId(message.getCommandId());
                                         context.getConnection().dispatchAsync(response);
                                     }
-    
+
                                 } catch (Exception e) {
                                     if (!sendProducerAck &amp;&amp; !context.isInRecoveryMode()) {
                                         ExceptionResponse response = new ExceptionResponse(e);
@@ -329,10 +328,10 @@
                                         context.getConnection().dispatchAsync(response);
                                     }
                                 }
-                                
+
                             }
                         });
-    
+
                         // If the user manager is not full, then the task will not
                         // get called..
                         if (!memoryUsage.notifyCallbackWhenNotFull(sendMessagesWaitingForSpaceTask)) {
@@ -342,24 +341,32 @@
                         context.setDontSendReponse(true);
                         return;
                     }
-    
+
                 } else {
-    
                     // Producer flow control cannot be used, so we have do the flow
                     // control at the broker
                     // by blocking this thread until there is space available.
-                    int count = 0;
-                    while (!memoryUsage.waitForSpace(1000)) {
-                        if (context.getStopping().get()) {
-                            throw new IOException("Connection closed, send aborted.");
-                        }
-                        if (count &gt; 2 &amp;&amp; context.isInTransaction()) {
-                            count =0;
-                            int size = context.getTransaction().size();
-                            LOG.warn("Waiting for space to send  transacted message - transaction elements = " + size + " need more space to commit. Message = " + message);
+                    
+                    if (memoryUsage.isFull()) {
+                        if (context.isInTransaction()) {
+
+                            int count = 0;
+                            while (!memoryUsage.waitForSpace(1000)) {
+                                if (context.getStopping().get()) {
+                                    throw new IOException("Connection closed, send aborted.");
+                                }
+                                if (count &gt; 2 &amp;&amp; context.isInTransaction()) {
+                                    count = 0;
+                                    int size = context.getTransaction().size();
+                                    LOG.warn("Waiting for space to send  transacted message - transaction elements = " + size + " need more space to commit. Message = " + message);
+                                }
+                            }
+                        } else {
+                            waitForSpace(context, memoryUsage, "Usage Manager memory limit reached. Stopping producer (" + message.getProducerId() + ") to prevent flooding "
+                                    + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
                         }
                     }
-    
+
                     // The usage manager could have delayed us by the time
                     // we unblock the message could have expired..
                     if (message.isExpired()) {
@@ -382,35 +389,28 @@
     }
 
     /**
-     * do send the message - this needs to be synchronized to ensure messages are stored AND dispatched in 
-     * the right order
+     * do send the message - this needs to be synchronized to ensure messages
+     * are stored AND dispatched in the right order
+     * 
      * @param producerExchange
      * @param message
      * @throws IOException
      * @throws Exception
      */
-    synchronized void doMessageSend(
-            final ProducerBrokerExchange producerExchange, final Message message)
-            throws IOException, Exception {
-        final ConnectionContext context = producerExchange
-                .getConnectionContext();
+    synchronized void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message) throws IOException, Exception {
+        final ConnectionContext context = producerExchange.getConnectionContext();
         message.setRegionDestination(this);
         message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());
 
-        if (topicStore != null &amp;&amp; message.isPersistent()
-                &amp;&amp; !canOptimizeOutPersistence()) {
+        if (topicStore != null &amp;&amp; message.isPersistent() &amp;&amp; !canOptimizeOutPersistence()) {
             if (systemUsage.getStoreUsage().isFull()) {
-                final String logMessage = "Usage Manager Store is Full. Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." +
-                        " See http://activemq.apache.org/producer-flow-control.html for more info";
-                LOG.info(logMessage);
+                final String logMessage = "Usage Manager Store is Full. Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "."
+                        + " See http://activemq.apache.org/producer-flow-control.html for more info";
                 if (systemUsage.isSendFailIfNoSpace()) {
-            	    throw new javax.jms.ResourceAllocationException(logMessage);
-                }
-            }
-            while (!systemUsage.getStoreUsage().waitForSpace(1000)) {
-                if (context.getStopping().get()) {
-                    throw new IOException("Connection closed, send aborted.");
+                    throw new javax.jms.ResourceAllocationException(logMessage);
                 }
+
+                waitForSpace(context, systemUsage.getStoreUsage(), logMessage);
             }
             topicStore.addMessage(context, message);
         }
@@ -457,14 +457,13 @@
 
     public void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException {
         if (topicStore != null &amp;&amp; node.isPersistent()) {
-            DurableTopicSubscription dsub = (DurableTopicSubscription)sub;
+            DurableTopicSubscription dsub = (DurableTopicSubscription) sub;
             SubscriptionKey key = dsub.getSubscriptionKey();
             topicStore.acknowledge(context, key.getClientId(), key.getSubscriptionName(), node.getMessageId());
         }
         messageConsumed(context, node);
     }
 
-    
     public void gc() {
     }
 
@@ -488,7 +487,7 @@
         if (memoryUsage != null) {
             memoryUsage.stop();
         }
-        if(this.topicStore != null) {
+        if (this.topicStore != null) {
             this.topicStore.stop();
         }
     }
@@ -510,7 +509,7 @@
                     public boolean hasSpace() {
                         return true;
                     }
-                    
+
                     public boolean isDuplicate(MessageId id) {
                         return false;
                     }
@@ -527,9 +526,9 @@
         }
         return result.toArray(new Message[result.size()]);
     }
-    
+
     public boolean iterate() {
-        synchronized(messagesWaitingForSpace) {
+        synchronized (messagesWaitingForSpace) {
             while (!memoryUsage.isFull() &amp;&amp; !messagesWaitingForSpace.isEmpty()) {
                 Runnable op = messagesWaitingForSpace.removeFirst();
                 op.run();
@@ -538,12 +537,9 @@
         return false;
     }
 
-
     // Properties
     // -------------------------------------------------------------------------
 
-    
-
     public DispatchPolicy getDispatchPolicy() {
         return dispatchPolicy;
     }
@@ -560,17 +556,16 @@
         this.subscriptionRecoveryPolicy = subscriptionRecoveryPolicy;
     }
 
-    
     // Implementation methods
     // -------------------------------------------------------------------------
-    
+
     public final void wakeup() {
     }
-    
+
     protected void dispatch(final ConnectionContext context, Message message) throws Exception {
         destinationStatistics.getMessages().increment();
         destinationStatistics.getEnqueues().increment();
-        dispatchValve.increment();   
+        dispatchValve.increment();
         MessageEvaluationContext msgContext = null;
         try {
             if (!subscriptionRecoveryPolicy.add(context, message)) {
@@ -587,17 +582,17 @@
             msgContext.setMessageReference(message);
             if (!dispatchPolicy.dispatch(message, msgContext, consumers)) {
                 onMessageWithNoConsumers(context, message);
-            }  
-            
+            }
+
         } finally {
             dispatchValve.decrement();
-            if(msgContext != null) {
+            if (msgContext != null) {
                 msgContext.clear();
             }
         }
     }
-    
-    public void messageExpired(ConnectionContext context,Subscription subs, MessageReference reference) {
+
+    public void messageExpired(ConnectionContext context, Subscription subs, MessageReference reference) {
         broker.messageExpired(context, reference);
         destinationStatistics.getMessages().decrement();
         destinationStatistics.getEnqueues().decrement();
@@ -609,9 +604,24 @@
         try {
             acknowledge(context, subs, ack, reference);
         } catch (IOException e) {
-            LOG.error("Failed to remove expired Message from the store ",e);
+            LOG.error("Failed to remove expired Message from the store ", e);
         }
     }
 
+    private final void waitForSpace(ConnectionContext context, Usage&lt;?&gt; usage, String warning) throws IOException, InterruptedException {
+        long start = System.currentTimeMillis();
+        long nextWarn = start + blockedProducerWarningInterval;
+        while (!usage.waitForSpace(1000)) {
+            if (context.getStopping().get()) {
+                throw new IOException("Connection closed, send aborted.");
+            }
+
+            long now = System.currentTimeMillis();
+            if (now &gt;= nextWarn) {
+                LOG.info(warning + " (blocking for: " + (now - start) / 1000 + "s)");
+                nextWarn = now + blockedProducerWarningInterval;
+            }
+        }
+    }
 
 }

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java (original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java Tue Dec  8 02:27:30 2009
@@ -60,6 +60,7 @@
     private int maxQueueAuditDepth=2048;
     private boolean enableAudit=true;
     private boolean producerFlowControl = true;
+    private long blockedProducerWarningInterval = Destination.DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL;
     private boolean optimizedDispatch=false;
     private int maxPageSize=BaseDestination.MAX_PAGE_SIZE;
     private int maxBrowsePageSize=BaseDestination.MAX_BROWSE_PAGE_SIZE;
@@ -125,6 +126,7 @@
     
     public void baseConfiguration(BaseDestination destination) {
         destination.setProducerFlowControl(isProducerFlowControl());
+        destination.setBlockedProducerWarningInterval(getBlockedProducerWarningInterval());
         destination.setEnableAudit(isEnableAudit());
         destination.setMaxAuditDepth(getMaxQueueAuditDepth());
         destination.setMaxProducersToAudit(getMaxProducersToAudit());
@@ -373,6 +375,27 @@
     }
 
     /**
+     * Set's the interval at which warnings about producers being blocked by
+     * resource usage will be triggered. Values of 0 or less will disable
+     * warnings
+     * 
+     * @param blockedProducerWarningInterval the interval at which warning about
+     *            blocked producers will be triggered.
+     */
+    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval) {
+        this.blockedProducerWarningInterval = blockedProducerWarningInterval;
+    }
+
+    /**
+     * 
+     * @return the interval at which warning about blocked producers will be
+     *         triggered.
+     */
+    public long getBlockedProducerWarningInterval() {
+        return blockedProducerWarningInterval;
+    }
+    
+    /**
      * @return the maxProducersToAudit
      */
     public int getMaxProducersToAudit() {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888227 [1/2] - in /activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker: jmx/ region/ region/policy/</title>
<author><name>cmacnaug@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091208022731.8B10D23889C5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091208022731-8B10D23889C5@eris-apache-org%3e</id>
<updated>2009-12-08T02:27:30Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cmacnaug
Date: Tue Dec  8 02:27:30 2009
New Revision: 888227

URL: http://svn.apache.org/viewvc?rev=888227&amp;view=rev
Log:
Backport from trunk revision 883458: Adding a blockedProducerWarningInterval attribute to
destinations to control the rate at which warnings about blocked producers are generated (otherwise
the warnings can flood the log). 

Modified:
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Destination.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Topic.java
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
Tue Dec  8 02:27:30 2009
@@ -82,11 +82,11 @@
     public long getDispatchCount() {
         return destination.getDestinationStatistics().getDispatched().getCount();
     }
-    
+
     public long getInFlightCount() {
         return destination.getDestinationStatistics().getInflight().getCount();
     }
-    
+
     public long getExpiredCount() {
         return destination.getDestinationStatistics().getExpired().getCount();
     }
@@ -220,7 +220,7 @@
         OpenTypeFactory factory = OpenTypeSupport.getFactory(ActiveMQMessage.class);
         Message[] messages = destination.browse();
         CompositeType ct = factory.getCompositeType();
-        TabularType tt = new TabularType("MessageList", "MessageList", ct, new String[] {"JMSMessageID"});
+        TabularType tt = new TabularType("MessageList", "MessageList", ct, new String[] {
"JMSMessageID" });
         TabularDataSupport rc = new TabularDataSupport(tt);
 
         MessageEvaluationContext ctx = new MessageEvaluationContext();
@@ -248,16 +248,16 @@
     public String sendTextMessage(String body) throws Exception {
         return sendTextMessage(Collections.EMPTY_MAP, body);
     }
-    
+
     public String sendTextMessage(Map headers, String body) throws Exception {
-        return sendTextMessage(headers,body,null,null);
+        return sendTextMessage(headers, body, null, null);
     }
 
     public String sendTextMessage(String body, String user, String password) throws Exception
{
-        return sendTextMessage(Collections.EMPTY_MAP,body,user,password);
+        return sendTextMessage(Collections.EMPTY_MAP, body, user, password);
     }
 
-    public String sendTextMessage(Map headers, String body,String userName,String password)
throws Exception {
+    public String sendTextMessage(Map headers, String body, String userName, String password)
throws Exception {
 
         String brokerUrl = "vm://" + broker.getBrokerName();
         ActiveMQDestination dest = destination.getActiveMQDestination();
@@ -266,14 +266,14 @@
         Connection connection = null;
         try {
 
-            connection = cf.createConnection(userName,password);
+            connection = cf.createConnection(userName, password);
             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
             MessageProducer producer = session.createProducer(dest);
-            ActiveMQTextMessage msg = (ActiveMQTextMessage)session.createTextMessage(body);
+            ActiveMQTextMessage msg = (ActiveMQTextMessage) session.createTextMessage(body);
 
             for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
-                Map.Entry entry = (Map.Entry)iter.next();
-                msg.setObjectProperty((String)entry.getKey(), entry.getValue());
+                Map.Entry entry = (Map.Entry) iter.next();
+                msg.setObjectProperty((String) entry.getKey(), entry.getValue());
             }
 
             producer.setDeliveryMode(msg.getJMSDeliveryMode());
@@ -292,30 +292,28 @@
 
     public int getMaxAuditDepth() {
         return destination.getMaxAuditDepth();
-     }
+    }
+
+    public int getMaxProducersToAudit() {
+        return destination.getMaxProducersToAudit();
+    }
+
+    public boolean isEnableAudit() {
+        return destination.isEnableAudit();
+    }
+
+    public void setEnableAudit(boolean enableAudit) {
+        destination.setEnableAudit(enableAudit);
+    }
+
+    public void setMaxAuditDepth(int maxAuditDepth) {
+        destination.setMaxAuditDepth(maxAuditDepth);
+    }
 
-     public int getMaxProducersToAudit() {
-         return destination.getMaxProducersToAudit();
-     }
-
-     public boolean isEnableAudit() {
-         return destination.isEnableAudit();
-     }
-
-     
-     public void setEnableAudit(boolean enableAudit) {
-         destination.setEnableAudit(enableAudit);
-     }
-
-     public void setMaxAuditDepth(int maxAuditDepth) {
-         destination.setMaxAuditDepth(maxAuditDepth);
-     }
- 
-     public void setMaxProducersToAudit(int maxProducersToAudit) {
-         destination.setMaxProducersToAudit(maxProducersToAudit);
-     }
+    public void setMaxProducersToAudit(int maxProducersToAudit) {
+        destination.setMaxProducersToAudit(maxProducersToAudit);
+    }
 
-    
     public float getMemoryUsagePortion() {
         return destination.getMemoryUsage().getUsagePortion();
     }
@@ -325,31 +323,52 @@
     }
 
     public boolean isProducerFlowControl() {
-       return destination.isProducerFlowControl();
+        return destination.isProducerFlowControl();
     }
-    
+
     public void setMemoryUsagePortion(float value) {
         destination.getMemoryUsage().setUsagePortion(value);
     }
 
     public void setProducerFlowControl(boolean producerFlowControl) {
-      destination.setProducerFlowControl(producerFlowControl);      
+        destination.setProducerFlowControl(producerFlowControl);
+    }
+
+    /**
+     * Set's the interval at which warnings about producers being blocked by
+     * resource usage will be triggered. Values of 0 or less will disable
+     * warnings
+     * 
+     * @param blockedProducerWarningInterval the interval at which warning about
+     *            blocked producers will be triggered.
+     */
+    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval) {
+        destination.setBlockedProducerWarningInterval(blockedProducerWarningInterval);
+    }
+
+    /**
+     * 
+     * @return the interval at which warning about blocked producers will be
+     *         triggered.
+     */
+    public long getBlockedProducerWarningInterval() {
+        return destination.getBlockedProducerWarningInterval();
     }
 
     public int getMaxPageSize() {
         return destination.getMaxPageSize();
     }
-    
+
     public void setMaxPageSize(int pageSize) {
         destination.setMaxPageSize(pageSize);
     }
-    
+
     public boolean isUseCache() {
         return destination.isUseCache();
     }
 
     public void setUseCache(boolean value) {
-        destination.setUseCache(value);    
+        destination.setUseCache(value);
     }
 
     public ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException
{

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
Tue Dec  8 02:27:30 2009
@@ -248,12 +248,31 @@
      */
     @MBeanInfo("Producers are flow controlled")
     boolean isProducerFlowControl();
+    
     /**
      * @param producerFlowControl the producerFlowControl to set
      */
     public void setProducerFlowControl(@MBeanInfo("producerFlowControl") boolean producerFlowControl);
     
     /**
+     * Set's the interval at which warnings about producers being blocked by
+     * resource usage will be triggered. Values of 0 or less will disable
+     * warnings
+     * 
+     * @param blockedProducerWarningInterval the interval at which warning about
+     *            blocked producers will be triggered.
+     */
+    public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval")
 long blockedProducerWarningInterval);
+
+    /**
+     * 
+     * @return the interval at which warning about blocked producers will be
+     *         triggered.
+     */
+    @MBeanInfo("Blocked Producer Warning Interval")
+    public long getBlockedProducerWarningInterval();
+    
+    /**
      * @return the maxProducersToAudit
      */
     @MBeanInfo("Maximum number of producers to audit") 

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/BaseDestination.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
Tue Dec  8 02:27:30 2009
@@ -40,18 +40,21 @@
  */
 public abstract class BaseDestination implements Destination {
     /**
-     * The maximum number of messages to page in to the destination from persistent storage
+     * The maximum number of messages to page in to the destination from
+     * persistent storage
      */
     public static final int MAX_PAGE_SIZE = 200;
     public static final int MAX_BROWSE_PAGE_SIZE = MAX_PAGE_SIZE * 2;
-    public static final long EXPIRE_MESSAGE_PERIOD = 30*1000;
+    public static final long EXPIRE_MESSAGE_PERIOD = 30 * 1000;
     protected final ActiveMQDestination destination;
     protected final Broker broker;
     protected final MessageStore store;
     protected SystemUsage systemUsage;
     protected MemoryUsage memoryUsage;
     private boolean producerFlowControl = true;
-    protected boolean warnOnProducerFlowControl = true; 
+    protected boolean warnOnProducerFlowControl = true;
+    protected long blockedProducerWarningInterval = DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL;
+
     private int maxProducersToAudit = 1024;
     private int maxAuditDepth = 2048;
     private boolean enableAudit = true;
@@ -82,8 +85,7 @@
      * @param parentStats
      * @throws Exception
      */
-    public BaseDestination(BrokerService brokerService, MessageStore store, ActiveMQDestination
destination,
-            DestinationStatistics parentStats) throws Exception {
+    public BaseDestination(BrokerService brokerService, MessageStore store, ActiveMQDestination
destination, DestinationStatistics parentStats) throws Exception {
         this.brokerService = brokerService;
         this.broker = brokerService.getBroker();
         this.store = store;
@@ -118,14 +120,34 @@
     }
 
     /**
-     * @param producerFlowControl
-     *            the producerFlowControl to set
+     * @param producerFlowControl the producerFlowControl to set
      */
     public void setProducerFlowControl(boolean producerFlowControl) {
         this.producerFlowControl = producerFlowControl;
     }
 
     /**
+     * Set's the interval at which warnings about producers being blocked by
+     * resource usage will be triggered. Values of 0 or less will disable
+     * warnings
+     * 
+     * @param blockedProducerWarningInterval the interval at which warning about
+     *            blocked producers will be triggered.
+     */
+    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval) {
+        this.blockedProducerWarningInterval = blockedProducerWarningInterval;
+    }
+
+    /**
+     * 
+     * @return the interval at which warning about blocked producers will be
+     *         triggered.
+     */
+    public long getBlockedProducerWarningInterval() {
+        return blockedProducerWarningInterval;
+    }
+
+    /**
      * @return the maxProducersToAudit
      */
     public int getMaxProducersToAudit() {
@@ -133,8 +155,7 @@
     }
 
     /**
-     * @param maxProducersToAudit
-     *            the maxProducersToAudit to set
+     * @param maxProducersToAudit the maxProducersToAudit to set
      */
     public void setMaxProducersToAudit(int maxProducersToAudit) {
         this.maxProducersToAudit = maxProducersToAudit;
@@ -148,8 +169,7 @@
     }
 
     /**
-     * @param maxAuditDepth
-     *            the maxAuditDepth to set
+     * @param maxAuditDepth the maxAuditDepth to set
      */
     public void setMaxAuditDepth(int maxAuditDepth) {
         this.maxAuditDepth = maxAuditDepth;
@@ -163,8 +183,7 @@
     }
 
     /**
-     * @param enableAudit
-     *            the enableAudit to set
+     * @param enableAudit the enableAudit to set
      */
     public void setEnableAudit(boolean enableAudit) {
         this.enableAudit = enableAudit;
@@ -199,8 +218,7 @@
     }
 
     public final boolean isActive() {
-        return destinationStatistics.getConsumers().getCount() != 0
-                || destinationStatistics.getProducers().getCount() != 0;
+        return destinationStatistics.getConsumers().getCount() != 0 || destinationStatistics.getProducers().getCount()
!= 0;
     }
 
     public int getMaxPageSize() {
@@ -218,13 +236,13 @@
     public void setMaxBrowsePageSize(int maxPageSize) {
         this.maxBrowsePageSize = maxPageSize;
     }
-    
+
     public int getMaxExpirePageSize() {
         return this.maxExpirePageSize;
     }
 
     public void setMaxExpirePageSize(int maxPageSize) {
-        this.maxExpirePageSize  = maxPageSize;
+        this.maxExpirePageSize = maxPageSize;
     }
 
     public void setExpireMessagesPeriod(long expireMessagesPeriod) {
@@ -234,7 +252,7 @@
     public long getExpireMessagesPeriod() {
         return expireMessagesPeriod;
     }
-    
+
     public boolean isUseCache() {
         return useCache;
     }
@@ -271,8 +289,7 @@
     }
 
     /**
-     * @param advisoryForSlowConsumers
-     *            the advisoryForSlowConsumers to set
+     * @param advisoryForSlowConsumers the advisoryForSlowConsumers to set
      */
     public void setAdvisoryForSlowConsumers(boolean advisoryForSlowConsumers) {
         this.advisoryForSlowConsumers = advisoryForSlowConsumers;
@@ -286,8 +303,8 @@
     }
 
     /**
-     * @param advisoryForDiscardingMessages
-     *            the advisoryForDiscardingMessages to set
+     * @param advisoryForDiscardingMessages the advisoryForDiscardingMessages to
+     *            set
      */
     public void setAdvisoryForDiscardingMessages(boolean advisoryForDiscardingMessages) {
         this.advisoryForDiscardingMessages = advisoryForDiscardingMessages;
@@ -301,8 +318,7 @@
     }
 
     /**
-     * @param advisoryWhenFull
-     *            the advisoryWhenFull to set
+     * @param advisoryWhenFull the advisoryWhenFull to set
      */
     public void setAdvisoryWhenFull(boolean advisoryWhenFull) {
         this.advisoryWhenFull = advisoryWhenFull;
@@ -316,8 +332,7 @@
     }
 
     /**
-     * @param advisoryForDelivery
-     *            the advisoryForDelivery to set
+     * @param advisoryForDelivery the advisoryForDelivery to set
      */
     public void setAdvisoryForDelivery(boolean advisoryForDelivery) {
         this.advisoryForDelivery = advisoryForDelivery;
@@ -331,8 +346,7 @@
     }
 
     /**
-     * @param advisoryForConsumed
-     *            the advisoryForConsumed to set
+     * @param advisoryForConsumed the advisoryForConsumed to set
      */
     public void setAdvisoryForConsumed(boolean advisoryForConsumed) {
         this.advisoryForConsumed = advisoryForConsumed;
@@ -346,13 +360,12 @@
     }
 
     /**
-     * @param advisdoryForFastProducers
-     *            the advisdoryForFastProducers to set
+     * @param advisdoryForFastProducers the advisdoryForFastProducers to set
      */
     public void setAdvisdoryForFastProducers(boolean advisdoryForFastProducers) {
         this.advisdoryForFastProducers = advisdoryForFastProducers;
     }
-    
+
     public boolean isSendAdvisoryIfNoConsumers() {
         return sendAdvisoryIfNoConsumers;
     }
@@ -376,14 +389,14 @@
     public void setDeadLetterStrategy(DeadLetterStrategy deadLetterStrategy) {
         this.deadLetterStrategy = deadLetterStrategy;
     }
-    
+
     public int getCursorMemoryHighWaterMark() {
-		return this.cursorMemoryHighWaterMark;
-	}
+        return this.cursorMemoryHighWaterMark;
+    }
 
-	public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
-		this.cursorMemoryHighWaterMark = cursorMemoryHighWaterMark;
-	}
+    public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
+        this.cursorMemoryHighWaterMark = cursorMemoryHighWaterMark;
+    }
 
     /**
      * called when message is consumed
@@ -410,8 +423,8 @@
     }
 
     /**
-     * Called when a message is discarded - e.g. running low on memory This will happen only
if the policy is enabled -
-     * e.g. non durable topics
+     * Called when a message is discarded - e.g. running low on memory This will
+     * happen only if the policy is enabled - e.g. non durable topics
      * 
      * @param context
      * @param messageReference
@@ -460,19 +473,19 @@
 
     public void dispose(ConnectionContext context) throws IOException {
         if (this.store != null) {
-        	this.store.removeAllMessages(context);
+            this.store.removeAllMessages(context);
             this.store.dispose(context);
         }
         this.destinationStatistics.setParent(null);
         this.memoryUsage.stop();
     }
-    
+
     /**
      * Provides a hook to allow messages with no consumer to be processed in
      * some way - such as to send to a dead letter queue or something..
      */
     protected void onMessageWithNoConsumers(ConnectionContext context, Message msg) throws
Exception {
-    	if (!msg.isPersistent()) {
+        if (!msg.isPersistent()) {
             if (isSendAdvisoryIfNoConsumers()) {
                 // allow messages with no consumers to be dispatched to a dead
                 // letter queue
@@ -489,12 +502,12 @@
                     if (message.getOriginalTransactionId() != null) {
                         message.setOriginalTransactionId(message.getTransactionId());
                     }
-                    
+
                     ActiveMQTopic advisoryTopic;
                     if (destination.isQueue()) {
-                    	advisoryTopic = AdvisorySupport.getNoQueueConsumersAdvisoryTopic(destination);
+                        advisoryTopic = AdvisorySupport.getNoQueueConsumersAdvisoryTopic(destination);
                     } else {
-                    	advisoryTopic = AdvisorySupport.getNoTopicConsumersAdvisoryTopic(destination);
+                        advisoryTopic = AdvisorySupport.getNoTopicConsumersAdvisoryTopic(destination);
                     }
                     message.setDestination(advisoryTopic);
                     message.setTransactionId(null);
@@ -517,8 +530,9 @@
             }
         }
     }
-    
-    public void processDispatchNotification(
-            MessageDispatchNotification messageDispatchNotification) throws Exception {
+
+    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception {
     }
+    
+    
 }

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Destination.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Destination.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Destination.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Destination.java
Tue Dec  8 02:27:30 2009
@@ -41,10 +41,12 @@
 public interface Destination extends Service, Task {
 
     public static final DeadLetterStrategy DEFAULT_DEAD_LETTER_STRATEGY = new SharedDeadLetterStrategy();
+    public static final long DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL = 30000;
+
     void addSubscription(ConnectionContext context, Subscription sub) throws Exception;
 
     void removeSubscription(ConnectionContext context, Subscription sub, long lastDeliveredSequenceId)
throws Exception;
-    
+
     void addProducer(ConnectionContext context, ProducerInfo info) throws Exception;
 
     void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception;
@@ -70,122 +72,146 @@
     String getName();
 
     MessageStore getMessageStore();
-    
+
     boolean isProducerFlowControl();
-    
+
     void setProducerFlowControl(boolean value);
-    
+
+    /**
+     * Set's the interval at which warnings about producers being blocked by
+     * resource usage will be triggered. Values of 0 or less will disable
+     * warnings
+     * 
+     * @param blockedProducerWarningInterval the interval at which warning about
+     *            blocked producers will be triggered.
+     */
+    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval);
+
+    /**
+     * 
+     * @return the interval at which warning about blocked producers will be
+     *         triggered.
+     */
+    public long getBlockedProducerWarningInterval();
+
     int getMaxProducersToAudit();
-    
+
     void setMaxProducersToAudit(int maxProducersToAudit);
-   
+
     int getMaxAuditDepth();
-   
+
     void setMaxAuditDepth(int maxAuditDepth);
-  
+
     boolean isEnableAudit();
-    
+
     void setEnableAudit(boolean enableAudit);
-    
-    boolean isActive();   
-    
+
+    boolean isActive();
+
     int getMaxPageSize();
-    
+
     public void setMaxPageSize(int maxPageSize);
-    
+
     public int getMaxBrowsePageSize();
 
     public void setMaxBrowsePageSize(int maxPageSize);
-    
+
     public boolean isUseCache();
-    
+
     public void setUseCache(boolean useCache);
-    
+
     public int getMinimumMessageSize();
 
     public void setMinimumMessageSize(int minimumMessageSize);
-    
+
     public int getCursorMemoryHighWaterMark();
 
-	public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark);
-    
+    public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark);
+
     /**
-     * optionally called by a Subscriber - to inform the Destination its
-     * ready for more messages
+     * optionally called by a Subscriber - to inform the Destination its ready
+     * for more messages
      */
     public void wakeup();
-    
+
     /**
      * @return true if lazyDispatch is enabled
      */
     public boolean isLazyDispatch();
-    
-    
+
     /**
      * set the lazy dispatch - default is false
+     * 
      * @param value
      */
     public void setLazyDispatch(boolean value);
 
-        
     /**
      * Inform the Destination a message has expired
+     * 
      * @param context
-     * @param subs 
+     * @param subs
      * @param node
      */
-    void messageExpired(ConnectionContext context, Subscription subs,MessageReference node);
+    void messageExpired(ConnectionContext context, Subscription subs, MessageReference node);
 
     /**
      * called when message is consumed
+     * 
      * @param context
      * @param messageReference
      */
-     void messageConsumed(ConnectionContext context, MessageReference messageReference);
-    
+    void messageConsumed(ConnectionContext context, MessageReference messageReference);
+
     /**
      * Called when message is delivered to the broker
+     * 
      * @param context
      * @param messageReference
      */
-     void messageDelivered(ConnectionContext context, MessageReference messageReference);
-    
+    void messageDelivered(ConnectionContext context, MessageReference messageReference);
+
     /**
-     * Called when a message is discarded - e.g. running low on memory
-     * This will happen only if the policy is enabled - e.g. non durable topics
+     * Called when a message is discarded - e.g. running low on memory This will
+     * happen only if the policy is enabled - e.g. non durable topics
+     * 
      * @param context
      * @param messageReference
      */
-     void messageDiscarded(ConnectionContext context, MessageReference messageReference);
-    
+    void messageDiscarded(ConnectionContext context, MessageReference messageReference);
+
     /**
      * Called when there is a slow consumer
+     * 
      * @param context
      * @param subs
      */
-     void slowConsumer(ConnectionContext context, Subscription subs);
-    
+    void slowConsumer(ConnectionContext context, Subscription subs);
+
     /**
      * Called to notify a producer is too fast
+     * 
      * @param context
      * @param producerInfo
      */
-     void fastProducer(ConnectionContext context,ProducerInfo producerInfo);
-    
+    void fastProducer(ConnectionContext context, ProducerInfo producerInfo);
+
     /**
      * Called when a Usage reaches a limit
+     * 
      * @param context
      * @param usage
      */
-     void isFull(ConnectionContext context,Usage usage);
+    void isFull(ConnectionContext context, Usage usage);
 
     List&lt;Subscription&gt; getConsumers();
 
     /**
-     * called on Queues in slave mode to allow dispatch to follow subscription choice of
master
+     * called on Queues in slave mode to allow dispatch to follow subscription
+     * choice of master
+     * 
      * @param messageDispatchNotification
      * @throws Exception
      */
-    void processDispatchNotification(
-            MessageDispatchNotification messageDispatchNotification) throws Exception;
+    void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception;
 }

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java?rev=888227&amp;r1=888226&amp;r2=888227&amp;view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
Tue Dec  8 02:27:30 2009
@@ -45,8 +45,7 @@
         this.next = next;
     }
 
-    public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack,
MessageReference node)
-        throws IOException {
+    public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack,
MessageReference node) throws IOException {
         next.acknowledge(context, sub, ack, node);
     }
 
@@ -108,13 +107,13 @@
 
     /**
      * Sends a message to the given destination which may be a wildcard
+     * 
      * @param context broker context
      * @param message message to send
      * @param destination possibly wildcard destination to send the message to
      * @throws Exception on error
      */
-    protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination
destination)
-        throws Exception {
+    protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination
destination) throws Exception {
         Broker broker = context.getConnectionContext().getBroker();
         Set&lt;Destination&gt; destinations = broker.getDestinations(destination);
 
@@ -130,24 +129,30 @@
     public boolean isProducerFlowControl() {
         return next.isProducerFlowControl();
     }
-    
-    public void setProducerFlowControl(boolean value){
+
+    public void setProducerFlowControl(boolean value) {
         next.setProducerFlowControl(value);
     }
 
-    public void addProducer(ConnectionContext context, ProducerInfo info)
-            throws Exception {
+    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval) {
+        next.setBlockedProducerWarningInterval(blockedProducerWarningInterval);
+    }
+    
+    public long getBlockedProducerWarningInterval() {
+        return next.getBlockedProducerWarningInterval();
+    }
+
+    public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
         next.addProducer(context, info);
-        
+
     }
 
-    public void removeProducer(ConnectionContext context, ProducerInfo info)
-            throws Exception {
-       next.removeProducer(context, info);
+    public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
+        next.removeProducer(context, info);
     }
 
     public int getMaxAuditDepth() {
-       return next.getMaxAuditDepth();
+        return next.getMaxAuditDepth();
     }
 
     public int getMaxProducersToAudit() {
@@ -157,20 +162,19 @@
     public boolean isEnableAudit() {
         return next.isEnableAudit();
     }
-    
+
     public void setEnableAudit(boolean enableAudit) {
         next.setEnableAudit(enableAudit);
     }
 
     public void setMaxAuditDepth(int maxAuditDepth) {
-       next.setMaxAuditDepth(maxAuditDepth);
+        next.setMaxAuditDepth(maxAuditDepth);
     }
 
-    
     public void setMaxProducersToAudit(int maxProducersToAudit) {
-       next.setMaxProducersToAudit(maxProducersToAudit);
+        next.setMaxProducersToAudit(maxProducersToAudit);
     }
-    
+
     public boolean isActive() {
         return next.isActive();
     }
@@ -189,88 +193,81 @@
 
     public void setUseCache(boolean useCache) {
         next.setUseCache(useCache);
-    }   
-    
+    }
+
     public int getMinimumMessageSize() {
         return next.getMinimumMessageSize();
     }
 
     public void setMinimumMessageSize(int minimumMessageSize) {
         next.setMinimumMessageSize(minimumMessageSize);
-    }   
-    
+    }
+
     public void wakeup() {
         next.wakeup();
     }
 
     public boolean isLazyDispatch() {
-       return next.isLazyDispatch();
+        return next.isLazyDispatch();
     }
 
     public void setLazyDispatch(boolean value) {
-      next.setLazyDispatch(value);        
+        next.setLazyDispatch(value);
     }
 
     public void messageExpired(ConnectionContext context, PrefetchSubscription prefetchSubscription,
MessageReference node) {
-        next.messageExpired(context, prefetchSubscription, node);        
+        next.messageExpired(context, prefetchSubscription, node);
     }
 
-	public boolean iterate() {
-		return next.iterate();
-	}
+    public boolean iterate() {
+        return next.iterate();
+    }
 
-    public void fastProducer(ConnectionContext context,ProducerInfo producerInfo) {
-       next.fastProducer(context, producerInfo);       
+    public void fastProducer(ConnectionContext context, ProducerInfo producerInfo) {
+        next.fastProducer(context, producerInfo);
     }
 
-   
     public void isFull(ConnectionContext context, Usage usage) {
-       next.isFull(context, usage);
+        next.isFull(context, usage);
     }
 
-   
-    public void messageConsumed(ConnectionContext context,MessageReference messageReference)
{
+    public void messageConsumed(ConnectionContext context, MessageReference messageReference)
{
         next.messageConsumed(context, messageReference);
     }
 
-    
-    public void messageDelivered(ConnectionContext context,MessageReference messageReference)
{
+    public void messageDelivered(ConnectionContext context, MessageReference messageReference)
{
         next.messageDelivered(context, messageReference);
     }
 
-    
-    public void messageDiscarded(ConnectionContext context,MessageReference messageReference)
{
+    public void messageDiscarded(ConnectionContext context, MessageReference messageReference)
{
         next.messageDiscarded(context, messageReference);
     }
 
-    
     public void slowConsumer(ConnectionContext context, Subscription subs) {
-       next.slowConsumer(context, subs);
+        next.slowConsumer(context, subs);
     }
 
-   
-    public void messageExpired(ConnectionContext context, Subscription subs,MessageReference
node) {
-       next.messageExpired(context,subs, node);    
+    public void messageExpired(ConnectionContext context, Subscription subs, MessageReference
node) {
+        next.messageExpired(context, subs, node);
     }
 
     public int getMaxBrowsePageSize() {
-       return next.getMaxBrowsePageSize();
+        return next.getMaxBrowsePageSize();
     }
 
     public void setMaxBrowsePageSize(int maxPageSize) {
         next.setMaxBrowsePageSize(maxPageSize);
     }
 
-    public void processDispatchNotification(
-            MessageDispatchNotification messageDispatchNotification) throws Exception {
-        next.processDispatchNotification(messageDispatchNotification);   
+    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception {
+        next.processDispatchNotification(messageDispatchNotification);
     }
 
-	public int getCursorMemoryHighWaterMark() {
-		return next.getCursorMemoryHighWaterMark();
-	}
-
-	public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
-		next.setCursorMemoryHighWaterMark(cursorMemoryHighWaterMark);
-	}
+    public int getCursorMemoryHighWaterMark() {
+        return next.getCursorMemoryHighWaterMark();
+    }
+
+    public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
+        next.setCursorMemoryHighWaterMark(cursorMemoryHighWaterMark);
+    }
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888205 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/Marshalers/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091208004717.BBB2C23888C2@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091208004717-BBB2C23888C2@eris-apache-org%3e</id>
<updated>2009-12-08T00:47:17Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Tue Dec  8 00:47:17 2009
New Revision: 888205

URL: http://svn.apache.org/viewvc?rev=888205&amp;view=rev
Log:
Create a folder to use to break out the various Stomp Command Marshalers : Undo

Removed:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/Marshalers/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888181 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol: Marshalers/ marshalers/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207231928.1F049238898B@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207231928-1F049238898B@eris-apache-org%3e</id>
<updated>2009-12-07T23:19:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 23:19:27 2009
New Revision: 888181

URL: http://svn.apache.org/viewvc?rev=888181&amp;view=rev
Log:
Create a folder to use to break out the various Stomp Command Marshalers.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/Marshalers/
      - copied from r888180, activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/marshalers/
Removed:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/marshalers/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888180 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/marshalers/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207231858.E4A58238898A@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207231858-E4A58238898A@eris-apache-org%3e</id>
<updated>2009-12-07T23:18:58Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 23:18:58 2009
New Revision: 888180

URL: http://svn.apache.org/viewvc?rev=888180&amp;view=rev
Log:
Create a folder to use to break out the various Stomp Command Marshalers.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/marshalers/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888168 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp: Commands/ConsumerInfo.cs Protocol/StompFrameStream.cs Protocol/StompWireFormat.cs</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207224905.4F2CB23888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207224905-4F2CB23888DC@eris-apache-org%3e</id>
<updated>2009-12-07T22:49:05Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 22:49:04 2009
New Revision: 888168

URL: http://svn.apache.org/viewvc?rev=888168&amp;view=rev
Log:
Change some things around since this code is now a dedicated Stomp client, remove anything
that was OpenWire related.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompFrameStream.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerInfo.cs?rev=888168&amp;r1=888167&amp;r2=888168&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerInfo.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerInfo.cs
Mon Dec  7 22:49:04 2009
@@ -18,6 +18,8 @@
 using System;
 using System.Collections;
 
+using Apache.NMS;
+
 namespace Apache.NMS.Stomp.Commands
 {
     public class ConsumerInfo : BaseCommand
@@ -25,8 +27,8 @@
         public const byte ID_CONSUMERINFO = 5;
 
         ConsumerId consumerId;
-        bool browser;
         Destination destination;
+        AcknowledgementMode ackMode;
         int prefetchSize;
         int maximumPendingMessageLimit;
         bool dispatchAsync;
@@ -58,8 +60,8 @@
         {
             return GetType().Name + "[" +
                 "ConsumerId=" + ConsumerId +
-                "Browser=" + Browser +
                 "Destination=" + Destination +
+                "Ack Mode=" + AckMode +
                 "PrefetchSize=" + PrefetchSize +
                 "MaximumPendingMessageLimit=" + MaximumPendingMessageLimit +
                 "DispatchAsync=" + DispatchAsync +
@@ -78,18 +80,18 @@
             set { this.consumerId = value; }
         }
 
-        public bool Browser
-        {
-            get { return browser; }
-            set { this.browser = value; }
-        }
-
         public Destination Destination
         {
             get { return destination; }
             set { this.destination = value; }
         }
 
+        public AcknowledgementMode AckMode
+        {
+            get { return this.ackMode; }
+            set { this.ackMode = value; }
+        }
+
         public int PrefetchSize
         {
             get { return prefetchSize; }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompFrameStream.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompFrameStream.cs?rev=888168&amp;r1=888167&amp;r2=888168&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompFrameStream.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompFrameStream.cs
Mon Dec  7 22:49:04 2009
@@ -89,7 +89,7 @@
 
         public void WriteHeader(String name, Object value)
         {
-            if (value != null)
+            if(value != null)
             {
                 builder.Append(name);
                 builder.Append(SEPARATOR);
@@ -100,7 +100,7 @@
 
         public void WriteHeader(String name, bool value)
         {
-            if (value)
+            if(value)
             {
                 builder.Append(name);
                 builder.Append(SEPARATOR);

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=888168&amp;r1=888167&amp;r2=888168&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
Mon Dec  7 22:49:04 2009
@@ -37,12 +37,14 @@
         {
         }
 
-        public ITransport Transport {
+        public ITransport Transport 
+        {
             get { return transport; }
             set { transport = value; }
         }
 
-        public int Version {
+        public int Version 
+        {
             get { return 1; }
         }
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888090 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207191100.046AC23888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207191100-046AC23888DD@eris-apache-org%3e</id>
<updated>2009-12-07T19:10:59Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 19:10:58 2009
New Revision: 888090

URL: http://svn.apache.org/viewvc?rev=888090&amp;view=rev
Log:
Adds more files to the svn:ignore property.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/   (props changed)

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Dec  7 19:10:58 2009
@@ -7,3 +7,5 @@
 package
 bin
 vs2008-stomp.pidb
+vs2008-stomp.userprefs
+vs2008-stomp-test.pidb




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r888089 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/ src/main/csharp/Commands/ src/main/csharp/Transport/Tcp/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207190959.513D723888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207190959-513D723888DD@eris-apache-org%3e</id>
<updated>2009-12-07T19:09:57Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 19:09:55 2009
New Revision: 888089

URL: http://svn.apache.org/viewvc?rev=888089&amp;view=rev
Log:
Fixing some compiler errors and bringing in more NMS Implementation for Stomp, basic structure
is in place now, code compiles now.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs   (with
props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
  (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs?rev=888089&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs Mon
Dec  7 19:09:55 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System.Text;
+using Apache.NMS;
+using Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp
+{
+
+    /// &lt;summary&gt;
+    /// Exception thrown when the broker returns an error
+    /// &lt;/summary&gt;
+    public class BrokerException : NMSException
+    {
+        private BrokerError brokerError;
+
+        /// &lt;summary&gt;
+        /// Generates a nice textual stack trace
+        /// &lt;/summary&gt;
+        public static string StackTraceDump(StackTraceElement[] elements)
+        {
+            StringBuilder builder = new StringBuilder();
+            if (elements != null)
+            {
+                foreach (StackTraceElement e in elements)
+                {
+                    builder.Append("\n " + e.ClassName + "." + e.MethodName + "(" + e.FileName
+ ":" + e.LineNumber + ")");
+                }
+            }
+            return builder.ToString();
+        }
+
+        public BrokerException() : base("Broker failed with missing exception log")
+        {
+        }
+
+        public BrokerException(BrokerError brokerError) : base(
+            brokerError.ExceptionClass + " : " + brokerError.Message + "\n" + StackTraceDump(brokerError.StackTraceElements))
+        {
+            this.brokerError = brokerError;
+        }
+
+        public BrokerError BrokerError
+        {
+            get {
+                return brokerError;
+            }
+        }
+
+        public virtual string JavaStackTrace
+        {
+            get {
+                return brokerError.StackTrace;
+            }
+        }
+
+    }
+}
+
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/BrokerException.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs?rev=888089&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs
Mon Dec  7 19:09:55 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+
+namespace Apache.NMS.Stomp.Commands
+{
+    public class ConnectionError : BaseCommand
+    {
+        BrokerError exception;
+        ConnectionId connectionId;
+
+        ///
+        /// &lt;summery&gt;
+        ///  Get the unique identifier that this object and its own
+        ///  Marshaler share.
+        /// &lt;/summery&gt;
+        ///
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.ErrorType;
+        }
+
+        ///
+        /// &lt;summery&gt;
+        ///  Returns a string containing the information for this DataStructure
+        ///  such as its type and value of its elements.
+        /// &lt;/summery&gt;
+        ///
+        public override string ToString()
+        {
+            return GetType().Name + "[" + 
+                "Exception=" + Exception + 
+                "ConnectionId=" + ConnectionId + 
+                "]";
+        }
+
+        public BrokerError Exception
+        {
+            get { return exception; }
+            set { this.exception = value; }
+        }
+
+        public ConnectionId ConnectionId
+        {
+            get { return connectionId; }
+            set { this.connectionId = value; }
+        }
+
+        ///
+        /// &lt;summery&gt;
+        ///  Return an answer of true to the isConnectionError() query.
+        /// &lt;/summery&gt;
+        ///
+        public override bool IsConnectionError
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+    };
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionError.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
Mon Dec  7 19:09:55 2009
@@ -47,7 +47,8 @@
         public const byte ShutdownInfoType = 23;
         public const byte ResponseType = 24;
         public const byte RemoveInfoType = 25;
-        public const byte ErrorResponseType = 26;
+        public const byte RemoveSubscriptionInfoType = 26;
+        public const byte ErrorResponseType = 27;
         
         public const byte DestinationType = 48;
         public const byte TempDestinationType = 49;

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs?rev=888089&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs
Mon Dec  7 19:09:55 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+
+namespace Apache.NMS.Stomp.Commands
+{
+    /*
+     *
+     *  Command code for OpenWire format for RemoveSubscriptionInfo
+     *
+     *  NOTE!: This file is auto generated - do not modify!
+     *         if you need to make a change, please see the Java Classes
+     *         in the nms-activemq-openwire-generator module
+     *
+     */
+    public class RemoveSubscriptionInfo : BaseCommand
+    {
+        ConnectionId connectionId;
+        string subscriptionName;
+        string clientId;
+
+        ///
+        /// &lt;summery&gt;
+        ///  Get the unique identifier that this object and its own
+        ///  Marshaler share.
+        /// &lt;/summery&gt;
+        ///
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.RemoveSubscriptionInfoType;
+        }
+
+        ///
+        /// &lt;summery&gt;
+        ///  Returns a string containing the information for this DataStructure
+        ///  such as its type and value of its elements.
+        /// &lt;/summery&gt;
+        ///
+        public override string ToString()
+        {
+            return GetType().Name + "[" + 
+                "ConnectionId=" + ConnectionId + 
+                "SubscriptionName=" + SubscriptionName + 
+                "ClientId=" + ClientId + 
+                "]";
+        }
+
+        public ConnectionId ConnectionId
+        {
+            get { return connectionId; }
+            set { this.connectionId = value; }
+        }
+
+        public string SubscriptionName
+        {
+            get { return subscriptionName; }
+            set { this.subscriptionName = value; }
+        }
+
+        public string ClientId
+        {
+            get { return clientId; }
+            set { this.clientId = value; }
+        }
+
+        ///
+        /// &lt;summery&gt;
+        ///  Return an answer of true to the isRemoveSubscriptionInfo() query.
+        /// &lt;/summery&gt;
+        ///
+        public override bool IsRemoveSubscriptionInfo
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+    };
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveSubscriptionInfo.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs?rev=888089&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
Mon Dec  7 19:09:55 2009
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using Apache.NMS;
+
+namespace Apache.NMS.Stomp
+{
+    /// &lt;summary&gt;
+    /// Exception thrown when a connection is used that it already closed
+    /// &lt;/summary&gt;
+    public class ConnectionClosedException : NMSException
+    {
+        public ConnectionClosedException() : base("The connection is already closed!")
+        {
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ConnectionClosedException.cs
------------------------------------------------------------------------------
    svn:executable = *

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs Mon
Dec  7 19:09:55 2009
@@ -153,7 +153,6 @@
             CheckClosed();
             CheckMessageListener();
 
-            SendPullRequest(0);
             MessageDispatch dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
 
             if(dispatch == null)
@@ -164,7 +163,7 @@
             BeforeMessageIsConsumed(dispatch);
             AfterMessageIsConsumed(dispatch, false);
 
-            return CreateActiveMQMessage(dispatch);
+            return CreateStompMessage(dispatch);
         }
 
         public IMessage Receive(TimeSpan timeout)
@@ -172,17 +171,7 @@
             CheckClosed();
             CheckMessageListener();
 
-            MessageDispatch dispatch = null;
-            SendPullRequest((long) timeout.TotalMilliseconds);
-
-            if(this.PrefetchSize == 0)
-            {
-                dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
-            }
-            else
-            {
-                dispatch = this.Dequeue(timeout);
-            }
+            MessageDispatch dispatch = this.Dequeue(timeout);
 
             if(dispatch == null)
             {
@@ -192,7 +181,7 @@
             BeforeMessageIsConsumed(dispatch);
             AfterMessageIsConsumed(dispatch, false);
 
-            return CreateActiveMQMessage(dispatch);
+            return CreateStompMessage(dispatch);
         }
 
         public IMessage ReceiveNoWait()
@@ -200,17 +189,7 @@
             CheckClosed();
             CheckMessageListener();
 
-            MessageDispatch dispatch = null;
-            SendPullRequest(-1);
-
-            if(this.PrefetchSize == 0)
-            {
-                dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
-            }
-            else
-            {
-                dispatch = this.Dequeue(TimeSpan.Zero);
-            }
+            MessageDispatch dispatch = this.Dequeue(TimeSpan.Zero);
 
             if(dispatch == null)
             {
@@ -220,7 +199,7 @@
             BeforeMessageIsConsumed(dispatch);
             AfterMessageIsConsumed(dispatch, false);
 
-            return CreateActiveMQMessage(dispatch);
+            return CreateStompMessage(dispatch);
         }
 
         public void Dispose()
@@ -309,25 +288,6 @@
 
         #endregion
 
-        protected void SendPullRequest(long timeout)
-        {
-            if(this.info.PrefetchSize == 0 &amp;&amp; this.unconsumedMessages.Empty)
-            {
-                MessagePull messagePull = new MessagePull();
-                messagePull.ConsumerId = this.info.ConsumerId;
-                messagePull.Destination = this.info.Destination;
-                messagePull.Timeout = timeout;
-                messagePull.ResponseRequired = false;
-
-                if(Tracer.IsDebugEnabled)
-                {
-                    Tracer.Debug("Sending MessagePull: " + messagePull);
-                }
-
-                session.Connection.Oneway(messagePull);
-            }
-        }
-
         protected void DoIndividualAcknowledge(Message message)
         {
             MessageDispatch dispatch = null;
@@ -482,7 +442,7 @@
                     {
                         if(listener != null &amp;&amp; this.unconsumedMessages.Running)
                         {
-                            ActiveMQMessage message = CreateActiveMQMessage(dispatch);
+                            Message message = CreateStompMessage(dispatch);
 
                             this.BeforeMessageIsConsumed(dispatch);
 

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs Mon
Dec  7 19:09:55 2009
@@ -119,11 +119,6 @@
                     Tracer.ErrorFormat("Error during producer close: {0}", ex);
                 }
 
-                if(this.usage != null)
-                {
-                    this.usage.Stop();
-                }
-
                 closed = true;
             }
         }
@@ -193,7 +188,7 @@
                     throw new ConnectionClosedException();
                 }
 
-                session.DoSend(stompMessage, this, this.usage, this.RequestTimeout);
+                session.DoSend(stompMessage, this, this.RequestTimeout);
             }
         }
 

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs Mon Dec  7
19:09:55 2009
@@ -462,7 +462,7 @@
             RemoveSubscriptionInfo command = new RemoveSubscriptionInfo();
             command.ConnectionId = Connection.ConnectionId;
             command.ClientId = Connection.ClientId;
-            command.SubcriptionName = name;
+            command.SubscriptionName = name;
             this.connection.SyncRequest(command);
         }
 
@@ -478,25 +478,23 @@
 
         public IQueue GetQueue(string name)
         {
-            return new ActiveMQQueue(name);
+            return new Commands.Queue(name);
         }
 
         public ITopic GetTopic(string name)
         {
-            return new ActiveMQTopic(name);
+            return new Commands.Topic(name);
         }
 
         public ITemporaryQueue CreateTemporaryQueue()
         {
-            ActiveMQTempQueue answer = new ActiveMQTempQueue(Connection.CreateTemporaryDestinationName());
-            CreateTemporaryDestination(answer);
+            TempQueue answer = new TempQueue(Connection.CreateTemporaryDestinationName());
             return answer;
         }
 
         public ITemporaryTopic CreateTemporaryTopic()
         {
-            ActiveMQTempTopic answer = new ActiveMQTempTopic(Connection.CreateTemporaryDestinationName());
-            CreateTemporaryDestination(answer);
+            TempTopic answer = new TempTopic(Connection.CreateTemporaryDestinationName());
             return answer;
         }
 
@@ -505,12 +503,7 @@
         /// &lt;/summary&gt;
         public void DeleteDestination(IDestination destination)
         {
-            DestinationInfo command = new DestinationInfo();
-            command.ConnectionId = Connection.ConnectionId;
-            command.OperationType = DestinationInfo.REMOVE_OPERATION_TYPE; // 1 is remove
-            command.Destination = (Destination) destination;
-
-            this.connection.Oneway(command);
+            // Not Possible with Stomp
         }
 
         public IMessage CreateMessage()
@@ -521,24 +514,24 @@
 
         public ITextMessage CreateTextMessage()
         {
-            ActiveMQTextMessage answer = new ActiveMQTextMessage();
+            TextMessage answer = new TextMessage();
             return ConfigureMessage(answer) as ITextMessage;
         }
 
         public ITextMessage CreateTextMessage(string text)
         {
-            ActiveMQTextMessage answer = new ActiveMQTextMessage(text);
+            TextMessage answer = new TextMessage(text);
             return ConfigureMessage(answer) as ITextMessage;
         }
 
         public IMapMessage CreateMapMessage()
         {
-            return ConfigureMessage(new ActiveMQMapMessage()) as IMapMessage;
+            return ConfigureMessage(new MapMessage()) as IMapMessage;
         }
 
         public IBytesMessage CreateBytesMessage()
         {
-            return ConfigureMessage(new ActiveMQBytesMessage()) as IBytesMessage;
+            return ConfigureMessage(new BytesMessage()) as IBytesMessage;
         }
 
         public IBytesMessage CreateBytesMessage(byte[] body)
@@ -550,12 +543,12 @@
 
         public IStreamMessage CreateStreamMessage()
         {
-            return ConfigureMessage(new ActiveMQStreamMessage()) as IStreamMessage;
+            return ConfigureMessage(new StreamMessage()) as IStreamMessage;
         }
 
         public IObjectMessage CreateObjectMessage(object body)
         {
-            throw NotSupportedException("No Object Message in Stomp");
+            throw new NotSupportedException("No Object Message in Stomp");
         }
 
         public void Commit()
@@ -584,16 +577,6 @@
 
         #endregion
 
-        protected void CreateTemporaryDestination(Destination tempDestination)
-        {
-            DestinationInfo command = new DestinationInfo();
-            command.ConnectionId = Connection.ConnectionId;
-            command.OperationType = DestinationInfo.ADD_OPERATION_TYPE; // 0 is add
-            command.Destination = tempDestination;
-
-            this.connection.SyncRequest(command);
-        }
-
         public void DoSend( Message message, MessageProducer producer, TimeSpan sendTimeout
)
         {
             Message msg = message;
@@ -605,7 +588,6 @@
             }
 
             msg.RedeliveryCounter = 0;
-            msg.BrokerPath = null;
 
             if(this.connection.CopyMessageOnSend)
             {

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
Mon Dec  7 19:09:55 2009
@@ -110,7 +110,7 @@
             TransactionInfo info = new TransactionInfo();
             info.ConnectionId = this.session.Connection.ConnectionId;
             info.TransactionId = transactionId;
-            info.Type = (int) TransactionType.CommitOnePhase;
+            info.Type = (int) TransactionType.Commit;
 
             this.transactionId = null;
             this.session.Connection.SyncRequest(info);

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
Mon Dec  7 19:09:55 2009
@@ -20,6 +20,7 @@
 using System.Net;
 using System.Net.Sockets;
 using Apache.NMS.Stomp.Transport;
+using Apache.NMS.Stomp.Protocol;
 using Apache.NMS.Util;
 
 namespace Apache.NMS.Stomp.Transport.Tcp
@@ -133,11 +134,6 @@
                 transport = new LoggingTransport(transport);
             }
 
-            if(wireformat is OpenWireFormat)
-            {
-                transport = new WireFormatNegotiator(transport, (OpenWireFormat) wireformat);
-            }
-
             transport.RequestTimeout = this.requestTimeout;
 
             if(setTransport != null)

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj?rev=888089&amp;r1=888088&amp;r2=888089&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Mon Dec  7 19:09:55
2009
@@ -104,8 +104,11 @@
     &lt;Compile Include="src\main\csharp\Threads\DedicatedTaskRunner.cs" /&gt;
     &lt;Compile Include="src\main\csharp\Threads\Task.cs" /&gt;
     &lt;Compile Include="src\main\csharp\Threads\TaskRunner.cs" /&gt;
-    &lt;Compile Include="src\main\csharp\Threads\TaskRunnerFactory.cs" /&gt;
     &lt;Compile Include="src\main\csharp\Commands\DataStructureTypes.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\BrokerException.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\ConnectionClosedException.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Commands\ConnectionError.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Commands\RemoveSubscriptionInfo.cs" /&gt;
   &lt;/ItemGroup&gt;
   &lt;ItemGroup&gt;
     &lt;None Include="keyfile\NMSKey.snk" /&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887989 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207162905.5AFDC238898A@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207162905-5AFDC238898A@eris-apache-org%3e</id>
<updated>2009-12-07T16:29:05Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 16:29:03 2009
New Revision: 887989

URL: http://svn.apache.org/viewvc?rev=887989&amp;view=rev
Log:
Remove TaskRunnerFactory class is not needed here.

Removed:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887985 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207162744.CD25623889B8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207162744-CD25623889B8@eris-apache-org%3e</id>
<updated>2009-12-07T16:27:43Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 16:27:42 2009
New Revision: 887985

URL: http://svn.apache.org/viewvc?rev=887985&amp;view=rev
Log:
* StompWireFormat.cs: 

Update the code to reflect the new Command names and feilds.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=887985&amp;r1=887984&amp;r2=887985&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
Mon Dec  7 16:27:42 2009
@@ -55,9 +55,9 @@
             {
                 WriteConnectionInfo((ConnectionInfo) o, ds);
             }
-            else if (o is ActiveMQMessage)
+            else if (o is Message)
             {
-                WriteMessage((ActiveMQMessage) o, ds);
+                WriteMessage((Message) o, ds);
             }
             else if (o is ConsumerInfo)
             {
@@ -241,15 +241,15 @@
 
         protected virtual Command ReadMessage(string command, IDictionary headers, byte[]
content)
         {
-            ActiveMQMessage message = null;
+            Message message = null;
             if (headers.Contains("content-length"))
             {
-                message = new ActiveMQBytesMessage();
+                message = new BytesMessage();
                 message.Content = content;
             }
             else
             {
-                message = new ActiveMQTextMessage(encoding.GetString(content, 0, content.Length));
+                message = new TextMessage(encoding.GetString(content, 0, content.Length));
             }
 
             // TODO now lets set the various headers
@@ -421,13 +421,13 @@
         protected virtual void WriteTransactionInfo(TransactionInfo command, StompFrameStream
ss)
         {
             TransactionId id = command.TransactionId;
-            if (id is LocalTransactionId)
+            if (id is TransactionId)
             {
                 string type = "BEGIN";
                 TransactionType transactionType = (TransactionType) command.Type;
                 switch (transactionType)
                 {
-                    case TransactionType.CommitOnePhase:
+                    case TransactionType.Commit:
                         command.ResponseRequired = true;
                         type = "COMMIT";
                         break;
@@ -468,7 +468,7 @@
             command.BeforeMarshall(null);
             if (command is TextMessage)
             {
-                ActiveMQTextMessage textMessage = command as ActiveMQTextMessage;
+                TextMessage textMessage = command as TextMessage;
                 ss.Content = encoding.GetBytes(textMessage.Text);
             }
             else




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887978 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands: Destination.cs MapMessage.cs Message.cs TempQueue.cs TempTopic.cs Topic.cs TransactionId.cs</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207162327.D51FE23889EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207162327-D51FE23889EC@eris-apache-org%3e</id>
<updated>2009-12-07T16:23:26Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 16:23:24 2009
New Revision: 887978

URL: http://svn.apache.org/viewvc?rev=887978&amp;view=rev
Log:
Gets most of the basic Commands compiling now.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
Mon Dec  7 16:23:24 2009
@@ -304,7 +304,6 @@
             set
             {
                 this.physicalName = value;
-                this.advisory = (value != null &amp;&amp; value.StartsWith(ADVISORY_PREFIX));
             }
         }
 
@@ -406,19 +405,6 @@
         }
 
         /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;true if the destination matches multiple possible destinations&lt;/returns&gt;
-        public bool IsWildcard()
-        {
-            if(physicalName != null)
-            {
-                return physicalName.IndexOf(DestinationFilter.ANY_CHILD) &gt;= 0
-                    || physicalName.IndexOf(DestinationFilter.ANY_DESCENDENT) &gt;= 0;
-            }
-            return false;
-        }
-
-        /// &lt;summary&gt;
         /// Factory method to create a child destination if this destination is a composite
         /// &lt;/summary&gt;
         /// &lt;param name="name"&gt;&lt;/param&gt;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
Mon Dec  7 16:23:24 2009
@@ -92,7 +92,7 @@
             {
                 MemoryStream buffer = new MemoryStream();
                 this.body.Marshal(buffer);
-                target.Close();
+                buffer.Close();
 
                 this.Content = buffer.ToArray();
             }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs Mon
Dec  7 16:23:24 2009
@@ -209,7 +209,9 @@
             {
                 if(null != MessageId)
                 {
-                    return BaseDataStreamMarshaller.ToString(MessageId);
+                    return MessageId.ProducerId.ConnectionId + ":" +
+                           MessageId.ProducerId.SessionId + ":" +
+                           MessageId.ProducerId.Value;
                 }
 
                 return String.Empty;
@@ -343,7 +345,7 @@
 
                 if(null != txnId)
                 {
-                    return BaseDataStreamMarshaller.ToString(txnId);
+                    return "" + txnId.Value;
                 }
 
                 return String.Empty;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
Mon Dec  7 16:23:24 2009
@@ -58,7 +58,7 @@
 
         public override Destination CreateDestination(String name)
         {
-            return new StompTempQueue(name);
+            return new TempQueue(name);
         }
 
         public override Object Clone()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
Mon Dec  7 16:23:24 2009
@@ -60,7 +60,7 @@
 
         public override Destination CreateDestination(String name)
         {
-            return new StompTempTopic(name);
+            return new TempTopic(name);
         }
 
         public override Object Clone()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs Mon
Dec  7 16:23:24 2009
@@ -22,13 +22,13 @@
     /// &lt;summary&gt;
     /// Summary description for Topic.
     /// &lt;/summary&gt;
-    public class StompTopic : Destination, ITopic
+    public class Topic : Destination, ITopic
     {
-        public StompTopic() : base()
+        public Topic() : base()
         {
         }
 
-        public StompTopic(String name) : base(name)
+        public Topic(String name) : base(name)
         {
         }
 
@@ -52,7 +52,7 @@
 
         public override int GetDestinationType()
         {
-            return ACTIVEMQ_TOPIC;
+            return STOMP_TOPIC;
         }
 
         public override Destination CreateDestination(String name)

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs?rev=887978&amp;r1=887977&amp;r2=887978&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs
Mon Dec  7 16:23:24 2009
@@ -20,7 +20,7 @@
 
 namespace Apache.NMS.Stomp.Commands
 {
-    public class TransactionId
+    public class TransactionId : BaseDataStructure
     {
         long value;
         ConnectionId connectionId;
@@ -31,7 +31,7 @@
         ///  Marshaler share.
         /// &lt;/summery&gt;
         ///
-        public byte GetDataStructureType()
+        public override byte GetDataStructureType()
         {
             return DataStructureTypes.TransactionIdType;
         }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887963 - in /activemq/activemq-cpp/trunk: activemq-cpp-openwire-generator/pom.xml activemq-cpp/pom.xml maven-cpptools-plugin/pom.xml pom.xml</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207154926.32B3F238888F@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207154926-32B3F238888F@eris-apache-org%3e</id>
<updated>2009-12-07T15:49:26Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 15:49:25 2009
New Revision: 887963

URL: http://svn.apache.org/viewvc?rev=887963&amp;view=rev
Log:
[maven-release-plugin] prepare release activemq-cpp-3.1.x

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml
    activemq/activemq-cpp/trunk/activemq-cpp/pom.xml
    activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml
    activemq/activemq-cpp/trunk/pom.xml

Modified: activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml?rev=887963&amp;r1=887962&amp;r2=887963&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml Mon Dec  7 15:49:25
2009
@@ -23,7 +23,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.x-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;activemq-cpp-openwire-generator&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/pom.xml?rev=887963&amp;r1=887962&amp;r2=887963&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/pom.xml (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/pom.xml Mon Dec  7 15:49:25 2009
@@ -24,7 +24,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.x-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;activemq-cpp-library&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml?rev=887963&amp;r1=887962&amp;r2=887963&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml (original)
+++ activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml Mon Dec  7 15:49:25 2009
@@ -24,7 +24,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.x-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;maven-cpptools-plugin&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/pom.xml?rev=887963&amp;r1=887962&amp;r2=887963&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/pom.xml (original)
+++ activemq/activemq-cpp/trunk/pom.xml Mon Dec  7 15:49:25 2009
@@ -27,7 +27,7 @@
 
   &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
   &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-  &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
+  &lt;version&gt;3.1.x-SNAPSHOT&lt;/version&gt;
   &lt;packaging&gt;pom&lt;/packaging&gt;
   &lt;name&gt;ActiveMQ-CPP Project&lt;/name&gt;
   &lt;inceptionYear&gt;2007&lt;/inceptionYear&gt;
@@ -90,9 +90,9 @@
   &lt;/distributionManagement&gt;
 
   &lt;scm&gt;
-    &lt;connection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/connection&gt;
-    &lt;developerConnection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/developerConnection&gt;
-    &lt;url&gt;http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/url&gt;
+    &lt;connection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/trunk&lt;/connection&gt;
+    &lt;developerConnection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/trunk&lt;/developerConnection&gt;
+    &lt;url&gt;http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk&lt;/url&gt;
   &lt;/scm&gt;
 
   &lt;dependencyManagement&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887962 - in /activemq/activemq-cpp/branches/activemq-cpp-3.1.x: ./ maven-cpptools-plugin/pom.xml pom.xml</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207154917.3C9EF23889E7@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207154917-3C9EF23889E7@eris-apache-org%3e</id>
<updated>2009-12-07T15:49:17Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 15:49:16 2009
New Revision: 887962

URL: http://svn.apache.org/viewvc?rev=887962&amp;view=rev
Log:
[maven-release-plugin]  copy for branch activemq-cpp-3.1.x

Added:
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/
      - copied from r887957, activemq/activemq-cpp/trunk/
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/maven-cpptools-plugin/pom.xml
      - copied unchanged from r887959, activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/pom.xml
      - copied unchanged from r887961, activemq/activemq-cpp/trunk/pom.xml



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887961 - /activemq/activemq-cpp/trunk/pom.xml</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207154910.E53B4238888E@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207154910-E53B4238888E@eris-apache-org%3e</id>
<updated>2009-12-07T15:49:10Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 15:49:10 2009
New Revision: 887961

URL: http://svn.apache.org/viewvc?rev=887961&amp;view=rev
Log:
[maven-release-plugin] prepare branch activemq-cpp-3.1.x

Modified:
    activemq/activemq-cpp/trunk/pom.xml

Modified: activemq/activemq-cpp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/pom.xml?rev=887961&amp;r1=887960&amp;r2=887961&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/pom.xml (original)
+++ activemq/activemq-cpp/trunk/pom.xml Mon Dec  7 15:49:10 2009
@@ -90,9 +90,9 @@
   &lt;/distributionManagement&gt;
 
   &lt;scm&gt;
-    &lt;connection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/trunk&lt;/connection&gt;
-    &lt;developerConnection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/trunk&lt;/developerConnection&gt;
-    &lt;url&gt;http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk&lt;/url&gt;
+    &lt;connection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/connection&gt;
+    &lt;developerConnection&gt;scm:svn:https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/developerConnection&gt;
+    &lt;url&gt;http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x&lt;/url&gt;
   &lt;/scm&gt;
 
   &lt;dependencyManagement&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887959 - /activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207154628.C661223889E7@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207154628-C661223889E7@eris-apache-org%3e</id>
<updated>2009-12-07T15:46:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 15:46:28 2009
New Revision: 887959

URL: http://svn.apache.org/viewvc?rev=887959&amp;view=rev
Log:
Fix version info.

Modified:
    activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml

Modified: activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml?rev=887959&amp;r1=887958&amp;r2=887959&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml (original)
+++ activemq/activemq-cpp/trunk/maven-cpptools-plugin/pom.xml Mon Dec  7 15:46:28 2009
@@ -24,7 +24,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.1.x-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;maven-cpptools-plugin&lt;/artifactId&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887936 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/examples: consumers/SimpleAsyncConsumer.cpp producers/SimpleProducer.cpp</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091207144713.94A53238898B@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091207144713-94A53238898B@eris-apache-org%3e</id>
<updated>2009-12-07T14:47:13Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Mon Dec  7 14:47:12 2009
New Revision: 887936

URL: http://svn.apache.org/viewvc?rev=887936&amp;view=rev
Log:
Cleaned up the sample code a bit.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp?rev=887936&amp;r1=887935&amp;r2=887936&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
Mon Dec  7 14:47:12 2009
@@ -66,10 +66,11 @@
                          const std::string&amp; destURI,
                          bool useTopic = false,
                          bool clientAck = false ) {
-        connection = NULL;
-        session = NULL;
-        destination = NULL;
-        consumer = NULL;
+
+        this-&gt;connection = NULL;
+        this-&gt;session = NULL;
+        this-&gt;destination = NULL;
+        this-&gt;consumer = NULL;
         this-&gt;useTopic = useTopic;
         this-&gt;brokerURI = brokerURI;
         this-&gt;destURI = destURI;
@@ -160,7 +161,7 @@
     // registered as an ExceptionListener with the connection.
     virtual void onException( const CMSException&amp; ex AMQCPP_UNUSED ) {
         printf("CMS Exception occurred.  Shutting down client.\n");
-        //exit(1);
+        exit(1);
     }
 
     virtual void transportInterrupted() {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp?rev=887936&amp;r1=887935&amp;r2=887936&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp Mon
Dec  7 14:47:12 2009
@@ -64,12 +64,12 @@
                     unsigned int numMessages,
                     const std::string&amp; destURI,
                     bool useTopic = false,
-                    bool clientAck = false,
-                    unsigned int connectRetries = 0 ){
-        connection = NULL;
-        session = NULL;
-        destination = NULL;
-        producer = NULL;
+                    bool clientAck = false ){
+
+        this-&gt;connection = NULL;
+        this-&gt;session = NULL;
+        this-&gt;destination = NULL;
+        this-&gt;producer = NULL;
         this-&gt;numMessages = numMessages;
         this-&gt;useTopic = useTopic;
         this-&gt;brokerURI = brokerURI;
@@ -87,6 +87,7 @@
 
     virtual void run() {
         try {
+
             // Create a ConnectionFactory
             auto_ptr&lt;ActiveMQConnectionFactory&gt; connectionFactory(
                 new ActiveMQConnectionFactory( brokerURI ) );
@@ -229,7 +230,11 @@
 
     // Create the producer and run it.
     SimpleProducer producer( brokerURI, numMessages, destURI, useTopics );
+
+    // Publish the given number of Messages
     producer.run();
+
+    // Before exiting we ensure that all CMS resources are closed.
     producer.close();
 
     std::cout &lt;&lt; "-----------------------------------------------------\n";




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887755 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/test/java/org/apache/activemq/broker/ activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/ activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/i...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206195405.5A4892388962@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206195405-5A4892388962@eris-apache-org%3e</id>
<updated>2009-12-06T19:54:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 19:54:02 2009
New Revision: 887755

URL: http://svn.apache.org/viewvc?rev=887755&amp;view=rev
Log:
Adding a DispatchOption enum to control the thread 'sticky' factor for serial queues.


Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchOption.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractSerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SerialDispatchQueue.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java Sun Dec  6 19:54:02 2009
@@ -15,6 +15,8 @@
 import org.apache.activemq.metric.MetricCounter;
 import org.apache.activemq.transport.TransportFactory;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 abstract public class RemoteProducer extends Connection implements FlowUnblockListener&lt;MessageDelivery&gt; {
 
     protected final MetricCounter rate = new MetricCounter();
@@ -59,7 +61,7 @@
         
         setupProducer();
         
-        dispatchQueue = getDispatcher().createSerialQueue(name + "-client");
+        dispatchQueue = getDispatcher().createSerialQueue(name + "-client", STICK_TO_CALLER_THREAD);
         dispatchTask = new Runnable(){
             public void run() {
                 dispatch();

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchOption.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchOption.java?rev=887755&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchOption.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchOption.java Sun Dec  6 19:54:02 2009
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+public enum DispatchOption {
+    /**
+     * Updates the target queue to be the
+     * thread queue so that execution 'sticks' to caller's 
+     * thread queue.
+     */
+    STICK_TO_CALLER_THREAD,
+    
+    /**
+     * Used to update the target queue to be the first
+     * random thread queue that dispatches this queue.
+     */
+    STICK_TO_DISPATCH_THREAD, 
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.dispatch;
 
+import java.util.EnumSet;
+import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
@@ -31,7 +33,7 @@
     public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit);
     public void dispatchApply(int iterations, Runnable runnable) throws InterruptedException;
     
-    String getLabel();
-
+    public String getLabel();
+    public Set&lt;DispatchOption&gt; getOptions();
                       
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java Sun Dec  6 19:54:02 2009
@@ -18,7 +18,9 @@
 
 import java.nio.channels.SelectableChannel;
 
+
 /**
+ * Provides easy access to a system wide Dispatcher.
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
@@ -27,9 +29,11 @@
     final private static Dispatcher dispatcher = create();
 
     private static Dispatcher create() {
-        return new DispatcherConfig().createDispatcher();
+        Dispatcher rc = new DispatcherConfig().createDispatcher();
+        rc.retain();
+        return rc;
     }
-
+    
     static DispatchQueue getMainQueue() {
         return dispatcher.getMainQueue();
     }
@@ -42,8 +46,8 @@
         return dispatcher.getGlobalQueue(priority);
     }
     
-    static DispatchQueue getSerialQueue(String label) {
-        return dispatcher.createSerialQueue(label);
+    static DispatchQueue getSerialQueue(String label, DispatchOption...options) {
+        return dispatcher.createSerialQueue(label, options);
     }
     
     static void dispatchMain() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java Sun Dec  6 19:54:02 2009
@@ -21,11 +21,11 @@
 
 
 public interface Dispatcher extends Retained {
-        
+
     public DispatchQueue getGlobalQueue();
     public DispatchQueue getGlobalQueue(DispatchPriority priority);
     
-    public DispatchQueue createSerialQueue(String label);
+    public DispatchQueue createSerialQueue(String label, DispatchOption... options);
     
     public DispatchQueue getMainQueue();
     public void dispatchMain();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java Sun Dec  6 19:54:02 2009
@@ -24,7 +24,7 @@
     public void onThreadCreate(DispatcherThread thread);
     public void onThreadDestroy(DispatcherThread thread);
 
-    public void onQueueCreate(DispatchQueue queue);
+    public void onQueueCreate(DispatchQueue queue, DispatchOption...options);
     public void onQueueDestroy(DispatchQueue queue);
     
     public void onSourceCreate(DispatchSource source);

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractSerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractSerialDispatchQueue.java?rev=887755&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractSerialDispatchQueue.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractSerialDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchOption;
+
+/**
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+abstract public class AbstractSerialDispatchQueue extends AbstractDispatchObject implements DispatchQueue, Runnable {
+
+    private final String label;
+    private final AtomicInteger suspendCounter = new AtomicInteger();
+    private final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
+    private final AtomicLong size = new AtomicLong();
+    private final Set&lt;DispatchOption&gt; options;
+
+    public AbstractSerialDispatchQueue(String label, DispatchOption...options) {
+        this.label = label;
+        this.options = set(options);
+        retain();
+    }
+
+    static private Set&lt;DispatchOption&gt; set(DispatchOption[] options) {
+        if( options==null || options.length==0 )
+            return Collections.emptySet() ;
+        return Collections.unmodifiableSet(EnumSet.copyOf(Arrays.asList(options)));
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void resume() {
+        if( suspendCounter.decrementAndGet() == 0 ) {
+            if( size.get() != 0 ) {
+                dispatchSelfAsync();
+            }
+        }
+    }
+
+    public void suspend() {
+        suspendCounter.incrementAndGet();
+    }
+
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+        throw new RuntimeException("TODO: implement me.");
+    }
+
+    public void execute(Runnable command) {
+        dispatchAsync(command);
+    }
+
+    public void dispatchAsync(Runnable runnable) {
+        if( runnable == null ) {
+            throw new IllegalArgumentException();
+        }
+        long lastSize = size.getAndIncrement();
+        if( lastSize==0 ) {
+            retain();
+        }
+        runnables.add(runnable);
+        if( lastSize == 0 &amp;&amp; suspendCounter.get()&lt;=0 ) {
+            dispatchSelfAsync();
+        }
+    }
+
+    protected void dispatchSelfAsync() {
+        targetQueue.dispatchAsync(this);
+    }
+
+    public void run() {
+        Runnable runnable;
+        long lsize = size.get();
+        while( suspendCounter.get() &lt;= 0 &amp;&amp; lsize &gt; 0 ) {
+            try {
+                runnable = runnables.poll();
+                if( runnable!=null ) {
+                    runnable.run();
+                    lsize = size.decrementAndGet();
+                    if( lsize==0 ) {
+                        release();
+                    }
+                }
+            } catch (Throwable e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public void dispatchSync(Runnable runnable) throws InterruptedException {
+        dispatchApply(1, runnable);
+    }
+    
+    public void dispatchApply(int iterations, Runnable runnable) throws InterruptedException {
+        QueueSupport.dispatchApply(this, iterations, runnable);
+    }
+
+    public Set&lt;DispatchOption&gt; getOptions() {
+        return options;
+    }
+
+    
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java Sun Dec  6 19:54:02 2009
@@ -24,13 +24,13 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSource;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.internal.BaseRetained;
-import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
 import static org.apache.activemq.dispatch.DispatchPriority.*;
 
@@ -183,8 +183,8 @@
         return globalQueues[priority.ordinal()];
     }
     
-    public DispatchQueue createSerialQueue(String label) {
-        AdvancedSerialDispatchQueue rc = new AdvancedSerialDispatchQueue(label);
+    public DispatchQueue createSerialQueue(String label, DispatchOption... options) {
+        SerialDispatchQueue rc = new SerialDispatchQueue(label, options);
         rc.setTargetQueue(getGlobalQueue());
         return rc;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -16,8 +16,12 @@
  */
 package org.apache.activemq.dispatch.internal.advanced;
 
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
@@ -95,4 +99,9 @@
 
     public void retain() {
     }
+    
+    public Set&lt;DispatchOption&gt; getOptions() {
+        return Collections.emptySet();
+    }
+
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SerialDispatchQueue.java?rev=887755&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SerialDispatchQueue.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SerialDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -0,0 +1,32 @@
+package org.apache.activemq.dispatch.internal.advanced;
+
+import org.apache.activemq.dispatch.DispatchOption;
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.internal.AbstractSerialDispatchQueue;
+
+public class SerialDispatchQueue extends AbstractSerialDispatchQueue {
+
+    public SerialDispatchQueue(String label, DispatchOption...options) {
+        super(label, options);
+//        context = new DispatchContext(this, true, label);
+}
+    
+//    @Override
+//    protected void dispatchSelfAsync() {
+//        AdvancedQueue aq = ((AdvancedQueue)targetQueue);
+//        super.dispatchSelfAsync();
+//    }
+    
+    @Override
+    public void run() {
+        DispatchQueue original = AdvancedDispatcher.CURRENT_QUEUE.get();
+        AdvancedDispatcher.CURRENT_QUEUE.set(this);
+        try {
+            super.run();
+        } finally {
+            AdvancedDispatcher.CURRENT_QUEUE.set(original);
+        }
+    }
+    
+
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -16,8 +16,12 @@
  */
 package org.apache.activemq.dispatch.internal.advanced;
 
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
@@ -95,5 +99,10 @@
 
     public void retain() {
     }
+    
+    public Set&lt;DispatchOption&gt; getOptions() {
+        return Collections.emptySet();
+    }
+
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java Sun Dec  6 19:54:02 2009
@@ -19,8 +19,6 @@
 
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.DispatchPriority;
-
 /**
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
@@ -33,9 +31,9 @@
         
     public DispatcherThread(SimpleDispatcher dispatcher, int ordinal) {
         this.dispatcher = dispatcher;
-        this.threadQueues = new ThreadDispatchQueue[3];
-        for (int i = 0; i &lt; 3; i++) {
-            threadQueues[i] = new ThreadDispatchQueue(this, DispatchPriority.values()[i] );
+        this.threadQueues = new ThreadDispatchQueue[dispatcher.globalQueues.length];
+        for (int i = 0; i &lt; threadQueues.length; i++) {
+            threadQueues[i] = new ThreadDispatchQueue(this, dispatcher.globalQueues[i]);
         }
         setName(dispatcher.getLabel()+" dispatcher: "+(ordinal+1));
         setDaemon(true);
@@ -43,11 +41,12 @@
     
     @Override
     public void run() {
+        GlobalDispatchQueue[] globalQueues = dispatcher.globalQueues;
         try {
             outer: while( true ) {
                 int counter=0;
-                for (SimpleQueue queue : threadQueues) {
-                    SimpleDispatcher.CURRENT_QUEUE.set(queue);
+                for (ThreadDispatchQueue queue : threadQueues) {
+                    SimpleDispatcher.CURRENT_QUEUE.set(queue.globalQueue);
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
                         dispatch(runnable);
@@ -60,8 +59,8 @@
                     continue;
                 }
                 
-                for (SimpleQueue queue : dispatcher.globalQueues) {
-                    SimpleDispatcher.CURRENT_QUEUE.set(threadQueues[queue.getPriority().ordinal()]);
+                for (SimpleQueue queue : globalQueues) {
+                    SimpleDispatcher.CURRENT_QUEUE.set(queue);
                     
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
@@ -134,6 +133,14 @@
             e.printStackTrace();
         }
     }
+    
+    public static DispatcherThread currentDispatcherThread() {
+        Thread currentThread = Thread.currentThread();
+        if( currentThread.getClass() == DispatcherThread.class ) {
+            return (DispatcherThread) currentThread;
+        }
+        return null;
+    }
 
     private final Object wakeupMutex = new Object();
     private boolean inWaitingList;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -16,10 +16,14 @@
  */
 package org.apache.activemq.dispatch.internal.simple;
 
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
@@ -28,7 +32,7 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public class GlobalDispatchQueue implements SimpleQueue {
+final public class GlobalDispatchQueue implements SimpleQueue {
 
     private final SimpleDispatcher dispatcher;
     final String label;
@@ -69,6 +73,32 @@
         QueueSupport.dispatchApply(this, iterations, runnable);
     }
 
+    public ThreadDispatchQueue getTargetQueue() {
+        DispatcherThread thread = DispatcherThread.currentDispatcherThread();
+        if( thread == null ) {
+            return null;
+        }
+        return thread.threadQueues[priority.ordinal()];
+    }
+    
+    public Runnable poll() {
+        Runnable rc = runnables.poll();
+        if( rc !=null ) {
+            counter.decrementAndGet();
+        }
+        return rc;
+    }
+
+    public DispatchPriority getPriority() {
+        return priority;
+    }
+
+    public void release() {
+    }
+
+    public void retain() {
+    }
+
     public void resume() {
         throw new UnsupportedOperationException();
     }
@@ -93,25 +123,20 @@
         throw new UnsupportedOperationException();
     }
 
-    public DispatchQueue getTargetQueue() {
-        throw new UnsupportedOperationException();
-    }
-    
-    public Runnable poll() {
-        Runnable rc = runnables.poll();
-        if( rc !=null ) {
-            counter.decrementAndGet();
-        }
-        return rc;
+    public Set&lt;DispatchOption&gt; getOptions() {
+        return Collections.emptySet();
     }
 
-    public DispatchPriority getPriority() {
-        return priority;
+    public GlobalDispatchQueue isGlobalDispatchQueue() {
+        return this;
     }
 
-    public void release() {
+    public SerialDispatchQueue isSerialDispatchQueue() {
+        return null;
     }
 
-    public void retain() {
+    public ThreadDispatchQueue isThreadDispatchQueue() {
+        return null;
     }
+
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SerialDispatchQueue.java?rev=887755&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SerialDispatchQueue.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SerialDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal.simple;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.dispatch.DispatchOption;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.internal.AbstractSerialDispatchQueue;
+
+public final class SerialDispatchQueue extends AbstractSerialDispatchQueue implements SimpleQueue {
+
+    private final SimpleDispatcher dispatcher;
+    private volatile boolean stickToThreadOnNextDispatch; 
+    private volatile boolean stickToThreadOnNextDispatchRequest; 
+    
+    SerialDispatchQueue(SimpleDispatcher dispatcher, String label, DispatchOption...options) {
+        super(label, options);
+        this.dispatcher = dispatcher;
+    }
+
+    @Override
+    public void setTargetQueue(DispatchQueue targetQueue) {
+        GlobalDispatchQueue global = ((SimpleQueue)targetQueue).isGlobalDispatchQueue(); 
+        if( getOptions().contains(DispatchOption.STICK_TO_CALLER_THREAD) &amp;&amp; global!=null ) {
+            stickToThreadOnNextDispatchRequest=true;
+        }
+        super.setTargetQueue(targetQueue);
+    }
+    
+    @Override
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+        dispatcher.timerThread.addRelative(runnable, this, delay, unit);
+    }
+
+    @Override
+    protected void dispatchSelfAsync() {
+        if( stickToThreadOnNextDispatchRequest ) {
+            SimpleQueue current = SimpleDispatcher.CURRENT_QUEUE.get();
+            if( current!=null ) {
+                SimpleQueue parent;
+                while( (parent = current.getTargetQueue()) !=null ) {
+                    current = parent;
+                }
+                if( current.isThreadDispatchQueue()==null ) {
+                    System.out.println("crap");
+                }
+                super.setTargetQueue(current);
+                stickToThreadOnNextDispatchRequest=false;
+            }
+        }
+        super.dispatchSelfAsync();
+    }
+    
+    @Override
+    public void run() {
+        SimpleQueue current = SimpleDispatcher.CURRENT_QUEUE.get();
+        if( stickToThreadOnNextDispatch ) {
+            stickToThreadOnNextDispatch=false;
+            GlobalDispatchQueue global = current.isGlobalDispatchQueue();
+            if( global!=null ) {
+                setTargetQueue(global.getTargetQueue());
+            }
+        }
+        SimpleDispatcher.CURRENT_QUEUE.set(this);
+        try {
+            super.run();
+        } finally {
+            SimpleDispatcher.CURRENT_QUEUE.set(current);
+        }
+    }
+
+    public DispatchPriority getPriority() {
+        throw new UnsupportedOperationException();
+    }
+
+    public Runnable poll() {
+        throw new UnsupportedOperationException();
+    }
+
+    public GlobalDispatchQueue isGlobalDispatchQueue() {
+        return null;
+    }
+
+    public SerialDispatchQueue isSerialDispatchQueue() {
+        return this;
+    }
+
+    public ThreadDispatchQueue isThreadDispatchQueue() {
+        return null;
+    }
+    
+    public SimpleQueue getTargetQueue() {
+        return (SimpleQueue) targetQueue;
+    }
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java Sun Dec  6 19:54:02 2009
@@ -18,7 +18,6 @@
 
 import java.nio.channels.SelectableChannel;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -27,8 +26,9 @@
 import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchSource;
 import org.apache.activemq.dispatch.DispatcherConfig;
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.internal.BaseRetained;
-import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
+import org.apache.activemq.dispatch.internal.AbstractSerialDispatchQueue;
 
 import static org.apache.activemq.dispatch.DispatchPriority.*;
 
@@ -41,9 +41,9 @@
  */
 final public class SimpleDispatcher extends BaseRetained implements Dispatcher {
         
-    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
+    public final static ThreadLocal&lt;SimpleQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;SimpleQueue&gt;();
 
-    final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
+    final SerialDispatchQueue mainQueue = new SerialDispatchQueue(this, "main");
     final GlobalDispatchQueue globalQueues[]; 
     final DispatcherThread dispatchers[];
     final AtomicLong globalQueuedRunnables = new AtomicLong();
@@ -74,13 +74,8 @@
         return globalQueues[priority.ordinal()];
     }
     
-    public DispatchQueue createSerialQueue(String label) {
-        SerialDispatchQueue rc = new SerialDispatchQueue(label) {
-            @Override
-            public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
-                timerThread.addRelative(runnable, this, delay, unit);
-            }
-        };
+    public DispatchQueue createSerialQueue(String label, DispatchOption... options) {
+        AbstractSerialDispatchQueue rc = new SerialDispatchQueue(this, label, options);
         rc.setTargetQueue(getGlobalQueue());
         return rc;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java Sun Dec  6 19:54:02 2009
@@ -7,4 +7,11 @@
 
     Runnable poll();
     DispatchPriority getPriority();
+    
+    SerialDispatchQueue isSerialDispatchQueue();
+    ThreadDispatchQueue isThreadDispatchQueue();
+    GlobalDispatchQueue isGlobalDispatchQueue();
+    
+    SimpleQueue getTargetQueue();
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java Sun Dec  6 19:54:02 2009
@@ -16,32 +16,35 @@
  */
 package org.apache.activemq.dispatch.internal.simple;
 
+import java.util.Collections;
 import java.util.LinkedList;
+import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchOption;
 import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.internal.QueueSupport;
 
 /**
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public class ThreadDispatchQueue implements SimpleQueue {
+final public class ThreadDispatchQueue implements SimpleQueue {
 
     final String label;
     final LinkedList&lt;Runnable&gt; localRunnables = new LinkedList&lt;Runnable&gt;();
     final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
-    private DispatcherThread dispatcher;
+    final DispatcherThread dispatcher;
     final AtomicLong counter;
-    private final DispatchPriority priority;
+    final GlobalDispatchQueue globalQueue;
     
-    public ThreadDispatchQueue(DispatcherThread dispatcher, DispatchPriority priority) {
+    public ThreadDispatchQueue(DispatcherThread dispatcher, GlobalDispatchQueue globalQueue) {
         this.dispatcher = dispatcher;
-        this.priority = priority;
-        this.label=priority.toString();
+        this.globalQueue = globalQueue;
+        this.label="thread local "+globalQueue.getLabel();
         this.counter = dispatcher.threadQueuedRunnables;
     }
 
@@ -119,12 +122,13 @@
     public void setTargetQueue(DispatchQueue queue) {
         throw new UnsupportedOperationException();
     }
-    public DispatchQueue getTargetQueue() {
-        throw new UnsupportedOperationException();
+    
+    public SimpleQueue getTargetQueue() {
+        return null;
     }
     
     public DispatchPriority getPriority() {
-        return priority;
+        return globalQueue.getPriority();
     }
 
     public void release() {
@@ -133,4 +137,20 @@
     public void retain() {
     }
 
+    public Set&lt;DispatchOption&gt; getOptions() {
+        return Collections.emptySet();
+    }
+
+    public GlobalDispatchQueue isGlobalDispatchQueue() {
+        return null;
+    }
+
+    public SerialDispatchQueue isSerialDispatchQueue() {
+        return null;
+    }
+
+    public ThreadDispatchQueue isThreadDispatchQueue() {
+        return this;
+    }
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java Sun Dec  6 19:54:02 2009
@@ -8,7 +8,7 @@
 
 import static org.apache.activemq.dispatch.internal.simple.TimerThread.Type.*;
 
-public class TimerThread extends Thread {
+final public class TimerThread extends Thread {
     enum Type {
         RELATIVE,
         ABSOLUTE,

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java Sun Dec  6 19:54:02 2009
@@ -17,6 +17,8 @@
 import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatcher;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 
 /** 
  * ActorTest
@@ -49,7 +51,7 @@
         Dispatcher advancedSystem = new AdvancedDispatcher(new DispatcherConfig());
         advancedSystem.retain();
         
-        DispatchQueue queue = advancedSystem.createSerialQueue("test");
+        DispatchQueue queue = advancedSystem.createSerialQueue("test", STICK_TO_CALLER_THREAD);
         ActorTestObject testObject = Actor.create(new ActorTestObject(), queue);
         
         CountDownLatch latch = new CountDownLatch(1);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java Sun Dec  6 19:54:02 2009
@@ -36,7 +36,7 @@
         Dispatcher advancedSystem = new AdvancedDispatcher(new DispatcherConfig());
         advancedSystem.retain();
         benchmark("advanced global queue", advancedSystem, advancedSystem.getGlobalQueue(DEFAULT));
-        benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test"));
+        benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test", DispatchOption.STICK_TO_CALLER_THREAD));
 
         RunnableCountDownLatch latch = new RunnableCountDownLatch(1);
         advancedSystem.addShutdownWatcher(latch);
@@ -47,7 +47,7 @@
         simpleSystem.retain();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));
-        benchmark("simple private serial queue", simpleSystem, simpleSystem.createSerialQueue("test"));
+        benchmark("simple private serial queue", simpleSystem, simpleSystem.createSerialQueue("test", DispatchOption.STICK_TO_CALLER_THREAD));
 
         latch = new RunnableCountDownLatch(1);
         advancedSystem.addShutdownWatcher(latch);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java Sun Dec  6 19:54:02 2009
@@ -21,8 +21,8 @@
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatcherConfig;
 
-
 import static java.lang.String.*;
+import static org.apache.activemq.dispatch.DispatchOption.*;
 
 /**
  * 
@@ -64,7 +64,7 @@
 
         private Work(CountDownLatch counter, AdvancedDispatcher dispatcher) {
             this.counter = counter;
-            dispatchQueue = dispatcher.createSerialQueue("test");
+            dispatchQueue = dispatcher.createSerialQueue("test", STICK_TO_CALLER_THREAD);
         }
 
         public void run() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java Sun Dec  6 19:54:02 2009
@@ -38,9 +38,9 @@
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
@@ -61,6 +61,8 @@
 import org.apache.activemq.queue.SingleFlowRelay;
 import org.apache.activemq.queue.Subscription;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 public class SharedQueuePerfTest extends TestCase {
 
     private static int PERFORMANCE_SAMPLES = 5;
@@ -308,7 +310,7 @@
             sendRate.name("Producer " + name + " Rate");
             totalProducerRate.add(sendRate);
             
-            dispatchQueue = dispatcher.createSerialQueue(name);
+            dispatchQueue = dispatcher.createSerialQueue(name, STICK_TO_CALLER_THREAD);
             dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java Sun Dec  6 19:54:02 2009
@@ -19,11 +19,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.ISinkController.FlowControllable;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 /**
  * Base class for a {@link FlowControllable}
  * {@link IFlowQueue}.
@@ -135,7 +137,7 @@
     public synchronized void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
         
-        dispatchQueue = dispatcher.createSerialQueue(getResourceName());
+        dispatchQueue = dispatcher.createSerialQueue(getResourceName(), STICK_TO_CALLER_THREAD);
         dispatchTask = new Runnable(){
             public void run() {
                 if( pollingDispatch() ) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java Sun Dec  6 19:54:02 2009
@@ -11,6 +11,8 @@
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.MetricCounter;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 public class RemoteProducer extends ClientConnection implements FlowUnblockListener&lt;Message&gt; {
 
     private final MetricCounter rate = new MetricCounter();
@@ -48,7 +50,7 @@
         super.start();
         outboundController = outputQueue.getFlowController(outboundFlow);
         
-        dispatchQueue = getDispatcher().createSerialQueue(name + "-client");
+        dispatchQueue = getDispatcher().createSerialQueue(name + "-client", STICK_TO_CALLER_THREAD);
         dispatchTask = new Runnable(){
             public void run() {
                 dispatch();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java?rev=887755&amp;r1=887754&amp;r2=887755&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java Sun Dec  6 19:54:02 2009
@@ -14,7 +14,6 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
@@ -34,6 +33,8 @@
 import org.apache.activemq.wireformat.WireFormat;
 import org.apache.activemq.wireformat.WireFormatFactory;
 
+import static org.apache.activemq.dispatch.DispatchOption.*;
+
 public class PipeTransportFactory extends TransportFactory {
     static private final Object EOF_TOKEN = new Object();
 
@@ -83,7 +84,7 @@
         }
 
         public void setDispatcher(Dispatcher dispatcher) {
-            dispatchQueue = dispatcher.createSerialQueue(name);
+            dispatchQueue = dispatcher.createSerialQueue(name, STICK_TO_CALLER_THREAD);
             dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887737 - /activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206183540.0025E23888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206183540-0025E23888D1@eris-apache-org%3e</id>
<updated>2009-12-06T18:35:39Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:35:39 2009
New Revision: 887737

URL: http://svn.apache.org/viewvc?rev=887737&amp;view=rev
Log:
Update Changelog.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt

Modified: activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt?rev=887737&amp;r1=887736&amp;r2=887737&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt Sun Dec  6 18:35:39 2009
@@ -24,6 +24,7 @@
                      decaf::io::ByteArrayOutputStream::write( const unsigned char* buffer,
                      std::size_t offset, std::size_t len )
     * [AMQCPP-270] - Broker exception on message Ack,
+    * [AMQCPP-271] - Connection shutdown crashes if the server went down
 
 Improvement
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887736 - /activemq/activemq-cpp/branches/activemq-cpp-3.1.x/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206183208.0709923888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206183208-0709923888D1@eris-apache-org%3e</id>
<updated>2009-12-06T18:32:07Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:32:07 2009
New Revision: 887736

URL: http://svn.apache.org/viewvc?rev=887736&amp;view=rev
Log:
Drop this branch while trunk is still acting as a 3.1 SNAPSHOT.

Removed:
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887735 - /activemq/activemq-cpp/trunk/pom.xml</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206183108.32DE123888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206183108-32DE123888EC@eris-apache-org%3e</id>
<updated>2009-12-06T18:31:08Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:31:07 2009
New Revision: 887735

URL: http://svn.apache.org/viewvc?rev=887735&amp;view=rev
Log:
revert version update while more 3.1 work is in progress,

Modified:
    activemq/activemq-cpp/trunk/pom.xml

Modified: activemq/activemq-cpp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/pom.xml?rev=887735&amp;r1=887734&amp;r2=887735&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/pom.xml (original)
+++ activemq/activemq-cpp/trunk/pom.xml Sun Dec  6 18:31:07 2009
@@ -27,7 +27,7 @@
 
   &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
   &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-  &lt;version&gt;3.2.0-SNAPSHOT&lt;/version&gt;
+  &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
   &lt;packaging&gt;pom&lt;/packaging&gt;
   &lt;name&gt;ActiveMQ-CPP Project&lt;/name&gt;
   &lt;inceptionYear&gt;2007&lt;/inceptionYear&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887734 - in /activemq/activemq-cpp/trunk: activemq-c/pom.xml activemq-cpp-openwire-generator/pom.xml activemq-cpp/configure.ac activemq-cpp/pom.xml activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206183028.68D8923888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206183028-68D8923888D1@eris-apache-org%3e</id>
<updated>2009-12-06T18:30:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:30:27 2009
New Revision: 887734

URL: http://svn.apache.org/viewvc?rev=887734&amp;view=rev
Log:
Reverting versioning updates while more 3.1 work is in progress.

Modified:
    activemq/activemq-cpp/trunk/activemq-c/pom.xml
    activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml
    activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
    activemq/activemq-cpp/trunk/activemq-cpp/pom.xml
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp

Modified: activemq/activemq-cpp/trunk/activemq-c/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/pom.xml?rev=887734&amp;r1=887733&amp;r2=887734&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/pom.xml (original)
+++ activemq/activemq-cpp/trunk/activemq-c/pom.xml Sun Dec  6 18:30:27 2009
@@ -25,7 +25,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.2.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;activemq-c-library&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml?rev=887734&amp;r1=887733&amp;r2=887734&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp-openwire-generator/pom.xml Sun Dec  6 18:30:27
2009
@@ -23,7 +23,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.2.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;activemq-cpp-openwire-generator&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac?rev=887734&amp;r1=887733&amp;r2=887734&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/configure.ac (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Sun Dec  6 18:30:27 2009
@@ -20,7 +20,7 @@
 ## --------------------------------
 ## Initialization macros.
 ## --------------------------------
-AC_INIT(activemq-cpp, 3.2.0, dev@activemq.apache.org)
+AC_INIT(activemq-cpp, 3.1.0, dev@activemq.apache.org)
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_SRCDIR(src/main/activemq/core/ActiveMQConnection.cpp)
 AC_CONFIG_MACRO_DIR([m4])
@@ -30,7 +30,7 @@
 ## -----------------------------------------------
 ACTIVEMQ_LIBRARY_NAME=activemq-cpp
 ACTIVEMQ_MAJOR_VERSION=3
-ACTIVEMQ_MINOR_VERSION=2
+ACTIVEMQ_MINOR_VERSION=1
 ACTIVEMQ_PATCH_VERSION=0
 ACTIVEMQ_VERSION=${ACTIVEMQ_MAJOR_VERSION}.${ACTIVEMQ_MINOR_VERSION}.${ACTIVEMQ_PATCH_VERSION}
 ACTIVEMQ_API_VERSION=${ACTIVEMQ_VERSION}
@@ -48,7 +48,7 @@
 ## REVISION: a change in the REVISION number is made for any other type of change
 ##  that does not justify a change to MINOR or MAJOR
 ##
-ACTIVEMQ_LIBRARY_VERSION=12:0:0
+ACTIVEMQ_LIBRARY_VERSION=11:0:0
 
 AC_SUBST(ACTIVEMQ_LIBRARY_NAME)
 AC_SUBST(ACTIVEMQ_VERSION)

Modified: activemq/activemq-cpp/trunk/activemq-cpp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/pom.xml?rev=887734&amp;r1=887733&amp;r2=887734&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/pom.xml (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/pom.xml Sun Dec  6 18:30:27 2009
@@ -24,7 +24,7 @@
   &lt;parent&gt;
     &lt;groupId&gt;org.apache.activemq-cpp&lt;/groupId&gt;
     &lt;artifactId&gt;activemq-cpp-pom&lt;/artifactId&gt;
-    &lt;version&gt;3.2.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;3.1.0-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
 
   &lt;artifactId&gt;activemq-cpp-library&lt;/artifactId&gt;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp?rev=887734&amp;r1=887733&amp;r2=887734&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionMetaData.cpp
Sun Dec  6 18:30:27 2009
@@ -51,7 +51,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string ActiveMQConnectionMetaData::getProviderVersion() const throw( cms::CMSException
) {
-    return "3.2";
+    return "3.1";
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -61,7 +61,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int ActiveMQConnectionMetaData::getProviderMinorVersion() const throw( cms::CMSException
) {
-    return 2;
+    return 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887732 - in /activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main: activemq/core/ActiveMQSession.cpp decaf/lang/Thread.cpp decaf/lang/Thread.h</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206182527.09EAA23888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206182527-09EAA23888D1@eris-apache-org%3e</id>
<updated>2009-12-06T18:25:26Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:25:26 2009
New Revision: 887732

URL: http://svn.apache.org/viewvc?rev=887732&amp;view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-271

Fix the Threads class to work with Foreign Thread instances.  Move the close marker in session
to after the close of the session resources.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.h

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=887732&amp;r1=887731&amp;r2=887732&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
Sun Dec  6 18:25:26 2009
@@ -118,9 +118,6 @@
 
     try {
 
-        // Now indicate that this session is closed.
-        closed = true;
-
         // Stop the dispatch executor.
         stop();
 
@@ -158,6 +155,9 @@
             }
         }
 
+        // Now indicate that this session is closed.
+        closed = true;
+
         // Remove this sessions from the connection
         this-&gt;connection-&gt;removeSession( this );
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.cpp?rev=887732&amp;r1=887731&amp;r2=887732&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.cpp
Sun Dec  6 18:25:26 2009
@@ -31,6 +31,8 @@
 #include &lt;decaf/util/concurrent/TimeUnit.h&gt;
 #include &lt;decaf/util/concurrent/Mutex.h&gt;
 
+#include &lt;vector&gt;
+
 #if HAVE_PTHREAD_H
 #include &lt;pthread.h&gt;
 #endif
@@ -169,6 +171,7 @@
 namespace{
 
     Thread* mainThread = NULL;
+    std::vector&lt;Thread*&gt; foreignThreads;
 
     #ifdef HAVE_PTHREAD_H
 
@@ -224,51 +227,67 @@
 ////////////////////////////////////////////////////////////////////////////////
 void Thread::initThreading() {
 
-    mainThread = new Thread( "Main Thread" );
+    // We mark the thread where Decaf's Init routine is called from as our Main Thread.
+    mainThread = Thread::createForeignThreadInstance( "Main Thread" );
+}
 
-    mainThread-&gt;properties-&gt;state = Thread::RUNNABLE;
-    mainThread-&gt;properties-&gt;priority = Thread::NORM_PRIORITY;
-    mainThread-&gt;properties-&gt;parent = mainThread;
+////////////////////////////////////////////////////////////////////////////////
+void Thread::shutdownThreading() {
 
-    #ifdef HAVE_PTHREAD_H
+    // Clear the Main Thread instance pointer, this indicates we are Shutdown.
+    mainThread = NULL;
 
-        mainThread-&gt;properties-&gt;handle = pthread_self();
+    // Destroy any Foreign Thread Facades that were created during runtime.
+    std::vector&lt;Thread*&gt;::iterator iter = foreignThreads.begin();
+    for( ; iter != foreignThreads.end(); ++iter ) {
+        delete *iter;
+    }
+    foreignThreads.clear();
 
-        // Create the Key used to store the Current Thread data
-        pthread_key_create( &amp;currentThreadKey, NULL );
-        pthread_setspecific( currentThreadKey, mainThread );
+    #ifdef HAVE_PTHREAD_H
 
-    #else
+        // Destroy the current Thread key now, no longer needed.
+        pthread_key_delete( currentThreadKey );
 
-        mainThread-&gt;properties-&gt;handle = ::GetCurrentThread();
+    #else
 
-        // Create the key used to store the Current Thread data
-        currentThreadKey = ::TlsAlloc();
-        ::TlsSetValue( currentThreadKey, mainThread );
+        // Destroy our TLS resources before we shutdown.
+        ::TlsFree( currentThreadKey );
 
     #endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Thread::shutdownThreading() {
+Thread* Thread::createForeignThreadInstance( const std::string&amp; name ) {
+
+    Thread* foreignThread = new Thread( name );
+
+    foreignThread-&gt;properties-&gt;state = Thread::RUNNABLE;
+    foreignThread-&gt;properties-&gt;priority = Thread::NORM_PRIORITY;
+    foreignThread-&gt;properties-&gt;parent = NULL;
 
     #ifdef HAVE_PTHREAD_H
 
-        // Destroy the Main Thread instance.
-        delete mainThread;
+        foreignThread-&gt;properties-&gt;handle = pthread_self();
 
-        // Destroy the current Thread key now, no longer needed.
-        pthread_key_delete( currentThreadKey );
+        // Create the Key used to store the Current Thread data
+        pthread_key_create( &amp;currentThreadKey, NULL );
+        pthread_setspecific( currentThreadKey, foreignThread );
 
     #else
 
-        // Destroy the Main Thread instance.
-        delete mainThread;
+        foreignThread-&gt;properties-&gt;handle = ::GetCurrentThread();
 
-        // Destroy our TLS resources before we shutdown.
-        ::TlsFree( currentThreadKey );
+        // Create the key used to store the Current Thread data
+        currentThreadKey = ::TlsAlloc();
+        ::TlsSetValue( currentThreadKey, foreignThread );
 
     #endif
+
+    // Store the Facade for later deletion
+    foreignThreads.push_back( foreignThread );
+
+    return foreignThread;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -573,6 +592,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 Thread* Thread::currentThread() {
 
+    if( mainThread == NULL ) {
+        throw RuntimeException(
+            __FILE__, __LINE__, "The Decaf Threading API is in a Shutdown State." );
+    }
+
     void* result = NULL;
 
     #ifdef HAVE_PTHREAD_H
@@ -585,9 +609,11 @@
 
     #endif
 
+    // This is a foreign Thread (Not Created By Decaf) lets create a stand in Thread
+    // instance so that other threads in Decaf can join it and wait on it.
     if( result == NULL ) {
-        throw RuntimeException(
-            __FILE__, __LINE__, "Failed to find the Current Thread pointer in the TLS." );
+        result = Thread::createForeignThreadInstance(
+            std::string( "ForeignThread-" ) + Integer::toString( Thread::getId() ) );
     }
 
     return (Thread*)result;

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.h?rev=887732&amp;r1=887731&amp;r2=887732&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/decaf/lang/Thread.h
Sun Dec  6 18:25:26 2009
@@ -359,6 +359,9 @@
         // Initialize the Threads internal state
         void initialize( Runnable* task, const std::string&amp; name );
 
+        // Create a Thread Facade for threads not created by the Decaf Library.
+        static Thread* createForeignThreadInstance( const std::string&amp; name );
+
         // Called by the Decaf Runtime at startup to allow the Platform Threading
         // code to initialize any necessary Threading constructs needed to support
         // the features of this class.




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887730 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: activemq/core/ActiveMQSession.cpp decaf/lang/Thread.cpp decaf/lang/Thread.h</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206182035.BCE69238888F@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206182035-BCE69238888F@eris-apache-org%3e</id>
<updated>2009-12-06T18:20:35Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sun Dec  6 18:20:35 2009
New Revision: 887730

URL: http://svn.apache.org/viewvc?rev=887730&amp;view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-271

Fix the Threads class to work with Foreign Thread instances.  Move the close marker in session
to after the close of the session resources.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=887730&amp;r1=887729&amp;r2=887730&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Sun
Dec  6 18:20:35 2009
@@ -118,9 +118,6 @@
 
     try {
 
-        // Now indicate that this session is closed.
-        closed = true;
-
         // Stop the dispatch executor.
         stop();
 
@@ -158,6 +155,9 @@
             }
         }
 
+        // Now indicate that this session is closed.
+        closed = true;
+
         // Remove this sessions from the connection
         this-&gt;connection-&gt;removeSession( this );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp?rev=887730&amp;r1=887729&amp;r2=887730&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp Sun Dec  6 18:20:35
2009
@@ -31,6 +31,8 @@
 #include &lt;decaf/util/concurrent/TimeUnit.h&gt;
 #include &lt;decaf/util/concurrent/Mutex.h&gt;
 
+#include &lt;vector&gt;
+
 #if HAVE_PTHREAD_H
 #include &lt;pthread.h&gt;
 #endif
@@ -169,6 +171,7 @@
 namespace{
 
     Thread* mainThread = NULL;
+    std::vector&lt;Thread*&gt; foreignThreads;
 
     #ifdef HAVE_PTHREAD_H
 
@@ -224,51 +227,67 @@
 ////////////////////////////////////////////////////////////////////////////////
 void Thread::initThreading() {
 
-    mainThread = new Thread( "Main Thread" );
+    // We mark the thread where Decaf's Init routine is called from as our Main Thread.
+    mainThread = Thread::createForeignThreadInstance( "Main Thread" );
+}
 
-    mainThread-&gt;properties-&gt;state = Thread::RUNNABLE;
-    mainThread-&gt;properties-&gt;priority = Thread::NORM_PRIORITY;
-    mainThread-&gt;properties-&gt;parent = mainThread;
+////////////////////////////////////////////////////////////////////////////////
+void Thread::shutdownThreading() {
 
-    #ifdef HAVE_PTHREAD_H
+    // Clear the Main Thread instance pointer, this indicates we are Shutdown.
+    mainThread = NULL;
 
-        mainThread-&gt;properties-&gt;handle = pthread_self();
+    // Destroy any Foreign Thread Facades that were created during runtime.
+    std::vector&lt;Thread*&gt;::iterator iter = foreignThreads.begin();
+    for( ; iter != foreignThreads.end(); ++iter ) {
+        delete *iter;
+    }
+    foreignThreads.clear();
 
-        // Create the Key used to store the Current Thread data
-        pthread_key_create( &amp;currentThreadKey, NULL );
-        pthread_setspecific( currentThreadKey, mainThread );
+    #ifdef HAVE_PTHREAD_H
 
-    #else
+        // Destroy the current Thread key now, no longer needed.
+        pthread_key_delete( currentThreadKey );
 
-        mainThread-&gt;properties-&gt;handle = ::GetCurrentThread();
+    #else
 
-        // Create the key used to store the Current Thread data
-        currentThreadKey = ::TlsAlloc();
-        ::TlsSetValue( currentThreadKey, mainThread );
+        // Destroy our TLS resources before we shutdown.
+        ::TlsFree( currentThreadKey );
 
     #endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Thread::shutdownThreading() {
+Thread* Thread::createForeignThreadInstance( const std::string&amp; name ) {
+
+    Thread* foreignThread = new Thread( name );
+
+    foreignThread-&gt;properties-&gt;state = Thread::RUNNABLE;
+    foreignThread-&gt;properties-&gt;priority = Thread::NORM_PRIORITY;
+    foreignThread-&gt;properties-&gt;parent = NULL;
 
     #ifdef HAVE_PTHREAD_H
 
-        // Destroy the Main Thread instance.
-        delete mainThread;
+        foreignThread-&gt;properties-&gt;handle = pthread_self();
 
-        // Destroy the current Thread key now, no longer needed.
-        pthread_key_delete( currentThreadKey );
+        // Create the Key used to store the Current Thread data
+        pthread_key_create( &amp;currentThreadKey, NULL );
+        pthread_setspecific( currentThreadKey, foreignThread );
 
     #else
 
-        // Destroy the Main Thread instance.
-        delete mainThread;
+        foreignThread-&gt;properties-&gt;handle = ::GetCurrentThread();
 
-        // Destroy our TLS resources before we shutdown.
-        ::TlsFree( currentThreadKey );
+        // Create the key used to store the Current Thread data
+        currentThreadKey = ::TlsAlloc();
+        ::TlsSetValue( currentThreadKey, foreignThread );
 
     #endif
+
+    // Store the Facade for later deletion
+    foreignThreads.push_back( foreignThread );
+
+    return foreignThread;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -573,6 +592,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 Thread* Thread::currentThread() {
 
+    if( mainThread == NULL ) {
+        throw RuntimeException(
+            __FILE__, __LINE__, "The Decaf Threading API is in a Shutdown State." );
+    }
+
     void* result = NULL;
 
     #ifdef HAVE_PTHREAD_H
@@ -585,9 +609,11 @@
 
     #endif
 
+    // This is a foreign Thread (Not Created By Decaf) lets create a stand in Thread
+    // instance so that other threads in Decaf can join it and wait on it.
     if( result == NULL ) {
-        throw RuntimeException(
-            __FILE__, __LINE__, "Failed to find the Current Thread pointer in the TLS." );
+        result = Thread::createForeignThreadInstance(
+            std::string( "ForeignThread-" ) + Integer::toString( Thread::getId() ) );
     }
 
     return (Thread*)result;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h?rev=887730&amp;r1=887729&amp;r2=887730&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.h Sun Dec  6 18:20:35
2009
@@ -359,6 +359,9 @@
         // Initialize the Threads internal state
         void initialize( Runnable* task, const std::string&amp; name );
 
+        // Create a Thread Facade for threads not created by the Decaf Library.
+        static Thread* createForeignThreadInstance( const std::string&amp; name );
+
         // Called by the Decaf Runtime at startup to allow the Platform Threading
         // code to initialize any necessary Threading constructs needed to support
         // the features of this class.




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887719 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/java/org/apache/activemq/apollo/broker/ activemq-broker/src/test/java/org/apache/activemq/broker/ activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206172750.D6433238898B@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206172750-D6433238898B@eris-apache-org%3e</id>
<updated>2009-12-06T17:27:50Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 17:27:48 2009
New Revision: 887719

URL: http://svn.apache.org/viewvc?rev=887719&amp;view=rev
Log:
better Dispatcher config/factory setup.


Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherConfig.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
Sun Dec  6 17:27:48 2009
@@ -26,7 +26,7 @@
 import org.apache.activemq.Service;
 import org.apache.activemq.apollo.Connection;
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.DispatcherAware;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportAcceptListener;
@@ -129,7 +129,7 @@
 		// apply some default configuration to this broker instance before it's started.
 		if( dispatcher == null ) {
 			int threads = Runtime.getRuntime().availableProcessors();
-			dispatcher = DispatcherFactory.create(getName(), threads);
+			dispatcher = DispatcherConfig.create(getName(), threads);
 		}
 		
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
Sun Dec  6 17:27:48 2009
@@ -31,7 +31,7 @@
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.Period;
 import org.apache.activemq.transport.TransportFactory;
@@ -135,7 +135,7 @@
     protected abstract String getRemoteWireFormat();
 
     protected Dispatcher createDispatcher() {
-        return DispatcherFactory.create("test", asyncThreadPoolSize);
+        return DispatcherConfig.create("test", asyncThreadPoolSize);
     }
 
     @Test

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
Sun Dec  6 17:27:48 2009
@@ -27,7 +27,7 @@
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.queue.IQueue;
 
 /**
@@ -47,7 +47,7 @@
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long,
MessageDelivery&gt;&gt;();
 
     protected Dispatcher createDispatcher() {
-        return DispatcherFactory.create("test", Runtime.getRuntime().availableProcessors());
+        return DispatcherConfig.create("test", Runtime.getRuntime().availableProcessors());
     }
 
     protected int consumerStartDelay = 0;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
Sun Dec  6 17:27:48 2009
@@ -18,8 +18,6 @@
 
 import java.nio.channels.SelectableChannel;
 
-import org.apache.activemq.dispatch.internal.simple.SimpleDispatcher;
-
 /**
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
@@ -29,7 +27,7 @@
     final private static Dispatcher dispatcher = create();
 
     private static Dispatcher create() {
-        return new SimpleDispatcher("system", Runtime.getRuntime().availableProcessors());
+        return new DispatcherConfig().createDispatcher();
     }
 
     static DispatchQueue getMainQueue() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
Sun Dec  6 17:27:48 2009
@@ -21,7 +21,7 @@
 
 
 public interface Dispatcher extends Retained {
-    
+        
     public DispatchQueue getGlobalQueue();
     public DispatchQueue getGlobalQueue(DispatchPriority priority);
     
@@ -33,5 +33,6 @@
     public DispatchQueue getCurrentQueue();
 
     public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue
queue);
+
     
 }
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherConfig.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherConfig.java?rev=887719&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherConfig.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherConfig.java
Sun Dec  6 17:27:48 2009
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch;
+
+import org.apache.activemq.dispatch.internal.advanced.DispatchObserver;
+import org.apache.activemq.dispatch.internal.simple.SimpleDispatcher;
+
+/**
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+public class DispatcherConfig {
+    
+    private String label="default";
+    private int threads=Runtime.getRuntime().availableProcessors();
+    private DispatchObserver observer;
+
+    public static Dispatcher create(String name, int threads) {
+        DispatcherConfig config = new DispatcherConfig();
+        config.label=name;
+        config.threads=threads;
+        return config.createDispatcher();
+    }
+
+    public Dispatcher createDispatcher() {
+        return new SimpleDispatcher(this);
+    }
+    
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String name) {
+        this.label = name;
+    }
+
+    public int getThreads() {
+        return threads;
+    }
+
+    public void setThreads(int threads) {
+        this.threads = threads;
+    }
+
+    public DispatchObserver getObserver() {
+        return observer;
+    }
+
+    public void setObserver(DispatchObserver observer) {
+        this.observer = observer;
+    }
+    
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
Sun Dec  6 17:27:48 2009
@@ -28,6 +28,7 @@
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSource;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
@@ -50,15 +51,13 @@
 
     protected LoadBalancer loadBalancer;
 
-    public AdvancedDispatcher(int size, int numPriorities) {
-        this.size = size;
-        this.numPriorities = numPriorities;
-        
+    public AdvancedDispatcher(DispatcherConfig config) {
+        this.size = config.getThreads();
+        this.numPriorities = 3;
         globalQueues = new GlobalDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
             globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i]);
         }
-        
         loadBalancer = new SimpleLoadBalancer();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
Sun Dec  6 17:27:48 2009
@@ -26,6 +26,7 @@
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchSource;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
@@ -52,13 +53,13 @@
     private final String label;
     TimerThread timerThread;
     
-    public SimpleDispatcher(String label, int size) {
-        this.label = label;
+    public SimpleDispatcher(DispatcherConfig config) {
+        this.label = config.getLabel();
         globalQueues = new GlobalDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
             globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i]
);
         }
-        dispatchers = new DispatcherThread[size];
+        dispatchers = new DispatcherThread[config.getThreads()];
     }
 
     public DispatchQueue getMainQueue() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
Sun Dec  6 17:27:48 2009
@@ -14,6 +14,7 @@
 
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatcher;
 
 
@@ -45,7 +46,7 @@
     
     public void testActorInvocation() throws Exception
     {
-        Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
+        Dispatcher advancedSystem = new AdvancedDispatcher(new DispatcherConfig());
         advancedSystem.retain();
         
         DispatchQueue queue = advancedSystem.createSerialQueue("test");

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
Sun Dec  6 17:27:48 2009
@@ -33,7 +33,7 @@
 public class DispatchSystemTest {
 
     public static void main(String[] args) throws Exception {
-        Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
+        Dispatcher advancedSystem = new AdvancedDispatcher(new DispatcherConfig());
         advancedSystem.retain();
         benchmark("advanced global queue", advancedSystem, advancedSystem.getGlobalQueue(DEFAULT));
         benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test"));
@@ -43,7 +43,7 @@
         advancedSystem.release();
         latch.await();
 
-        Dispatcher simpleSystem = new SimpleDispatcher("test", Runtime.getRuntime().availableProcessors());
+        Dispatcher simpleSystem = new SimpleDispatcher(new DispatcherConfig());
         simpleSystem.retain();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
Sun Dec  6 17:27:48 2009
@@ -19,6 +19,7 @@
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatcherConfig;
 
 
 import static java.lang.String.*;
@@ -30,7 +31,7 @@
 public class DispatcherPoolTest {
     
     public static void main(String[] args) throws Exception {
-        AdvancedDispatcher dispatcher = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
+        AdvancedDispatcher dispatcher = new AdvancedDispatcher(new DispatcherConfig());
         dispatcher.retain();
         
         // warm the JIT up..

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
Sun Dec  6 17:27:48 2009
@@ -23,7 +23,7 @@
 
 import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 
 @XmlRootElement(name="dispatcher")
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -40,7 +40,7 @@
 		if( name == null ) {
 			name = "broker";
 		}
-		return DispatcherFactory.create(name, threads);
+		return DispatcherConfig.create(name, threads);
 	}
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
Sun Dec  6 17:27:48 2009
@@ -41,7 +41,7 @@
 import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -83,7 +83,7 @@
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long,
MessageDelivery&gt;&gt;();
 
     protected Dispatcher createDispatcher() {
-        return DispatcherFactory.create("pref-test", THREAD_POOL_SIZE);
+        return DispatcherConfig.create("pref-test", THREAD_POOL_SIZE);
     }
 
     protected int consumerStartDelay = 0;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
Sun Dec  6 17:27:48 2009
@@ -22,7 +22,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.dispatch.DispatcherAware;
 import org.apache.activemq.flow.IFlowSink;
 import org.apache.activemq.flow.Commands.Destination;
@@ -189,7 +189,7 @@
 
     protected void createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = DispatcherFactory.create("mock-broker", Runtime.getRuntime().availableProcessors());
+            dispatcher = DispatcherConfig.create("mock-broker", Runtime.getRuntime().availableProcessors());
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
Sun Dec  6 17:27:48 2009
@@ -21,7 +21,7 @@
 import junit.framework.TestCase;
 
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -95,7 +95,7 @@
     }
 
     protected Dispatcher createDispatcher(String name) {
-        return DispatcherFactory.create("test", threadsPerDispatcher);
+        return DispatcherConfig.create("test", threadsPerDispatcher);
     }
 
     public void test_1_1_0() throws Exception {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java?rev=887719&amp;r1=887718&amp;r2=887719&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
Sun Dec  6 17:27:48 2009
@@ -8,7 +8,7 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherConfig;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -280,7 +280,7 @@
 
     protected Dispatcher createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = DispatcherFactory.create("client", threadsPerDispatcher);
+            dispatcher = DispatcherConfig.create("client", threadsPerDispatcher);
         }
         return dispatcher;
     }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887707 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/java/org/apache/activemq/apollo/broker/ activemq-broker/src/test/java/org/apache/activemq/broker/ activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206162837.8D51923888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206162837-8D51923888D1@eris-apache-org%3e</id>
<updated>2009-12-06T16:28:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 16:28:35 2009
New Revision: 887707

URL: http://svn.apache.org/viewvc?rev=887707&amp;view=rev
Log:
Dispatcher is now using the Retained interface to manage it's lifecycle.


Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
Sun Dec  6 16:28:35 2009
@@ -138,7 +138,7 @@
     		throw new IllegalStateException("Can only start a broker that is in the "+State.CONFIGURATION
+" state.  Broker was "+state.get());
     	}
     	try {
-		    dispatcher.start();
+		    dispatcher.retain();
 
 	    	synchronized(virtualHosts) {
 			    for (VirtualHost virtualHost : virtualHosts.values()) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
Sun Dec  6 16:28:35 2009
@@ -97,7 +97,7 @@
     @Before
     public void setUp() throws Exception {
         dispatcher = createDispatcher();
-        dispatcher.start();
+        dispatcher.retain();
         
         if (tcp) {
             sendBrokerBindURI = "tcp://localhost:10000?wireFormat=" + getBrokerWireFormat();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
Sun Dec  6 16:28:35 2009
@@ -64,7 +64,7 @@
     
     protected void startServices() throws Exception {
         dispatcher = createDispatcher();
-        dispatcher.start();
+        dispatcher.retain();
         database = new BrokerDatabase(createStore());
         database.setDispatcher(dispatcher);
         database.start();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
Sun Dec  6 16:28:35 2009
@@ -22,9 +22,6 @@
 
 public interface Dispatcher extends Retained {
     
-    public void start();
-    public void shutdown(Runnable onShutdown);
-    
     public DispatchQueue getGlobalQueue();
     public DispatchQueue getGlobalQueue(DispatchPriority priority);
     

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
Sun Dec  6 16:28:35 2009
@@ -24,6 +24,6 @@
     
     public void retain();
     public void release();
-    public void setShutdownHandler(Runnable shutdownHandler);
+    public void addShutdownWatcher(Runnable shutdownWatcher);
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
Sun Dec  6 16:28:35 2009
@@ -1,28 +1,49 @@
 package org.apache.activemq.dispatch.internal;
 
+import java.util.ArrayList;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
 
 public class BaseRetained {
     
-    final protected AtomicInteger reatinCounter = new AtomicInteger(1);
-    final protected AtomicReference&lt;Runnable&gt; shutdownHandler = new AtomicReference&lt;Runnable&gt;();
+    final protected AtomicInteger reatinCounter = new AtomicInteger(0);
+    final protected ArrayList&lt;Runnable&gt; shutdownHandlers = new ArrayList&lt;Runnable&gt;();
 
-    public void setShutdownHandler(Runnable finalizer) {
-        this.shutdownHandler.set(finalizer);
+    public void addShutdownWatcher(Runnable shutdownHandler) {
+        synchronized(shutdownHandlers) {
+            shutdownHandlers.add(shutdownHandler);
+        }
     }
     
     public void retain() {
-        int prev = reatinCounter.getAndIncrement();
-        assert prev!=0;
+        if( reatinCounter.getAndIncrement() == 0 ) {
+            startup();
+        }
     }
 
     public void release() {
         if( reatinCounter.decrementAndGet()==0 ) {
-            Runnable value = shutdownHandler.getAndSet(null);
-            if( value!=null ) {
-                value.run();
-            }
+            shutdown();
+        }
+    }
+
+    /**
+     * Subclasses should override if they want to do some startup processing. 
+     */
+    protected void startup() {
+    }
+
+
+    /**
+     * Subclasses should override if they want to do clean up. 
+     */
+    protected void shutdown() {
+        ArrayList&lt;Runnable&gt; copy;
+        synchronized(shutdownHandlers) {
+            copy = new ArrayList&lt;Runnable&gt;(shutdownHandlers);
+            shutdownHandlers.clear();
+        }
+        for (Runnable runnable : copy) {
+            runnable.run();
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
Sun Dec  6 16:28:35 2009
@@ -22,12 +22,6 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.Dispatcher;
-import org.apache.activemq.dispatch.DispatcherFactory;
-
-import static org.apache.activemq.dispatch.DispatcherFactory.*;
-
-import static org.apache.activemq.dispatch.DispatcherFactory.*;
 
 /**
  * 
@@ -44,6 +38,7 @@
 
     public SerialDispatchQueue(String label) {
         this.label = label;
+        retain();
     }
 
     public String getLabel() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
Sun Dec  6 16:28:35 2009
@@ -34,7 +34,7 @@
 import static org.apache.activemq.dispatch.DispatchPriority.*;
 
 
-public class AdvancedDispatcher extends BaseRetained implements Dispatcher {
+final public class AdvancedDispatcher extends BaseRetained implements Dispatcher {
 
     public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
 
@@ -44,10 +44,6 @@
 
     private final ArrayList&lt;DispatcherThread&gt; dispatchers = new ArrayList&lt;DispatcherThread&gt;();
 
-    final AtomicInteger startCounter = new AtomicInteger();
-//    final AtomicBoolean started = new AtomicBoolean();
-//    final AtomicBoolean shutdown = new AtomicBoolean();
-
     private int roundRobinCounter = 0;
     private int size;
     private final int numPriorities;
@@ -67,54 +63,32 @@
     }
 
     /**
-     * Subclasses should implement this to return a new dispatcher.
-     * 
-     * @param name
-     *            The name to assign the dispatcher.
-     * @param pool
-     *            The pool.
-     * @return The new dispathcer.
-     */
-    protected DispatcherThread createDispatcher(String name) throws Exception {
-        return new DispatcherThread(this, name, numPriorities);
-    }
-
-    /**
      * @see org.apache.activemq.dispatch.internal.advanced.DispatcherThread#start()
      */
-    public synchronized final void start()  {
-        if( startCounter.getAndIncrement()==0 ) {
-            // Create all the workers.
-            try {
-                loadBalancer.start();
-                for (int i = 0; i &lt; size; i++) {
-                    DispatcherThread dispatacher = createDispatcher("dispatcher -" + (i +
1));
-                    dispatchers.add(dispatacher);
-                    dispatacher.start();
-                }
-            } catch (Exception e) {
-                shutdown();
-            }
+    protected void startup()  {
+        loadBalancer.start();
+        for (int i = 0; i &lt; size; i++) {
+            DispatcherThread dispatacher = new DispatcherThread(this, ("dispatcher -" + (i
+ 1)), numPriorities);
+            dispatchers.add(dispatacher);
+            dispatacher.start();
         }
     }
-
-    public final void shutdown() {
-        shutdown(null);
-    }
     
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.activemq.dispatch.IDispatcher#shutdown()
-     */
-    public final void shutdown(Runnable onShutdown) {
-        if( startCounter.decrementAndGet()==0 ) {
-            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.size());
-            for (DispatcherThread d : new ArrayList&lt;DispatcherThread&gt;(dispatchers))
{
-                d.shutdown(shutdownCountDown, onShutdown);
+    protected void shutdown() {
+        Runnable countDown = new Runnable() {
+            AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.size());
+            public void run() {
+                if( shutdownCountDown.decrementAndGet()==0 ) {
+                    // Notify any registered shutdown watchers.
+                    AdvancedDispatcher.super.shutdown();
+                }
             }
-            loadBalancer.stop();
+        };
+
+        for (DispatcherThread d : new ArrayList&lt;DispatcherThread&gt;(dispatchers)) {
+            d.shutdown(countDown);
         }
+        loadBalancer.stop();
     }
 
     /**

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
Sun Dec  6 16:28:35 2009
@@ -22,7 +22,6 @@
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.util.Mapper;
@@ -30,8 +29,6 @@
 import org.apache.activemq.util.TimerHeap;
 import org.apache.activemq.util.list.LinkedNodeList;
 
-import static org.apache.activemq.dispatch.DispatcherFactory.*;
-
 public class DispatcherThread implements Runnable {
 
     static public final ThreadLocal&lt;DispatcherThread&gt; CURRENT = new ThreadLocal&lt;DispatcherThread&gt;();
@@ -124,27 +121,14 @@
             thread.start();
         }
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.activemq.dispatch.IDispatcher#shutdown()
-     */
-    public void shutdown() throws InterruptedException {
-        Thread joinThread = shutdown(new AtomicInteger(1), null);
-        if (joinThread != null) {
-            // thread.interrupt();
-            joinThread.join();
-        }
-    }
     
-    public Thread shutdown(final AtomicInteger shutdownCountDown, final Runnable onShutdown)
{
+    public Thread shutdown(final Runnable onShutdown) {
         synchronized (this) {
             if (thread != null) {
                 dispatchInternal(new Runnable() {
                     public void run() {
                         running = false;
-                        if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null)
{
+                        if( onShutdown!=null ) {
                             onShutdown.run();
                         }
                     }
@@ -153,7 +137,7 @@
                 thread = null;
                 return rc;
             } else {
-                if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null) {
+                if( onShutdown!=null) {
                     onShutdown.run();
                 }
             }
@@ -268,7 +252,7 @@
         foreignPermits.release();
     }
 
-    protected final void onForeignUpdate(DispatchContext context) {
+    protected void onForeignUpdate(DispatchContext context) {
         synchronized (foreignQueue) {
 
             ForeignEvent fe = context.updateEvent[foreignToggle];
@@ -281,7 +265,7 @@
         }
     }
 
-    protected final boolean removeDispatchContext(DispatchContext context) {
+    protected boolean removeDispatchContext(DispatchContext context) {
         synchronized (foreignQueue) {
 
             if (context.updateEvent[0].isLinked()) {
@@ -304,7 +288,7 @@
         return false;
     }
 
-    protected final boolean takeOwnership(DispatchContext context) {
+    protected boolean takeOwnership(DispatchContext context) {
         synchronized (this) {
             if (running) {
                 contexts.add(context);
@@ -316,13 +300,13 @@
     }
 
     //Special dispatch method that allow high priority dispatch:
-    private final void dispatchInternal(Runnable runnable, int priority) {
+    private void dispatchInternal(Runnable runnable, int priority) {
         DispatchContext context = new DispatchContext(this, runnable, false, name);
         context.priority = priority;
         context.requestDispatch();
     }
 
-    public final void dispatch(Runnable runnable, int priority) {
+    public void dispatch(Runnable runnable, int priority) {
         DispatchContext context = new DispatchContext(this, runnable, false, name);
         context.updatePriority(priority);
         context.requestDispatch();
@@ -343,11 +327,11 @@
         };
     }
 
-    public void execute(final Runnable runnable) {
+    public void execute(Runnable runnable) {
         dispatch(runnable, 0);
     }
     
-    public void execute(final Runnable runnable, int prio) {
+    public void execute(Runnable runnable, int prio) {
         dispatch(runnable, prio);
     }
 
@@ -368,7 +352,7 @@
         }
     }
     
-    final void add(ForeignEvent event) {
+    void add(ForeignEvent event) {
         synchronized (foreignQueue) {
             if (!event.isLinked()) {
                 foreignQueue[foreignToggle].addLast(event);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
Sun Dec  6 16:28:35 2009
@@ -78,7 +78,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setShutdownHandler(Runnable finalizer) {
+    public void addShutdownWatcher(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
Sun Dec  6 16:28:35 2009
@@ -78,7 +78,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setShutdownHandler(Runnable finalizer) {
+    public void addShutdownWatcher(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
Sun Dec  6 16:28:35 2009
@@ -85,7 +85,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setShutdownHandler(Runnable finalizer) {
+    public void addShutdownWatcher(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
Sun Dec  6 16:28:35 2009
@@ -38,7 +38,7 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public class SimpleDispatcher extends BaseRetained implements Dispatcher {
+final public class SimpleDispatcher extends BaseRetained implements Dispatcher {
         
     public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
 
@@ -49,7 +49,6 @@
     
     final ConcurrentLinkedQueue&lt;DispatcherThread&gt; waitingDispatchers = new ConcurrentLinkedQueue&lt;DispatcherThread&gt;();
     final AtomicInteger waitingDispatcherCount = new AtomicInteger();
-    final AtomicInteger startCounter = new AtomicInteger();
     private final String label;
     TimerThread timerThread;
     
@@ -109,35 +108,32 @@
         }
     }
 
-    public void start() {
-        if( startCounter.getAndIncrement()==0 ) {
-            for (int i = 0; i &lt; dispatchers.length; i++) {
-                dispatchers[i] = new DispatcherThread(this, i);
-                dispatchers[i].start();
-            }
-            timerThread = new TimerThread(this);
-            timerThread.start();
+    protected void startup() {
+        for (int i = 0; i &lt; dispatchers.length; i++) {
+            dispatchers[i] = new DispatcherThread(this, i);
+            dispatchers[i].start();
         }
+        timerThread = new TimerThread(this);
+        timerThread.start();
     }
 
-    public void shutdown(final Runnable onShutdown) {
-        if( startCounter.decrementAndGet()==0 ) {
-            
-            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.length+1);
-            Runnable wrapper = new Runnable() {
-                public void run() {
-                    if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null)
{
-                        onShutdown.run();
-                    }
-                    throw new DispatcherThread.Shutdown();
+    public void shutdown() {
+        
+        Runnable countDown = new Runnable() {
+            AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.length+1);
+            public void run() {
+                if( shutdownCountDown.decrementAndGet()==0 ) {
+                    // Notify any registered shutdown watchers.
+                    SimpleDispatcher.super.shutdown();
                 }
-            };
-
-            timerThread.shutdown(wrapper);
-            for (int i = 0; i &lt; dispatchers.length; i++) {
-                ThreadDispatchQueue queue = dispatchers[i].threadQueues[LOW.ordinal()];
-                queue.runnables.add(wrapper);
+                throw new DispatcherThread.Shutdown();
             }
+        };
+
+        timerThread.shutdown(countDown);
+        for (int i = 0; i &lt; dispatchers.length; i++) {
+            ThreadDispatchQueue queue = dispatchers[i].threadQueues[LOW.ordinal()];
+            queue.runnables.add(countDown);
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
Sun Dec  6 16:28:35 2009
@@ -112,7 +112,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setShutdownHandler(Runnable finalizer) {
+    public void addShutdownWatcher(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
Sun Dec  6 16:28:35 2009
@@ -46,7 +46,7 @@
     public void testActorInvocation() throws Exception
     {
         Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
-        advancedSystem.start();
+        advancedSystem.retain();
         
         DispatchQueue queue = advancedSystem.createSerialQueue("test");
         ActorTestObject testObject = Actor.create(new ActorTestObject(), queue);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
Sun Dec  6 16:28:35 2009
@@ -34,22 +34,24 @@
 
     public static void main(String[] args) throws Exception {
         Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
-        advancedSystem.start();
+        advancedSystem.retain();
         benchmark("advanced global queue", advancedSystem, advancedSystem.getGlobalQueue(DEFAULT));
         benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test"));
 
         RunnableCountDownLatch latch = new RunnableCountDownLatch(1);
-        advancedSystem.shutdown(latch);
+        advancedSystem.addShutdownWatcher(latch);
+        advancedSystem.release();
         latch.await();
 
         Dispatcher simpleSystem = new SimpleDispatcher("test", Runtime.getRuntime().availableProcessors());
-        simpleSystem.start();
+        simpleSystem.retain();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));
         benchmark("simple private serial queue", simpleSystem, simpleSystem.createSerialQueue("test"));
 
         latch = new RunnableCountDownLatch(1);
-        simpleSystem.shutdown(latch);
+        advancedSystem.addShutdownWatcher(latch);
+        advancedSystem.release();
         latch.await();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
Sun Dec  6 16:28:35 2009
@@ -30,21 +30,21 @@
 public class DispatcherPoolTest {
     
     public static void main(String[] args) throws Exception {
-        AdvancedDispatcher pooledDispatcher = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
-        pooledDispatcher.start();
+        AdvancedDispatcher dispatcher = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(),
3);
+        dispatcher.retain();
         
         // warm the JIT up..
-        benchmarkWork(pooledDispatcher, 100000);
+        benchmarkWork(dispatcher, 100000);
         
         int iterations = 1000*1000*20;
         long start = System.nanoTime();
-        benchmarkWork(pooledDispatcher, iterations);
+        benchmarkWork(dispatcher, iterations);
         long end = System.nanoTime();
         
         double durationMS = 1.0d*(end-start)/1000000d;
         double rate = 1000d * iterations / durationMS;
         
-        pooledDispatcher.shutdown();
+        dispatcher.release();
         System.out.println(format("duration: %,.3f ms, rate: %,.2f executions/sec", durationMS,
rate));
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
Sun Dec  6 16:28:35 2009
@@ -90,7 +90,7 @@
 
     protected void startServices() throws Exception {
         dispatcher = createDispatcher();
-        dispatcher.start();
+        dispatcher.retain();
         database = new BrokerDatabase(createStore());
         database.setDispatcher(dispatcher);
         if( TEST_MAX_STORE_LATENCY ) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
Sun Dec  6 16:28:35 2009
@@ -88,7 +88,7 @@
         }
         
         stop();
-        dispatchQueue.setShutdownHandler(onShutdown);
+        dispatchQueue.addShutdownWatcher(onShutdown);
         dispatchQueue.release();
         dispatchQueue = null;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
Sun Dec  6 16:28:35 2009
@@ -210,7 +210,7 @@
         broker.setName("Broker");
         broker.createDispatcher();
         try {
-            broker.getDispatcher().start();
+            broker.getDispatcher().retain();
             broker.startServices();
         } catch (Exception e) {
             // TODO Auto-generated catch block

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
Sun Dec  6 16:28:35 2009
@@ -255,7 +255,7 @@
     private void createConnections(int destCount) throws Exception {
 
         dispatcher = createDispatcher("BrokerDispatcher");
-        dispatcher.start();
+        dispatcher.retain();
 
         if (multibroker) {
             sendBroker = createBroker("SendBroker", sendBrokerURI);
@@ -287,7 +287,7 @@
         Dispatcher clientDispatcher = null;
         if (SEPARATE_CLIENT_DISPATCHER) {
             clientDispatcher = createDispatcher("ClientDispatcher");
-            clientDispatcher.start();
+            clientDispatcher.retain();
         } else {
             clientDispatcher = dispatcher;
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
Sun Dec  6 16:28:35 2009
@@ -219,7 +219,7 @@
     }
 
     public void runTest() throws Exception {
-        getDispatcher().start();
+        getDispatcher().retain();
 
         // Start 'em up.
         startServices();
@@ -304,7 +304,7 @@
         System.out.println(IntrospectionSupport.toString(test));
         try
         {
-            test.getDispatcher().start();
+            test.getDispatcher().retain();
             test.createConnections();
             test.runTest();
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java?rev=887707&amp;r1=887706&amp;r2=887707&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
Sun Dec  6 16:28:35 2009
@@ -71,7 +71,7 @@
         	pipe.write(EOF_TOKEN);
             if (dispatchQueue != null) {
                 RunnableCountDownLatch done = new RunnableCountDownLatch(1);
-                dispatchQueue.setShutdownHandler(done);
+                dispatchQueue.addShutdownWatcher(done);
                 dispatchQueue.release();
                 done.await();
             } else {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887687 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/java/org/apache/activemq/apollo/ activemq-broker/src/main/java/org/apache/activemq/apollo/broker/ activemq-broker/src/test/java/org/apache/activemq/broker/ activ...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206144037.6AE6C23888C2@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206144037-6AE6C23888C2@eris-apache-org%3e</id>
<updated>2009-12-06T14:40:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 14:40:34 2009
New Revision: 887687

URL: http://svn.apache.org/viewvc?rev=887687&amp;view=rev
Log:
Another round of renaming

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java Sun Dec  6 14:40:34 2009
@@ -25,7 +25,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.Service;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.transport.DispatchableTransport;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportListener;
@@ -42,7 +42,7 @@
     protected int inputResumeThreshold = 512 * 1024;
     protected boolean useAsyncWriteThread = true;
 
-    private Dispatch dispatcher;
+    private Dispatcher dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean();
     private ExecutorService blockingWriter;
     private ExceptionListener exceptionListener;
@@ -170,11 +170,11 @@
         this.priorityLevels = priorityLevels;
     }
 
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java Sun Dec  6 14:40:34 2009
@@ -25,9 +25,9 @@
 
 import org.apache.activemq.Service;
 import org.apache.activemq.apollo.Connection;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
-import org.apache.activemq.dispatch.DispatchAware;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherAware;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportAcceptListener;
 import org.apache.activemq.transport.TransportServer;
@@ -51,7 +51,7 @@
 
     private final LinkedHashMap&lt;AsciiBuffer, VirtualHost&gt; virtualHosts = new LinkedHashMap&lt;AsciiBuffer, VirtualHost&gt;();
     private VirtualHost defaultVirtualHost;
-    private Dispatch dispatcher;
+    private Dispatcher dispatcher;
     private File dataDirectory;
 
     private final class BrokerAcceptListener implements TransportAcceptListener {
@@ -129,7 +129,7 @@
 		// apply some default configuration to this broker instance before it's started.
 		if( dispatcher == null ) {
 			int threads = Runtime.getRuntime().availableProcessors();
-			dispatcher = DispatchFactory.create(getName(), threads);
+			dispatcher = DispatcherFactory.create(getName(), threads);
 		}
 		
 
@@ -376,10 +376,10 @@
     // /////////////////////////////////////////////////////////////////
     // Property Accessors
     // /////////////////////////////////////////////////////////////////
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
     	assertInConfigurationState();
         this.dispatcher = dispatcher;
     }
@@ -417,8 +417,8 @@
     
 	private void startTransportServer(TransportServer server) throws Exception {
 		server.setAcceptListener(new BrokerAcceptListener());
-		if (server instanceof DispatchAware ) {
-			((DispatchAware) server).setDispatcher(dispatcher);
+		if (server instanceof DispatcherAware ) {
+			((DispatcherAware) server).setDispatcher(dispatcher);
 		}
 		server.start();
 	}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java Sun Dec  6 14:40:34 2009
@@ -40,8 +40,8 @@
 import org.apache.activemq.broker.store.Store.QueueQueryResult;
 import org.apache.activemq.broker.store.Store.QueueRecord;
 import org.apache.activemq.broker.store.Store.Session;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchAware;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherAware;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -60,7 +60,7 @@
 import org.apache.activemq.util.list.LinkedNode;
 import org.apache.activemq.util.list.LinkedNodeList;
 
-public class BrokerDatabase extends AbstractLimitedFlowResource&lt;BrokerDatabase.OperationBase&lt;?&gt;&gt; implements Service, DispatchAware {
+public class BrokerDatabase extends AbstractLimitedFlowResource&lt;BrokerDatabase.OperationBase&lt;?&gt;&gt; implements Service, DispatcherAware {
 
     private static final boolean DEBUG = false;
 
@@ -71,7 +71,7 @@
     private final FlowController&lt;OperationBase&lt;?&gt;&gt; storeController;
     private final int FLUSH_QUEUE_SIZE = 10000 * 1024;
 
-    private Dispatch dispatcher;
+    private Dispatcher dispatcher;
     private Thread flushThread;
     private AtomicBoolean running = new AtomicBoolean(false);
     private DatabaseListener listener;
@@ -1288,11 +1288,11 @@
         return store.allocateStoreTracking();
     }
 
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java Sun Dec  6 14:40:34 2009
@@ -24,7 +24,7 @@
 
 import org.apache.activemq.broker.store.Store.MessageRecord;
 import org.apache.activemq.broker.store.Store.QueueQueryResult;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.ISourceController;
 import org.apache.activemq.flow.PrioritySizeLimiter;
 import org.apache.activemq.flow.SizeLimiter;
@@ -52,7 +52,7 @@
     private static final boolean USE_PRIORITY_QUEUES = true;
 
     private BrokerDatabase database;
-    private Dispatch dispatcher;
+    private Dispatcher dispatcher;
 
     private static HashMap&lt;String, ProtocolHandler&gt; protocolHandlers = new HashMap&lt;String, ProtocolHandler&gt;();
     private static final BrokerDatabase.MessageRecordMarshaller&lt;MessageDelivery&gt; MESSAGE_MARSHALLER = new BrokerDatabase.MessageRecordMarshaller&lt;MessageDelivery&gt;() {
@@ -226,7 +226,7 @@
         this.database = database;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java Sun Dec  6 14:40:34 2009
@@ -30,8 +30,8 @@
 import org.apache.activemq.apollo.broker.Router;
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.Period;
 import org.apache.activemq.transport.TransportFactory;
@@ -87,7 +87,7 @@
     protected Broker sendBroker;
     protected Broker rcvBroker;
     protected ArrayList&lt;Broker&gt; brokers = new ArrayList&lt;Broker&gt;();
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
     protected final AtomicLong msgIdGenerator = new AtomicLong();
     protected final AtomicBoolean stopping = new AtomicBoolean();
 
@@ -134,8 +134,8 @@
 
     protected abstract String getRemoteWireFormat();
 
-    protected Dispatch createDispatcher() {
-        return DispatchFactory.create("test", asyncThreadPoolSize);
+    protected Dispatcher createDispatcher() {
+        return DispatcherFactory.create("test", asyncThreadPoolSize);
     }
 
     @Test

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java Sun Dec  6 14:40:34 2009
@@ -26,8 +26,8 @@
 import org.apache.activemq.apollo.broker.MessageDelivery;
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 import org.apache.activemq.queue.IQueue;
 
 /**
@@ -37,7 +37,7 @@
 public class SharedQueueTest extends TestCase {
 
 
-    Dispatch dispatcher;
+    Dispatcher dispatcher;
     BrokerDatabase database;
     BrokerQueueStore queueStore;
     private static final boolean USE_KAHA_DB = true;
@@ -46,8 +46,8 @@
 
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt;();
 
-    protected Dispatch createDispatcher() {
-        return DispatchFactory.create("test", Runtime.getRuntime().availableProcessors());
+    protected Dispatcher createDispatcher() {
+        return DispatcherFactory.create("test", Runtime.getRuntime().availableProcessors());
     }
 
     protected int consumerStartDelay = 0;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java Sun Dec  6 14:40:34 2009
@@ -18,7 +18,7 @@
 
 import java.nio.channels.SelectableChannel;
 
-import org.apache.activemq.dispatch.internal.simple.SimpleDispatchSPI;
+import org.apache.activemq.dispatch.internal.simple.SimpleDispatcher;
 
 /**
  * 
@@ -26,34 +26,34 @@
  */
 public class DispatchSystem {
 
-    final private static Dispatch spi = create();
+    final private static Dispatcher dispatcher = create();
 
-    private static Dispatch create() {
-        return new SimpleDispatchSPI("system", Runtime.getRuntime().availableProcessors());
+    private static Dispatcher create() {
+        return new SimpleDispatcher("system", Runtime.getRuntime().availableProcessors());
     }
 
     static DispatchQueue getMainQueue() {
-        return spi.getMainQueue();
+        return dispatcher.getMainQueue();
     }
     
     static public DispatchQueue getGlobalQueue() {
-        return spi.getGlobalQueue();
+        return dispatcher.getGlobalQueue();
     }
     
     static public DispatchQueue getGlobalQueue(DispatchPriority priority) {
-        return spi.getGlobalQueue(priority);
+        return dispatcher.getGlobalQueue(priority);
     }
     
     static DispatchQueue getSerialQueue(String label) {
-        return spi.createSerialQueue(label);
+        return dispatcher.createSerialQueue(label);
     }
     
     static void dispatchMain() {
-        spi.dispatchMain();
+        dispatcher.dispatchMain();
     }
 
     static DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue) {
-        return spi.createSource(channel, interestOps, queue);
+        return dispatcher.createSource(channel, interestOps, queue);
     }
 
 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatcher.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+import java.nio.channels.SelectableChannel;
+
+
+public interface Dispatcher extends Retained {
+    
+    public void start();
+    public void shutdown(Runnable onShutdown);
+    
+    public DispatchQueue getGlobalQueue();
+    public DispatchQueue getGlobalQueue(DispatchPriority priority);
+    
+    public DispatchQueue createSerialQueue(String label);
+    
+    public DispatchQueue getMainQueue();
+    public void dispatchMain();
+    
+    public DispatchQueue getCurrentQueue();
+
+    public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue);
+    
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,14 @@
+package org.apache.activemq.dispatch;
+
+
+/**
+ * Handy interface to signal classes which would like an Dispatcher instance
+ * injected into them.
+ *  
+ * @author chirino
+ */
+public interface DispatcherAware {
+
+	public void setDispatcher(Dispatcher dispatcher);
+	
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherFactory.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch;
+
+import org.apache.activemq.dispatch.internal.simple.SimpleDispatcher;
+
+/**
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+public class DispatcherFactory {
+
+    public static Dispatcher create() {
+        return create("system", Runtime.getRuntime().availableProcessors());
+    }
+
+    public static Dispatcher create(String name, int threads) {
+        return new SimpleDispatcher(name, threads);
+    }
+    
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherObserver.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+import org.apache.activemq.dispatch.internal.simple.DispatcherThread;
+
+public interface DispatcherObserver {
+    
+    public void onThreadCreate(DispatcherThread thread);
+    public void onThreadDestroy(DispatcherThread thread);
+
+    public void onQueueCreate(DispatchQueue queue);
+    public void onQueueDestroy(DispatchQueue queue);
+    
+    public void onSourceCreate(DispatchSource source);
+    public void onSourceDestroy(DispatchSource source);
+    
+    public void onDispatchRequest(DispatchQueue target, Runnable request);
+
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java Sun Dec  6 14:40:34 2009
@@ -22,12 +22,12 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 
-import static org.apache.activemq.dispatch.DispatchFactory.*;
+import static org.apache.activemq.dispatch.DispatcherFactory.*;
 
-import static org.apache.activemq.dispatch.DispatchFactory.*;
+import static org.apache.activemq.dispatch.DispatcherFactory.*;
 
 /**
  * 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatcher.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,231 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch.internal.advanced;
+
+import java.nio.channels.SelectableChannel;
+import java.util.ArrayList;
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchSource;
+import org.apache.activemq.dispatch.internal.BaseRetained;
+import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
+
+import static org.apache.activemq.dispatch.DispatchPriority.*;
+
+
+public class AdvancedDispatcher extends BaseRetained implements Dispatcher {
+
+    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
+
+    final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
+    final GlobalDispatchQueue globalQueues[];
+    final AtomicLong globalQueuedRunnables = new AtomicLong();
+
+    private final ArrayList&lt;DispatcherThread&gt; dispatchers = new ArrayList&lt;DispatcherThread&gt;();
+
+    final AtomicInteger startCounter = new AtomicInteger();
+//    final AtomicBoolean started = new AtomicBoolean();
+//    final AtomicBoolean shutdown = new AtomicBoolean();
+
+    private int roundRobinCounter = 0;
+    private int size;
+    private final int numPriorities;
+
+    protected LoadBalancer loadBalancer;
+
+    public AdvancedDispatcher(int size, int numPriorities) {
+        this.size = size;
+        this.numPriorities = numPriorities;
+        
+        globalQueues = new GlobalDispatchQueue[3];
+        for (int i = 0; i &lt; 3; i++) {
+            globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i]);
+        }
+        
+        loadBalancer = new SimpleLoadBalancer();
+    }
+
+    /**
+     * Subclasses should implement this to return a new dispatcher.
+     * 
+     * @param name
+     *            The name to assign the dispatcher.
+     * @param pool
+     *            The pool.
+     * @return The new dispathcer.
+     */
+    protected DispatcherThread createDispatcher(String name) throws Exception {
+        return new DispatcherThread(this, name, numPriorities);
+    }
+
+    /**
+     * @see org.apache.activemq.dispatch.internal.advanced.DispatcherThread#start()
+     */
+    public synchronized final void start()  {
+        if( startCounter.getAndIncrement()==0 ) {
+            // Create all the workers.
+            try {
+                loadBalancer.start();
+                for (int i = 0; i &lt; size; i++) {
+                    DispatcherThread dispatacher = createDispatcher("dispatcher -" + (i + 1));
+                    dispatchers.add(dispatacher);
+                    dispatacher.start();
+                }
+            } catch (Exception e) {
+                shutdown();
+            }
+        }
+    }
+
+    public final void shutdown() {
+        shutdown(null);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.activemq.dispatch.IDispatcher#shutdown()
+     */
+    public final void shutdown(Runnable onShutdown) {
+        if( startCounter.decrementAndGet()==0 ) {
+            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.size());
+            for (DispatcherThread d : new ArrayList&lt;DispatcherThread&gt;(dispatchers)) {
+                d.shutdown(shutdownCountDown, onShutdown);
+            }
+            loadBalancer.stop();
+        }
+    }
+
+    /**
+     * A Dispatcher must call this to indicate that is has started it's dispatch
+     * loop.
+     */
+    public void onDispatcherStarted(DispatcherThread d) {
+        DispatcherThread.CURRENT.set(d);
+        loadBalancer.onDispatcherStarted(d);
+    }
+
+    public LoadBalancer getLoadBalancer() {
+        return loadBalancer;
+    }
+
+    /**
+     * A Dispatcher must call this when exiting it's dispatch loop
+     */
+    public void onDispatcherStopped(DispatcherThread d) {
+        synchronized (dispatchers) {
+            if (dispatchers.remove(d)) {
+                size--;
+            }
+        }
+        loadBalancer.onDispatcherStopped(d);
+    }
+
+    protected DispatcherThread chooseDispatcher() {
+        DispatcherThread d = DispatcherThread.CURRENT.get();
+        if (d == null) {
+            synchronized (dispatchers) {
+                if(dispatchers.isEmpty())
+                {
+                    throw new RejectedExecutionException();
+                }
+                if (++roundRobinCounter &gt;= size) {
+                    roundRobinCounter = 0;
+                }
+                return dispatchers.get(roundRobinCounter);
+            }
+        } else {
+            return d;
+        }
+    }
+
+//    public DispatchContext register(Runnable runnable, String name) {
+//        return chooseDispatcher().register(runnable, name);
+//    }
+
+	public int getSize() {
+		return size;
+	}
+	
+    public final Executor createPriorityExecutor(final int priority) {
+        return new Executor() {
+            public void execute(final Runnable runnable) {
+                chooseDispatcher().dispatch(runnable, priority);
+            }
+
+        };
+    }
+
+    public int getDispatchPriorities() {
+        // TODO Auto-generated method stub
+        return numPriorities;
+    }
+
+    public void execute(Runnable command) {
+        chooseDispatcher().dispatch(command, 0);
+    }
+    
+    public void execute(Runnable command, int priority) {
+        chooseDispatcher().dispatch(command, priority);
+    }
+
+    public void schedule(final Runnable runnable, long delay, TimeUnit timeUnit) {
+        chooseDispatcher().schedule(runnable, delay, timeUnit);
+    }
+
+    public void schedule(final Runnable runnable, int priority, long delay, TimeUnit timeUnit) {
+        chooseDispatcher().schedule(runnable, priority, delay, timeUnit);
+    }
+    
+    public DispatchQueue getMainQueue() {
+        return mainQueue;
+    }
+    
+    public DispatchQueue getGlobalQueue() {
+        return getGlobalQueue(DEFAULT);
+    }
+
+    public DispatchQueue getGlobalQueue(DispatchPriority priority) {
+        return globalQueues[priority.ordinal()];
+    }
+    
+    public DispatchQueue createSerialQueue(String label) {
+        AdvancedSerialDispatchQueue rc = new AdvancedSerialDispatchQueue(label);
+        rc.setTargetQueue(getGlobalQueue());
+        return rc;
+    }
+    
+    public void dispatchMain() {
+        mainQueue.run();
+    }
+
+    public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue) {
+        return null;
+    }
+
+    public DispatchQueue getCurrentQueue() {
+        return CURRENT_QUEUE.get();
+    }    
+
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java Sun Dec  6 14:40:34 2009
@@ -38,8 +38,8 @@
         this.runnable = runnable;
         this.label = label;
         this.target = thread;
-        if (persistent &amp;&amp; target.spi != null) {
-            this.tracker = target.spi.getLoadBalancer().createExecutionTracker((DispatchContext) this);
+        if (persistent &amp;&amp; target.dispatcher != null) {
+            this.tracker = target.dispatcher.getLoadBalancer().createExecutionTracker((DispatchContext) this);
         } else {
             this.tracker = null;
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java Sun Dec  6 14:40:34 2009
@@ -30,7 +30,7 @@
 import org.apache.activemq.util.TimerHeap;
 import org.apache.activemq.util.list.LinkedNodeList;
 
-import static org.apache.activemq.dispatch.DispatchFactory.*;
+import static org.apache.activemq.dispatch.DispatcherFactory.*;
 
 public class DispatcherThread implements Runnable {
 
@@ -46,7 +46,7 @@
     protected final HashSet&lt;DispatchContext&gt; contexts = new HashSet&lt;DispatchContext&gt;();
 
     // Set if this dispatcher is part of a dispatch pool:
-    protected final AdvancedDispatchSPI spi;
+    protected final AdvancedDispatcher dispatcher;
 
     // The local dispatch queue:
     protected final PriorityLinkedList&lt;DispatchContext&gt; priorityQueue;
@@ -75,7 +75,7 @@
         }
     };
 
-    protected DispatcherThread(AdvancedDispatchSPI spi, String name, int priorities) {
+    protected DispatcherThread(AdvancedDispatcher dispatcher, String name, int priorities) {
         this.name = name;
         
         this.dispatchQueues = new ThreadDispatchQueue[3];
@@ -88,7 +88,7 @@
         for (int i = 0; i &lt; 2; i++) {
             foreignQueue[i] = new LinkedNodeList&lt;ForeignEvent&gt;();
         }
-        this.spi = spi;
+        this.dispatcher = dispatcher;
     }
     
     @SuppressWarnings("unchecked")
@@ -176,7 +176,7 @@
 
     public void run() {
 
-        spi.onDispatcherStarted((DispatcherThread) this);
+        dispatcher.onDispatcherStarted((DispatcherThread) this);
         DispatchContext pdc;
         try {
             while (running) {
@@ -184,7 +184,7 @@
                 // If no local work available wait for foreign work:
                 while((pdc = priorityQueue.poll())!=null){
                     if( pdc.priority &lt; dispatchQueues.length ) {
-                        AdvancedDispatchSPI.CURRENT_QUEUE.set(dispatchQueues[pdc.priority]);
+                        AdvancedDispatcher.CURRENT_QUEUE.set(dispatchQueues[pdc.priority]);
                     }
                     
                     if (pdc.tracker != null) {
@@ -235,7 +235,7 @@
         } catch (Throwable thrown) {
             thrown.printStackTrace();
         } finally {
-            spi.onDispatcherStopped((DispatcherThread) this);
+            dispatcher.onDispatcherStopped((DispatcherThread) this);
             cleanup();
         }
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java Sun Dec  6 14:40:34 2009
@@ -29,11 +29,11 @@
 public class GlobalDispatchQueue implements DispatchQueue {
 
     private final String label;
-    private final AdvancedDispatchSPI spi;
+    private final AdvancedDispatcher dispatcher;
     private final DispatchPriority priority;
     
-    public GlobalDispatchQueue(AdvancedDispatchSPI spi, DispatchPriority priority) {
-        this.spi = spi;
+    public GlobalDispatchQueue(AdvancedDispatcher dispatcher, DispatchPriority priority) {
+        this.dispatcher = dispatcher;
         this.priority = priority;
         this.label=priority.toString();
     }
@@ -47,11 +47,11 @@
     }
 
     public void dispatchAsync(Runnable runnable) {
-        spi.execute(runnable, priority.ordinal());
+        dispatcher.execute(runnable, priority.ordinal());
     }
 
     public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
-        spi.schedule(runnable, priority.ordinal(), delay, TimeUnit.MILLISECONDS);
+        dispatcher.schedule(runnable, priority.ordinal(), delay, TimeUnit.MILLISECONDS);
     }
 
     public void dispatchSync(final Runnable runnable) throws InterruptedException {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java Sun Dec  6 14:40:34 2009
@@ -27,17 +27,17 @@
  */
 final public class DispatcherThread extends Thread {
     private static final int MAX_DISPATCH_BEFORE_CHECKING_FOR_HIGHER_PRIO = 10000;
-    private final SimpleDispatchSPI spi;
+    private final SimpleDispatcher dispatcher;
     final ThreadDispatchQueue[] threadQueues;
     final AtomicLong threadQueuedRunnables = new AtomicLong();
         
-    public DispatcherThread(SimpleDispatchSPI spi, int ordinal) {
-        this.spi = spi;
+    public DispatcherThread(SimpleDispatcher dispatcher, int ordinal) {
+        this.dispatcher = dispatcher;
         this.threadQueues = new ThreadDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
             threadQueues[i] = new ThreadDispatchQueue(this, DispatchPriority.values()[i] );
         }
-        setName(spi.getLabel()+" dispatcher: "+(ordinal+1));
+        setName(dispatcher.getLabel()+" dispatcher: "+(ordinal+1));
         setDaemon(true);
     }
     
@@ -47,7 +47,7 @@
             outer: while( true ) {
                 int counter=0;
                 for (SimpleQueue queue : threadQueues) {
-                    SimpleDispatchSPI.CURRENT_QUEUE.set(queue);
+                    SimpleDispatcher.CURRENT_QUEUE.set(queue);
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
                         dispatch(runnable);
@@ -60,8 +60,8 @@
                     continue;
                 }
                 
-                for (SimpleQueue queue : spi.globalQueues) {
-                    SimpleDispatchSPI.CURRENT_QUEUE.set(threadQueues[queue.getPriority().ordinal()]);
+                for (SimpleQueue queue : dispatcher.globalQueues) {
+                    SimpleDispatcher.CURRENT_QUEUE.set(threadQueues[queue.getPriority().ordinal()]);
                     
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
@@ -80,7 +80,7 @@
                     continue;
                 }
             
-//        GlobalDispatchQueue[] globalQueues = spi.globalQueues;
+//        GlobalDispatchQueue[] globalQueues = dispatcher.globalQueues;
 //        while( true ) {
 //
 //            if( dispatch(threadQueues[0]) 
@@ -117,7 +117,7 @@
                 break;
             }        
             if( counter==0 ) {
-                SimpleDispatchSPI.CURRENT_QUEUE.set(queue);
+                SimpleDispatcher.CURRENT_QUEUE.set(queue);
             }
             dispatch(runnable);
             counter++;
@@ -139,10 +139,10 @@
     private boolean inWaitingList;
     
     private void waitForWakeup() throws InterruptedException {
-        while( threadQueuedRunnables.get()==0 &amp;&amp; spi.globalQueuedRunnables.get()==0 ) {
+        while( threadQueuedRunnables.get()==0 &amp;&amp; dispatcher.globalQueuedRunnables.get()==0 ) {
             synchronized(wakeupMutex) {
                 if( !inWaitingList ) {
-                    spi.addWaitingDispatcher(this);
+                    dispatcher.addWaitingDispatcher(this);
                     inWaitingList=true;
                 }
                 wakeupMutex.wait();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java Sun Dec  6 14:40:34 2009
@@ -30,17 +30,17 @@
  */
 public class GlobalDispatchQueue implements SimpleQueue {
 
-    private final SimpleDispatchSPI spi;
+    private final SimpleDispatcher dispatcher;
     final String label;
     final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
     final AtomicLong counter;
     private final DispatchPriority priority;
 
-    public GlobalDispatchQueue(SimpleDispatchSPI spi, DispatchPriority priority) {
-        this.spi = spi;
+    public GlobalDispatchQueue(SimpleDispatcher dispatcher, DispatchPriority priority) {
+        this.dispatcher = dispatcher;
         this.priority = priority;
         this.label=priority.toString();
-        this.counter = spi.globalQueuedRunnables;
+        this.counter = dispatcher.globalQueuedRunnables;
     }
 
     public String getLabel() {
@@ -54,11 +54,11 @@
     public void dispatchAsync(Runnable runnable) {
         this.counter.incrementAndGet();
         runnables.add(runnable);
-        spi.wakeup();
+        dispatcher.wakeup();
     }
 
     public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
-        spi.timerThread.addRelative(runnable, this, delay, unit);
+        dispatcher.timerThread.addRelative(runnable, this, delay, unit);
     }
 
     public void dispatchSync(final Runnable runnable) throws InterruptedException {

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java?rev=887687&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatcher.java Sun Dec  6 14:40:34 2009
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch.internal.simple;
+
+import java.nio.channels.SelectableChannel;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatchSource;
+import org.apache.activemq.dispatch.internal.BaseRetained;
+import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
+
+import static org.apache.activemq.dispatch.DispatchPriority.*;
+
+
+
+/**
+ * Implements a simple dispatch system.
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+public class SimpleDispatcher extends BaseRetained implements Dispatcher {
+        
+    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
+
+    final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
+    final GlobalDispatchQueue globalQueues[]; 
+    final DispatcherThread dispatchers[];
+    final AtomicLong globalQueuedRunnables = new AtomicLong();
+    
+    final ConcurrentLinkedQueue&lt;DispatcherThread&gt; waitingDispatchers = new ConcurrentLinkedQueue&lt;DispatcherThread&gt;();
+    final AtomicInteger waitingDispatcherCount = new AtomicInteger();
+    final AtomicInteger startCounter = new AtomicInteger();
+    private final String label;
+    TimerThread timerThread;
+    
+    public SimpleDispatcher(String label, int size) {
+        this.label = label;
+        globalQueues = new GlobalDispatchQueue[3];
+        for (int i = 0; i &lt; 3; i++) {
+            globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i] );
+        }
+        dispatchers = new DispatcherThread[size];
+    }
+
+    public DispatchQueue getMainQueue() {
+        return mainQueue;
+    }
+    
+    public DispatchQueue getGlobalQueue() {
+        return getGlobalQueue(DEFAULT);
+    }
+
+    public DispatchQueue getGlobalQueue(DispatchPriority priority) {
+        return globalQueues[priority.ordinal()];
+    }
+    
+    public DispatchQueue createSerialQueue(String label) {
+        SerialDispatchQueue rc = new SerialDispatchQueue(label) {
+            @Override
+            public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+                timerThread.addRelative(runnable, this, delay, unit);
+            }
+        };
+        rc.setTargetQueue(getGlobalQueue());
+        return rc;
+    }
+    
+    public void dispatchMain() {
+        mainQueue.run();
+    }
+
+    public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue) {
+        return null;
+    }
+
+    public void addWaitingDispatcher(DispatcherThread dispatcher) {
+        waitingDispatcherCount.incrementAndGet();
+        waitingDispatchers.add(dispatcher);
+    }
+    
+    public void wakeup() {
+        int value = waitingDispatcherCount.get();
+        if( value!=0 ) {
+            DispatcherThread dispatcher = waitingDispatchers.poll();
+            if( dispatcher!=null ) {
+                waitingDispatcherCount.decrementAndGet();
+                dispatcher.globalWakeup();
+            }
+        }
+    }
+
+    public void start() {
+        if( startCounter.getAndIncrement()==0 ) {
+            for (int i = 0; i &lt; dispatchers.length; i++) {
+                dispatchers[i] = new DispatcherThread(this, i);
+                dispatchers[i].start();
+            }
+            timerThread = new TimerThread(this);
+            timerThread.start();
+        }
+    }
+
+    public void shutdown(final Runnable onShutdown) {
+        if( startCounter.decrementAndGet()==0 ) {
+            
+            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.length+1);
+            Runnable wrapper = new Runnable() {
+                public void run() {
+                    if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null) {
+                        onShutdown.run();
+                    }
+                    throw new DispatcherThread.Shutdown();
+                }
+            };
+
+            timerThread.shutdown(wrapper);
+            for (int i = 0; i &lt; dispatchers.length; i++) {
+                ThreadDispatchQueue queue = dispatchers[i].threadQueues[LOW.ordinal()];
+                queue.runnables.add(wrapper);
+            }
+        }
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public DispatchQueue getCurrentQueue() {
+        return CURRENT_QUEUE.get();
+    }
+    
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java Sun Dec  6 14:40:34 2009
@@ -25,8 +25,8 @@
     private final Object mutex = new Object();
     private ArrayList&lt;TimerRequest&gt; requests = new ArrayList&lt;TimerRequest&gt;();
     
-    public TimerThread(SimpleDispatchSPI spi) {
-        setName(spi.getLabel()+" timer");
+    public TimerThread(SimpleDispatcher dispatcher) {
+        setName(dispatcher.getLabel()+" timer");
         setDaemon(true);
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java Sun Dec  6 14:40:34 2009
@@ -13,8 +13,8 @@
 import junit.framework.TestCase;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatcher;
 
 
 /** 
@@ -45,7 +45,7 @@
     
     public void testActorInvocation() throws Exception
     {
-        Dispatch advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
+        Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(), 3);
         advancedSystem.start();
         
         DispatchQueue queue = advancedSystem.createSerialQueue("test");

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java Sun Dec  6 14:40:34 2009
@@ -19,8 +19,8 @@
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.simple.SimpleDispatchSPI;
+import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatcher;
+import org.apache.activemq.dispatch.internal.simple.SimpleDispatcher;
 
 import static org.apache.activemq.dispatch.DispatchPriority.*;
 
@@ -33,7 +33,7 @@
 public class DispatchSystemTest {
 
     public static void main(String[] args) throws Exception {
-        Dispatch advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
+        Dispatcher advancedSystem = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(), 3);
         advancedSystem.start();
         benchmark("advanced global queue", advancedSystem, advancedSystem.getGlobalQueue(DEFAULT));
         benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test"));
@@ -42,7 +42,7 @@
         advancedSystem.shutdown(latch);
         latch.await();
 
-        Dispatch simpleSystem = new SimpleDispatchSPI("test", Runtime.getRuntime().availableProcessors());
+        Dispatcher simpleSystem = new SimpleDispatcher("test", Runtime.getRuntime().availableProcessors());
         simpleSystem.start();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));
@@ -53,13 +53,13 @@
         latch.await();
     }
 
-    private static void benchmark(String name, Dispatch spi, DispatchQueue queue) throws InterruptedException {
+    private static void benchmark(String name, Dispatcher dispatcher, DispatchQueue queue) throws InterruptedException {
         // warm the JIT up..
-        benchmarkWork(spi, queue, 100000);
+        benchmarkWork(dispatcher, queue, 100000);
         
         int iterations = 1000*1000*20;
         long start = System.nanoTime();
-        benchmarkWork(spi, queue, iterations);
+        benchmarkWork(dispatcher, queue, iterations);
         long end = System.nanoTime();
         
         double durationMS = 1.0d*(end-start)/1000000d;
@@ -68,13 +68,13 @@
         System.out.println(format("name: %s, duration: %,.3f ms, rate: %,.2f executions/sec", name, durationMS, rate));
     }
 
-    private static void benchmarkWork(final Dispatch spi, final DispatchQueue queue, int iterations) throws InterruptedException {
+    private static void benchmarkWork(final Dispatcher dispatcher, final DispatchQueue queue, int iterations) throws InterruptedException {
         final CountDownLatch counter = new CountDownLatch(iterations);
         Runnable task = new Runnable(){
             public void run() {
                 counter.countDown();
                 if( counter.getCount()&gt;0 ) {
-                    spi.getCurrentQueue().dispatchAsync(this);
+                    dispatcher.getCurrentQueue().dispatchAsync(this);
                 }
             }
         };

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java Sun Dec  6 14:40:34 2009
@@ -30,7 +30,7 @@
 public class DispatcherPoolTest {
     
     public static void main(String[] args) throws Exception {
-        AdvancedDispatchSPI pooledDispatcher = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
+        AdvancedDispatcher pooledDispatcher = new AdvancedDispatcher(Runtime.getRuntime().availableProcessors(), 3);
         pooledDispatcher.start();
         
         // warm the JIT up..
@@ -48,7 +48,7 @@
         System.out.println(format("duration: %,.3f ms, rate: %,.2f executions/sec", durationMS, rate));
     }
 
-    private static void benchmarkWork(final AdvancedDispatchSPI pooledDispatcher, int iterations) throws InterruptedException {
+    private static void benchmarkWork(final AdvancedDispatcher pooledDispatcher, int iterations) throws InterruptedException {
         final CountDownLatch counter = new CountDownLatch(iterations);
         for (int i = 0; i &lt; 1000; i++) {
             Work dispatchable = new Work(counter, pooledDispatcher);
@@ -61,9 +61,9 @@
         private final CountDownLatch counter;
         private final DispatchQueue dispatchQueue;
 
-        private Work(CountDownLatch counter, AdvancedDispatchSPI spi) {
+        private Work(CountDownLatch counter, AdvancedDispatcher dispatcher) {
             this.counter = counter;
-            dispatchQueue = spi.createSerialQueue("test");
+            dispatchQueue = dispatcher.createSerialQueue("test");
         }
 
         public void run() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java Sun Dec  6 14:40:34 2009
@@ -22,8 +22,8 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.activemq.apollo.broker.Broker;
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 
 @XmlRootElement(name="dispatcher")
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -36,11 +36,11 @@
 	@XmlAttribute(required=false)
 	int threads = Runtime.getRuntime().availableProcessors();
 	
-	public Dispatch createDispatcher(BrokerXml brokerXml) {
+	public Dispatcher createDispatcher(BrokerXml brokerXml) {
 		if( name == null ) {
 			name = "broker";
 		}
-		return DispatchFactory.create(name, threads);
+		return DispatcherFactory.create(name, threads);
 	}
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java Sun Dec  6 14:40:34 2009
@@ -26,7 +26,7 @@
 import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.apollo.broker.BrokerFactory;
 import org.apache.activemq.broker.store.memory.MemoryStore;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.junit.Test;
@@ -44,7 +44,7 @@
 		LOG.info("Loading broker configuration from the classpath with URI: " + uri);
 		Broker broker = BrokerFactory.createBroker(uri);
 		
-		Dispatch p = (Dispatch)broker.getDispatcher();
+		Dispatcher p = (Dispatcher)broker.getDispatcher();
 //		assertEquals(4, p.getSize());
 //		assertEquals("test dispatcher", p.getName());
 		

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java Sun Dec  6 14:40:34 2009
@@ -38,10 +38,10 @@
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.DispatcherFactory;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -65,7 +65,7 @@
 
     private static int PERFORMANCE_SAMPLES = 5;
 
-    Dispatch dispatcher;
+    Dispatcher dispatcher;
     BrokerDatabase database;
     BrokerQueueStore queueStore;
     private static final boolean USE_KAHA_DB = true;
@@ -82,8 +82,8 @@
     protected ArrayList&lt;Producer&gt; producers = new ArrayList&lt;Producer&gt;();
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt;();
 
-    protected Dispatch createDispatcher() {
-        return DispatchFactory.create("pref-test", THREAD_POOL_SIZE);
+    protected Dispatcher createDispatcher() {
+        return DispatcherFactory.create("pref-test", THREAD_POOL_SIZE);
     }
 
     protected int consumerStartDelay = 0;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java Sun Dec  6 14:40:34 2009
@@ -21,7 +21,7 @@
 
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.ISinkController.FlowControllable;
 
 /**
@@ -32,7 +32,7 @@
  */
 public abstract class AbstractFlowQueue&lt;E&gt; extends AbstractFlowRelay&lt;E&gt; implements FlowControllable&lt;E&gt;, IFlowQueue&lt;E&gt; {
 
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
     protected Collection&lt;IPollableFlowSource.FlowReadyListener&lt;E&gt;&gt; readyListeners;
     private boolean notifyReady = false;
     protected int dispatchPriority = 0;
@@ -132,7 +132,7 @@
      * @param dispatcher
      *            The dispatcher to handle messages.
      */
-    public synchronized void setDispatcher(Dispatch dispatcher) {
+    public synchronized void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
         
         dispatchQueue = dispatcher.createSerialQueue(getResourceName());

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java Sun Dec  6 14:40:34 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.queue;
 
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.IFlowRelay;
 
 public interface IFlowQueue&lt;E&gt; extends IBlockingFlowSource&lt;E&gt;, IPollableFlowSource&lt;E&gt;, IFlowRelay&lt;E&gt; {
@@ -57,7 +57,7 @@
      * @param dispatcher
      *            The dispatcher to be used by the queue.
      */
-    public void setDispatcher(Dispatch dispatcher);
+    public void setDispatcher(Dispatcher dispatcher);
 
     /**
      * Sets the base dispatch priority for the queue. Setting to higher value

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java Sun Dec  6 14:40:34 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.queue;
 
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.queue.QueueStore.PersistentQueue;
 import org.apache.activemq.util.Mapper;
 
@@ -47,7 +47,7 @@
      * @param dispatcher
      *            The dispatcher to be used by the queue.
      */
-    public void setDispatcher(Dispatch dispatcher);
+    public void setDispatcher(Dispatcher dispatcher);
 
     /**
      * Sets the base dispatch priority for the queue. Setting to higher value

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java Sun Dec  6 14:40:34 2009
@@ -21,7 +21,7 @@
 import java.util.HashSet;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.ISourceController;
 import org.apache.activemq.util.Mapper;
 import org.apache.activemq.util.buffer.AsciiBuffer;
@@ -31,7 +31,7 @@
     protected HashSet&lt;Subscription&lt;V&gt;&gt; subscriptions = new HashSet&lt;Subscription&lt;V&gt;&gt;();
     private HashMap&lt;Integer, IQueue&lt;K, V&gt;&gt; partitions = new HashMap&lt;Integer, IQueue&lt;K, V&gt;&gt;();
     protected QueueStore&lt;K, V&gt; store;
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
     protected boolean started;
     protected boolean shutdown = false;
     protected QueueDescriptor queueDescriptor;
@@ -253,7 +253,7 @@
         this.autoRelease = autoRelease;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         checkShutdown();
         this.dispatcher = dispatcher;
         synchronized (this) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java Sun Dec  6 14:40:34 2009
@@ -11,7 +11,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.flow.AbstractLimiter;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.IFlowLimiter;
@@ -66,12 +66,12 @@
     private final int inputWindowSize = 1000;
     private final int inputResumeThreshold = 500;
 
-    private Dispatch dispatcher;
+    private Dispatcher dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean(false);
     protected boolean blockingTransport = false;
     ExecutorService blockingWriter;
 
-    public static void setInShutdown(boolean val, Dispatch dispatcher) {
+    public static void setInShutdown(boolean val, Dispatcher dispatcher) {
         if (val != inShutdown.getAndSet(val)) {
             if (val) {
                 if (USE_RATE_BASED_LIMITER) {
@@ -275,11 +275,11 @@
         this.priorityLevels = priorityLevels;
     }
 
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -456,12 +456,12 @@
 
     protected static class RateBasedLimiterCollector implements Runnable {
 
-        private Dispatch dispatcher;
+        private Dispatcher dispatcher;
         private int samplingPeriod = 50;
         private boolean scheduled = false;
         private HashSet&lt;RateBasedLimiter&gt; limiters = new HashSet&lt;RateBasedLimiter&gt;();
 
-        public synchronized void setDispatcher(Dispatch d) {
+        public synchronized void setDispatcher(Dispatcher d) {
             if (d != dispatcher) {
                 scheduled = false;
                 dispatcher = d;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java Sun Dec  6 14:40:34 2009
@@ -21,9 +21,9 @@
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
-import org.apache.activemq.dispatch.DispatchAware;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
+import org.apache.activemq.dispatch.DispatcherAware;
 import org.apache.activemq.flow.IFlowSink;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.transport.Transport;
@@ -53,7 +53,7 @@
     private TransportServer transportServer;
     private String uri;
     private String name;
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean();
     private boolean useInputQueues = false;
 
@@ -125,8 +125,8 @@
 
         transportServer = TransportFactory.bind(new URI(uri));
         transportServer.setAcceptListener(this);
-        if (transportServer instanceof DispatchAware) {
-            ((DispatchAware) transportServer).setDispatcher(dispatcher);
+        if (transportServer instanceof DispatcherAware) {
+            ((DispatcherAware) transportServer).setDispatcher(dispatcher);
         }
         transportServer.start();
 
@@ -159,7 +159,7 @@
         error.printStackTrace();
     }
 
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
 
@@ -167,7 +167,7 @@
         this.name = name;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -189,7 +189,7 @@
 
     protected void createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = DispatchFactory.create("mock-broker", Runtime.getRuntime().availableProcessors());
+            dispatcher = DispatcherFactory.create("mock-broker", Runtime.getRuntime().availableProcessors());
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java Sun Dec  6 14:40:34 2009
@@ -20,8 +20,8 @@
 
 import junit.framework.TestCase;
 
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -63,7 +63,7 @@
     protected MockBroker rcvBroker;
     protected MockClient client;
 
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
 
     static public final Mapper&lt;Long, Message&gt; KEY_MAPPER = new Mapper&lt;Long, Message&gt;() {
         public Long map(Message element) {
@@ -94,8 +94,8 @@
         }
     }
 
-    protected Dispatch createDispatcher(String name) {
-        return DispatchFactory.create("test", threadsPerDispatcher);
+    protected Dispatcher createDispatcher(String name) {
+        return DispatcherFactory.create("test", threadsPerDispatcher);
     }
 
     public void test_1_1_0() throws Exception {
@@ -284,7 +284,7 @@
             }
         }
 
-        Dispatch clientDispatcher = null;
+        Dispatcher clientDispatcher = null;
         if (SEPARATE_CLIENT_DISPATCHER) {
             clientDispatcher = createDispatcher("ClientDispatcher");
             clientDispatcher.start();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java Sun Dec  6 14:40:34 2009
@@ -7,8 +7,8 @@
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.Dispatch;
-import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.Dispatcher;
+import org.apache.activemq.dispatch.DispatcherFactory;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -43,7 +43,7 @@
     protected ArrayList&lt;MetricCounter&gt; additionalReportMetrics = new ArrayList&lt;MetricCounter&gt;();
     protected boolean includeDetailedRates = false;
 
-    protected Dispatch dispatcher;
+    protected Dispatcher dispatcher;
 
     public RemoteConsumer consumer(int index) {
         return consumers.get(index);
@@ -214,7 +214,7 @@
         return testName;
     }
 
-    public void setDispatcher(Dispatch dispatcher) {
+    public void setDispatcher(Dispatcher dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -274,13 +274,13 @@
         }
     }
 
-    public Dispatch getDispatcher() {
+    public Dispatcher getDispatcher() {
         return dispatcher;
     }
 
-    protected Dispatch createDispatcher() {
+    protected Dispatcher createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = DispatchFactory.create("client", threadsPerDispatcher);
+            dispatcher = DispatcherFactory.create("client", threadsPerDispatcher);
         }
         return dispatcher;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java Sun Dec  6 14:40:34 2009
@@ -17,9 +17,9 @@
 package org.apache.activemq.transport;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.DispatchAware;
+import org.apache.activemq.dispatch.DispatcherAware;
 
-public interface DispatchableTransport extends Transport, DispatchAware {
+public interface DispatchableTransport extends Transport, DispatcherAware {
 
     public void setDispatchPriority(DispatchPriority priority);
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java?rev=887687&amp;r1=887686&amp;r2=887687&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java Sun Dec  6 14:40:34 2009
@@ -14,9 +14,9 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.Dispatcher;
 import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
 import org.apache.activemq.transport.DispatchableTransport;
 import org.apache.activemq.transport.FutureResponse;
@@ -82,7 +82,7 @@
             }
         }
 
-        public void setDispatcher(Dispatch dispatcher) {
+        public void setDispatcher(Dispatcher dispatcher) {
             dispatchQueue = dispatcher.createSerialQueue(name);
             dispatchTask = new Runnable(){
                 public void run() {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887686 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/java/org/apache/activemq/apollo/ activemq-broker/src/main/java/org/apache/activemq/apollo/broker/ activemq-broker/src/test/java/org/apache/activemq/broker/ activ...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206143241.63C0823888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206143241-63C0823888D1@eris-apache-org%3e</id>
<updated>2009-12-06T14:32:40Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 14:32:37 2009
New Revision: 887686

URL: http://svn.apache.org/viewvc?rev=887686&amp;view=rev
Log:
Refactor for better dispatch package class names

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteConsumer.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/openwire/OpenwireRemoteConsumer.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteConsumer.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/test/java/org/apache/activemq/perf/broker/stomp/StompRemoteConsumer.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/Connection.java Sun Dec  6 14:32:37 2009
@@ -25,8 +25,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.Service;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.transport.DispatchableTransport;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportListener;
@@ -43,7 +42,7 @@
     protected int inputResumeThreshold = 512 * 1024;
     protected boolean useAsyncWriteThread = true;
 
-    private AdvancedDispatchSPI dispatcher;
+    private Dispatch dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean();
     private ExecutorService blockingWriter;
     private ExceptionListener exceptionListener;
@@ -171,11 +170,11 @@
         this.priorityLevels = priorityLevels;
     }
 
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Broker.java Sun Dec  6 14:32:37 2009
@@ -25,11 +25,9 @@
 
 import org.apache.activemq.Service;
 import org.apache.activemq.apollo.Connection;
-import org.apache.activemq.dispatch.DispatcherAware;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.DispatchAware;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportAcceptListener;
 import org.apache.activemq.transport.TransportServer;
@@ -53,7 +51,7 @@
 
     private final LinkedHashMap&lt;AsciiBuffer, VirtualHost&gt; virtualHosts = new LinkedHashMap&lt;AsciiBuffer, VirtualHost&gt;();
     private VirtualHost defaultVirtualHost;
-    private AdvancedDispatchSPI dispatcher;
+    private Dispatch dispatcher;
     private File dataDirectory;
 
     private final class BrokerAcceptListener implements TransportAcceptListener {
@@ -131,7 +129,7 @@
 		// apply some default configuration to this broker instance before it's started.
 		if( dispatcher == null ) {
 			int threads = Runtime.getRuntime().availableProcessors();
-			dispatcher = new AdvancedDispatchSPI(threads, Broker.MAX_PRIORITY);
+			dispatcher = DispatchFactory.create(getName(), threads);
 		}
 		
 
@@ -186,9 +184,9 @@
         for (VirtualHost virtualHost : virtualHosts.values()) {
         	stop(virtualHost);
         }
-        dispatcher.shutdown();
+        
+        dispatcher.release();
     	state.set(State.STOPPED);
-
     }
         
     // /////////////////////////////////////////////////////////////////
@@ -378,10 +376,10 @@
     // /////////////////////////////////////////////////////////////////
     // Property Accessors
     // /////////////////////////////////////////////////////////////////
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
     	assertInConfigurationState();
         this.dispatcher = dispatcher;
     }
@@ -419,8 +417,8 @@
     
 	private void startTransportServer(TransportServer server) throws Exception {
 		server.setAcceptListener(new BrokerAcceptListener());
-		if (server instanceof DispatcherAware ) {
-			((DispatcherAware) server).setDispatcher(dispatcher);
+		if (server instanceof DispatchAware ) {
+			((DispatchAware) server).setDispatcher(dispatcher);
 		}
 		server.start();
 	}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java Sun Dec  6 14:32:37 2009
@@ -40,8 +40,8 @@
 import org.apache.activemq.broker.store.Store.QueueQueryResult;
 import org.apache.activemq.broker.store.Store.QueueRecord;
 import org.apache.activemq.broker.store.Store.Session;
-import org.apache.activemq.dispatch.DispatcherAware;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchAware;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -60,7 +60,7 @@
 import org.apache.activemq.util.list.LinkedNode;
 import org.apache.activemq.util.list.LinkedNodeList;
 
-public class BrokerDatabase extends AbstractLimitedFlowResource&lt;BrokerDatabase.OperationBase&lt;?&gt;&gt; implements Service, DispatcherAware {
+public class BrokerDatabase extends AbstractLimitedFlowResource&lt;BrokerDatabase.OperationBase&lt;?&gt;&gt; implements Service, DispatchAware {
 
     private static final boolean DEBUG = false;
 
@@ -71,7 +71,7 @@
     private final FlowController&lt;OperationBase&lt;?&gt;&gt; storeController;
     private final int FLUSH_QUEUE_SIZE = 10000 * 1024;
 
-    private AdvancedDispatchSPI dispatcher;
+    private Dispatch dispatcher;
     private Thread flushThread;
     private AtomicBoolean running = new AtomicBoolean(false);
     private DatabaseListener listener;
@@ -328,7 +328,7 @@
 
         if (requestedDelayedFlushPointer == -1) {
             requestedDelayedFlushPointer = delayedFlushPointer;
-            dispatcher.schedule(flushDelayCallback, flushDelay, TimeUnit.MILLISECONDS);
+            dispatcher.getGlobalQueue().dispatchAfter(flushDelayCallback, flushDelay, TimeUnit.MILLISECONDS);
         }
 
     }
@@ -1288,11 +1288,11 @@
         return store.allocateStoreTracking();
     }
 
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerQueueStore.java Sun Dec  6 14:32:37 2009
@@ -24,7 +24,7 @@
 
 import org.apache.activemq.broker.store.Store.MessageRecord;
 import org.apache.activemq.broker.store.Store.QueueQueryResult;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.flow.ISourceController;
 import org.apache.activemq.flow.PrioritySizeLimiter;
 import org.apache.activemq.flow.SizeLimiter;
@@ -52,7 +52,7 @@
     private static final boolean USE_PRIORITY_QUEUES = true;
 
     private BrokerDatabase database;
-    private AdvancedDispatchSPI dispatcher;
+    private Dispatch dispatcher;
 
     private static HashMap&lt;String, ProtocolHandler&gt; protocolHandlers = new HashMap&lt;String, ProtocolHandler&gt;();
     private static final BrokerDatabase.MessageRecordMarshaller&lt;MessageDelivery&gt; MESSAGE_MARSHALLER = new BrokerDatabase.MessageRecordMarshaller&lt;MessageDelivery&gt;() {
@@ -226,7 +226,7 @@
         this.database = database;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/BrokerTestBase.java Sun Dec  6 14:32:37 2009
@@ -30,9 +30,8 @@
 import org.apache.activemq.apollo.broker.Router;
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.Period;
 import org.apache.activemq.transport.TransportFactory;
@@ -88,7 +87,7 @@
     protected Broker sendBroker;
     protected Broker rcvBroker;
     protected ArrayList&lt;Broker&gt; brokers = new ArrayList&lt;Broker&gt;();
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
     protected final AtomicLong msgIdGenerator = new AtomicLong();
     protected final AtomicBoolean stopping = new AtomicBoolean();
 
@@ -135,8 +134,8 @@
 
     protected abstract String getRemoteWireFormat();
 
-    protected AdvancedDispatchSPI createDispatcher() {
-        return new AdvancedDispatchSPI(asyncThreadPoolSize, Broker.MAX_PRIORITY);
+    protected Dispatch createDispatcher() {
+        return DispatchFactory.create("test", asyncThreadPoolSize);
     }
 
     @Test
@@ -539,7 +538,7 @@
             connection.stop();
         }
         if (dispatcher != null) {
-            dispatcher.shutdown();
+            dispatcher.release();
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteConsumer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteConsumer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteConsumer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteConsumer.java Sun Dec  6 14:32:37 2009
@@ -46,7 +46,7 @@
     protected void messageReceived(final ISourceController&lt;MessageDelivery&gt; controller, final MessageDelivery elem) {
         if( schedualWait ) {
             if (thinkTime &gt; 0) {
-                getDispatcher().schedule(new Runnable(){
+                getDispatcher().getGlobalQueue().dispatchAfter(new Runnable(){
                     public void run() {
                         consumerRate.increment();
                         controller.elementDispatched(elem);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java Sun Dec  6 14:32:37 2009
@@ -59,7 +59,7 @@
         
         setupProducer();
         
-        dispatchQueue = getDispatcher().createQueue(name + "-client");
+        dispatchQueue = getDispatcher().createSerialQueue(name + "-client");
         dispatchTask = new Runnable(){
             public void run() {
                 dispatch();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/SharedQueueTest.java Sun Dec  6 14:32:37 2009
@@ -21,15 +21,13 @@
 
 import junit.framework.TestCase;
 
-import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.apollo.broker.BrokerDatabase;
 import org.apache.activemq.apollo.broker.BrokerQueueStore;
 import org.apache.activemq.apollo.broker.MessageDelivery;
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
 import org.apache.activemq.queue.IQueue;
 
 /**
@@ -39,7 +37,7 @@
 public class SharedQueueTest extends TestCase {
 
 
-    AdvancedDispatchSPI dispatcher;
+    Dispatch dispatcher;
     BrokerDatabase database;
     BrokerQueueStore queueStore;
     private static final boolean USE_KAHA_DB = true;
@@ -48,8 +46,8 @@
 
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt;();
 
-    protected AdvancedDispatchSPI createDispatcher() {
-        return new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), Broker.MAX_PRIORITY);
+    protected Dispatch createDispatcher() {
+        return DispatchFactory.create("test", Runtime.getRuntime().availableProcessors());
     }
 
     protected int consumerStartDelay = 0;
@@ -77,9 +75,8 @@
     }
 
     protected void stopServices() throws Exception {
-        dispatcher.shutdown();
         database.stop();
-        dispatcher.shutdown();
+        dispatcher.release();
         queues.clear();
     }
 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java?rev=887686&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Dispatch.java Sun Dec  6 14:32:37 2009
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+import java.nio.channels.SelectableChannel;
+
+
+public interface Dispatch extends Retained {
+    
+    public void start();
+    public void shutdown(Runnable onShutdown);
+    
+    public DispatchQueue getGlobalQueue();
+    public DispatchQueue getGlobalQueue(DispatchPriority priority);
+    
+    public DispatchQueue createSerialQueue(String label);
+    
+    public DispatchQueue getMainQueue();
+    public void dispatchMain();
+    
+    public DispatchQueue getCurrentQueue();
+
+    public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue);
+    
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java?rev=887686&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchAware.java Sun Dec  6 14:32:37 2009
@@ -0,0 +1,14 @@
+package org.apache.activemq.dispatch;
+
+
+/**
+ * Handy interface to signal classes which would like an DispatchSPI instance
+ * injected into them.
+ *  
+ * @author chirino
+ */
+public interface DispatchAware {
+
+	public void setDispatcher(Dispatch dispatcher);
+	
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java?rev=887686&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchFactory.java Sun Dec  6 14:32:37 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch;
+
+import org.apache.activemq.dispatch.internal.simple.SimpleDispatchSPI;
+
+/**
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+public class DispatchFactory {
+
+    public static Dispatch create() {
+        return create("system", Runtime.getRuntime().availableProcessors());
+    }
+
+    public static Dispatch create(String name, int threads) {
+        return new SimpleDispatchSPI(name, threads);
+    }
+    
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java?rev=887686&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java Sun Dec  6 14:32:37 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+import org.apache.activemq.dispatch.internal.simple.DispatcherThread;
+
+public interface DispatchObserver {
+    
+    public void onThreadCreate(DispatcherThread thread);
+    public void onThreadDestroy(DispatcherThread thread);
+
+    public void onQueueCreate(DispatchQueue queue);
+    public void onQueueDestroy(DispatchQueue queue);
+    
+    public void onSourceCreate(DispatchSource source);
+    public void onSourceDestroy(DispatchSource source);
+    
+    public void onDispatchRequest(DispatchQueue target, Runnable request);
+
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java Sun Dec  6 14:32:37 2009
@@ -26,50 +26,34 @@
  */
 public class DispatchSystem {
 
-    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
-    static public DispatchQueue getCurrentQueue() {
-        return CURRENT_QUEUE.get();
-    }
-
-    private static DispatchSPI spi;
+    final private static Dispatch spi = create();
 
-    public static DispatchSPI create() {
-        return create("system", Runtime.getRuntime().availableProcessors());
+    private static Dispatch create() {
+        return new SimpleDispatchSPI("system", Runtime.getRuntime().availableProcessors());
     }
 
-    public static SimpleDispatchSPI create(String name, int threads) {
-        return new SimpleDispatchSPI(name, threads);
-    }
-    
-    synchronized public static DispatchSPI spi() {
-        if(spi==null) {
-            spi = create();
-        }
-        return spi;
-    }
-    
     static DispatchQueue getMainQueue() {
-        return spi().getMainQueue();
+        return spi.getMainQueue();
     }
     
     static public DispatchQueue getGlobalQueue() {
-        return spi().getGlobalQueue();
+        return spi.getGlobalQueue();
     }
     
     static public DispatchQueue getGlobalQueue(DispatchPriority priority) {
-        return spi().getGlobalQueue(priority);
+        return spi.getGlobalQueue(priority);
     }
     
-    static DispatchQueue createQueue(String label) {
-        return spi().createQueue(label);
+    static DispatchQueue getSerialQueue(String label) {
+        return spi.createSerialQueue(label);
     }
     
     static void dispatchMain() {
-        spi().dispatchMain();
+        spi.dispatchMain();
     }
 
     static DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue) {
-        return spi().createSource(channel, interestOps, queue);
+        return spi.createSource(channel, interestOps, queue);
     }
 
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java Sun Dec  6 14:32:37 2009
@@ -22,7 +22,12 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
+
+import static org.apache.activemq.dispatch.DispatchFactory.*;
+
+import static org.apache.activemq.dispatch.DispatchFactory.*;
 
 /**
  * 
@@ -84,8 +89,8 @@
     }
 
     public void run() {
-        DispatchQueue original = DispatchSystem.CURRENT_QUEUE.get();
-        DispatchSystem.CURRENT_QUEUE.set(this);
+        DispatchQueue original = CURRENT_QUEUE.get();
+        CURRENT_QUEUE.set(this);
         try {
             Runnable runnable;
             long lsize = size.get();
@@ -104,7 +109,7 @@
                 }
             }
         } finally {
-            DispatchSystem.CURRENT_QUEUE.set(original);
+            CURRENT_QUEUE.set(original);
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java Sun Dec  6 14:32:37 2009
@@ -24,19 +24,19 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.DispatchSPI;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSource;
 import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
 import static org.apache.activemq.dispatch.DispatchPriority.*;
 
-import static org.apache.activemq.dispatch.DispatchPriority.*;
 
+public class AdvancedDispatchSPI extends BaseRetained implements Dispatch {
 
-public class AdvancedDispatchSPI extends BaseRetained implements DispatchSPI {
+    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
 
     final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
     final GlobalDispatchQueue globalQueues[];
@@ -210,7 +210,7 @@
         return globalQueues[priority.ordinal()];
     }
     
-    public DispatchQueue createQueue(String label) {
+    public DispatchQueue createSerialQueue(String label) {
         AdvancedSerialDispatchQueue rc = new AdvancedSerialDispatchQueue(label);
         rc.setTargetQueue(getGlobalQueue());
         return rc;
@@ -222,6 +222,10 @@
 
     public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue) {
         return null;
+    }
+
+    public DispatchQueue getCurrentQueue() {
+        return CURRENT_QUEUE.get();
     }    
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java Sun Dec  6 14:32:37 2009
@@ -25,12 +25,13 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.DispatchSystem;
 import org.apache.activemq.util.Mapper;
 import org.apache.activemq.util.PriorityLinkedList;
 import org.apache.activemq.util.TimerHeap;
 import org.apache.activemq.util.list.LinkedNodeList;
 
+import static org.apache.activemq.dispatch.DispatchFactory.*;
+
 public class DispatcherThread implements Runnable {
 
     static public final ThreadLocal&lt;DispatcherThread&gt; CURRENT = new ThreadLocal&lt;DispatcherThread&gt;();
@@ -183,7 +184,7 @@
                 // If no local work available wait for foreign work:
                 while((pdc = priorityQueue.poll())!=null){
                     if( pdc.priority &lt; dispatchQueues.length ) {
-                        DispatchSystem.CURRENT_QUEUE.set(dispatchQueues[pdc.priority]);
+                        AdvancedDispatchSPI.CURRENT_QUEUE.set(dispatchQueues[pdc.priority]);
                     }
                     
                     if (pdc.tracker != null) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java Sun Dec  6 14:32:37 2009
@@ -20,7 +20,6 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.DispatchSystem;
 
 /**
  * 
@@ -48,7 +47,7 @@
             outer: while( true ) {
                 int counter=0;
                 for (SimpleQueue queue : threadQueues) {
-                    DispatchSystem.CURRENT_QUEUE.set(queue);
+                    SimpleDispatchSPI.CURRENT_QUEUE.set(queue);
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
                         dispatch(runnable);
@@ -62,7 +61,7 @@
                 }
                 
                 for (SimpleQueue queue : spi.globalQueues) {
-                    DispatchSystem.CURRENT_QUEUE.set(threadQueues[queue.getPriority().ordinal()]);
+                    SimpleDispatchSPI.CURRENT_QUEUE.set(threadQueues[queue.getPriority().ordinal()]);
                     
                     Runnable runnable;
                     while( (runnable = queue.poll())!=null ) {
@@ -118,7 +117,7 @@
                 break;
             }        
             if( counter==0 ) {
-                DispatchSystem.CURRENT_QUEUE.set(queue);
+                SimpleDispatchSPI.CURRENT_QUEUE.set(queue);
             }
             dispatch(runnable);
             counter++;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java Sun Dec  6 14:32:37 2009
@@ -24,7 +24,7 @@
 
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchPriority;
-import org.apache.activemq.dispatch.DispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.dispatch.DispatchSource;
 import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
@@ -38,8 +38,10 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public class SimpleDispatchSPI extends BaseRetained implements DispatchSPI {
+public class SimpleDispatchSPI extends BaseRetained implements Dispatch {
         
+    public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
+
     final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
     final GlobalDispatchQueue globalQueues[]; 
     final DispatcherThread dispatchers[];
@@ -72,7 +74,7 @@
         return globalQueues[priority.ordinal()];
     }
     
-    public DispatchQueue createQueue(String label) {
+    public DispatchQueue createSerialQueue(String label) {
         SerialDispatchQueue rc = new SerialDispatchQueue(label) {
             @Override
             public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
@@ -142,5 +144,9 @@
     public String getLabel() {
         return label;
     }
+
+    public DispatchQueue getCurrentQueue() {
+        return CURRENT_QUEUE.get();
+    }
     
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java Sun Dec  6 14:32:37 2009
@@ -13,7 +13,7 @@
 import junit.framework.TestCase;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 
 
@@ -45,10 +45,10 @@
     
     public void testActorInvocation() throws Exception
     {
-        DispatchSPI advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
+        Dispatch advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
         advancedSystem.start();
         
-        DispatchQueue queue = advancedSystem.createQueue("test");
+        DispatchQueue queue = advancedSystem.createSerialQueue("test");
         ActorTestObject testObject = Actor.create(new ActorTestObject(), queue);
         
         CountDownLatch latch = new CountDownLatch(1);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java Sun Dec  6 14:32:37 2009
@@ -33,27 +33,27 @@
 public class DispatchSystemTest {
 
     public static void main(String[] args) throws Exception {
-        DispatchSPI advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
+        Dispatch advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
         advancedSystem.start();
         benchmark("advanced global queue", advancedSystem, advancedSystem.getGlobalQueue(DEFAULT));
-        benchmark("advanced private serial queue", advancedSystem, advancedSystem.createQueue("test"));
+        benchmark("advanced private serial queue", advancedSystem, advancedSystem.createSerialQueue("test"));
 
         RunnableCountDownLatch latch = new RunnableCountDownLatch(1);
         advancedSystem.shutdown(latch);
         latch.await();
 
-        DispatchSPI simpleSystem = new SimpleDispatchSPI("test", Runtime.getRuntime().availableProcessors());
+        Dispatch simpleSystem = new SimpleDispatchSPI("test", Runtime.getRuntime().availableProcessors());
         simpleSystem.start();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));
-        benchmark("simple private serial queue", simpleSystem, simpleSystem.createQueue("test"));
+        benchmark("simple private serial queue", simpleSystem, simpleSystem.createSerialQueue("test"));
 
         latch = new RunnableCountDownLatch(1);
         simpleSystem.shutdown(latch);
         latch.await();
     }
 
-    private static void benchmark(String name, DispatchSPI spi, DispatchQueue queue) throws InterruptedException {
+    private static void benchmark(String name, Dispatch spi, DispatchQueue queue) throws InterruptedException {
         // warm the JIT up..
         benchmarkWork(spi, queue, 100000);
         
@@ -68,13 +68,13 @@
         System.out.println(format("name: %s, duration: %,.3f ms, rate: %,.2f executions/sec", name, durationMS, rate));
     }
 
-    private static void benchmarkWork(final DispatchSPI spi, final DispatchQueue queue, int iterations) throws InterruptedException {
+    private static void benchmarkWork(final Dispatch spi, final DispatchQueue queue, int iterations) throws InterruptedException {
         final CountDownLatch counter = new CountDownLatch(iterations);
         Runnable task = new Runnable(){
             public void run() {
                 counter.countDown();
                 if( counter.getCount()&gt;0 ) {
-                    DispatchSystem.getCurrentQueue().dispatchAsync(this);
+                    spi.getCurrentQueue().dispatchAsync(this);
                 }
             }
         };

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java Sun Dec  6 14:32:37 2009
@@ -63,7 +63,7 @@
 
         private Work(CountDownLatch counter, AdvancedDispatchSPI spi) {
             this.counter = counter;
-            dispatchQueue = spi.createQueue("test");
+            dispatchQueue = spi.createSerialQueue("test");
         }
 
         public void run() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/DispatcherXml.java Sun Dec  6 14:32:37 2009
@@ -22,9 +22,8 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.activemq.apollo.broker.Broker;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
 
 @XmlRootElement(name="dispatcher")
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -37,12 +36,11 @@
 	@XmlAttribute(required=false)
 	int threads = Runtime.getRuntime().availableProcessors();
 	
-	public AdvancedDispatchSPI createDispatcher(BrokerXml brokerXml) {
+	public Dispatch createDispatcher(BrokerXml brokerXml) {
 		if( name == null ) {
-//			VirtualHostXml vh = brokerXml.getDefaultVirtualHost();
-			name = "Broker: ";
+			name = "broker";
 		}
-		return new AdvancedDispatchSPI(threads, maxPriority);
+		return DispatchFactory.create(name, threads);
 	}
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java Sun Dec  6 14:32:37 2009
@@ -26,7 +26,7 @@
 import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.apollo.broker.BrokerFactory;
 import org.apache.activemq.broker.store.memory.MemoryStore;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.junit.Test;
@@ -44,7 +44,7 @@
 		LOG.info("Loading broker configuration from the classpath with URI: " + uri);
 		Broker broker = BrokerFactory.createBroker(uri);
 		
-		AdvancedDispatchSPI p = (AdvancedDispatchSPI)broker.getDispatcher();
+		Dispatch p = (Dispatch)broker.getDispatcher();
 //		assertEquals(4, p.getSize());
 //		assertEquals("test dispatcher", p.getName());
 		

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java Sun Dec  6 14:32:37 2009
@@ -75,6 +75,7 @@
 import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.command.TransactionInfo;
 import org.apache.activemq.command.WireFormatInfo;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.filter.BooleanExpression;
 import org.apache.activemq.filter.FilterException;
 import org.apache.activemq.filter.LogicExpression;
@@ -693,7 +694,7 @@
             }
             controller = new FlowController&lt;MessageDelivery&gt;(null, flow, limiter, this);
             controller.useOverFlowQueue(false);
-            controller.setExecutor(connection.getDispatcher().createPriorityExecutor(connection.getDispatcher().getDispatchPriorities() - 1));
+            controller.setExecutor(connection.getDispatcher().getGlobalQueue(DispatchPriority.HIGH));
             super.onFlowOpened(controller);
         }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java Sun Dec  6 14:32:37 2009
@@ -26,7 +26,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.apollo.broker.BrokerDatabase;
 import org.apache.activemq.apollo.broker.BrokerQueueStore;
 import org.apache.activemq.apollo.broker.MessageDelivery;
@@ -39,8 +38,10 @@
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerId;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.DispatchFactory;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -64,7 +65,7 @@
 
     private static int PERFORMANCE_SAMPLES = 5;
 
-    AdvancedDispatchSPI dispatcher;
+    Dispatch dispatcher;
     BrokerDatabase database;
     BrokerQueueStore queueStore;
     private static final boolean USE_KAHA_DB = true;
@@ -81,8 +82,8 @@
     protected ArrayList&lt;Producer&gt; producers = new ArrayList&lt;Producer&gt;();
     protected ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; queues = new ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt;();
 
-    protected AdvancedDispatchSPI createDispatcher() {
-        return new AdvancedDispatchSPI(THREAD_POOL_SIZE, Broker.MAX_PRIORITY);
+    protected Dispatch createDispatcher() {
+        return DispatchFactory.create("pref-test", THREAD_POOL_SIZE);
     }
 
     protected int consumerStartDelay = 0;
@@ -104,9 +105,8 @@
     }
 
     protected void stopServices() throws Exception {
-        dispatcher.shutdown();
         database.stop();
-        dispatcher.shutdown();
+        dispatcher.release();
         consumers.clear();
         producers.clear();
         queues.clear();
@@ -216,7 +216,7 @@
             };
 
             if (consumerStartDelay &gt; 0) {
-                dispatcher.schedule(startConsumers, consumerStartDelay, TimeUnit.SECONDS);
+                dispatcher.getGlobalQueue().dispatchAfter(startConsumers, consumerStartDelay, TimeUnit.SECONDS);
             } else {
                 startConsumers.run();
             }
@@ -308,7 +308,7 @@
             sendRate.name("Producer " + name + " Rate");
             totalProducerRate.add(sendRate);
             
-            dispatchQueue = dispatcher.createQueue(name);
+            dispatchQueue = dispatcher.createSerialQueue(name);
             dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();
@@ -332,7 +332,7 @@
 
             Flow flow = new Flow(name, true);
             outboundQueue = new SingleFlowRelay&lt;OpenWireMessageDelivery&gt;(flow, name, limiter);
-            outboundQueue.setFlowExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+            outboundQueue.setFlowExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
             outboundQueue.setDrain(new QueueDispatchTarget&lt;OpenWireMessageDelivery&gt;() {
 
                 public void drain(OpenWireMessageDelivery elem, ISourceController&lt;OpenWireMessageDelivery&gt; controller) {
@@ -449,7 +449,7 @@
 
             controller = new FlowController&lt;MessageDelivery&gt;(null, flow, limiter, this);
             controller.useOverFlowQueue(false);
-            controller.setExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+            controller.setExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
 
             rate.name("Consumer " + name + " Rate");
             totalConsumerRate.add(rate);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/openwire/OpenwireRemoteConsumer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/openwire/OpenwireRemoteConsumer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/openwire/OpenwireRemoteConsumer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/openwire/OpenwireRemoteConsumer.java Sun Dec  6 14:32:37 2009
@@ -22,6 +22,7 @@
 import org.apache.activemq.command.MessageDispatch;
 import org.apache.activemq.command.SessionInfo;
 import org.apache.activemq.command.WireFormatInfo;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
 import org.apache.activemq.flow.IFlowResource;
@@ -70,7 +71,7 @@
                 return null;
             }
         }, flow, limiter, inboundMutex);
-        inboundController.setExecutor(getDispatcher().createPriorityExecutor(getDispatcher().getDispatchPriorities() - 1));
+        inboundController.setExecutor(getDispatcher().getGlobalQueue(DispatchPriority.HIGH));
 
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java Sun Dec  6 14:32:37 2009
@@ -20,7 +20,8 @@
 import java.util.Collection;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.flow.ISinkController.FlowControllable;
 
 /**
@@ -31,7 +32,7 @@
  */
 public abstract class AbstractFlowQueue&lt;E&gt; extends AbstractFlowRelay&lt;E&gt; implements FlowControllable&lt;E&gt;, IFlowQueue&lt;E&gt; {
 
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
     protected Collection&lt;IPollableFlowSource.FlowReadyListener&lt;E&gt;&gt; readyListeners;
     private boolean notifyReady = false;
     protected int dispatchPriority = 0;
@@ -87,7 +88,7 @@
         }
         
         stop();
-        dispatchQueue.setFinalizer(onShutdown);
+        dispatchQueue.setShutdownHandler(onShutdown);
         dispatchQueue.release();
         dispatchQueue = null;
     }
@@ -131,10 +132,10 @@
      * @param dispatcher
      *            The dispatcher to handle messages.
      */
-    public synchronized void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public synchronized void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
         
-        dispatchQueue = dispatcher.createQueue(getResourceName());
+        dispatchQueue = dispatcher.createSerialQueue(getResourceName());
         dispatchTask = new Runnable(){
             public void run() {
                 if( pollingDispatch() ) {
@@ -146,7 +147,7 @@
 //        TODO:
 //        dispatchContext.updatePriority(dispatchPriority);
         
-        super.setFlowExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+        super.setFlowExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
     }
 
     public synchronized void setDispatchPriority(int priority) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java Sun Dec  6 14:32:37 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.queue;
 
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
 import org.apache.activemq.flow.IFlowResource;
@@ -170,7 +171,7 @@
                 }
             };
             controller.useOverFlowQueue(false);
-            controller.setExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+            controller.setExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
         }
 
         cursor = queue.openCursor(getResourceName(), memoryController, true, true);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IFlowQueue.java Sun Dec  6 14:32:37 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.queue;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.flow.IFlowRelay;
 
 public interface IFlowQueue&lt;E&gt; extends IBlockingFlowSource&lt;E&gt;, IPollableFlowSource&lt;E&gt;, IFlowRelay&lt;E&gt; {
@@ -57,7 +57,7 @@
      * @param dispatcher
      *            The dispatcher to be used by the queue.
      */
-    public void setDispatcher(AdvancedDispatchSPI dispatcher);
+    public void setDispatcher(Dispatch dispatcher);
 
     /**
      * Sets the base dispatch priority for the queue. Setting to higher value

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java Sun Dec  6 14:32:37 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.queue;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.queue.QueueStore.PersistentQueue;
 import org.apache.activemq.util.Mapper;
 
@@ -47,7 +47,7 @@
      * @param dispatcher
      *            The dispatcher to be used by the queue.
      */
-    public void setDispatcher(AdvancedDispatchSPI dispatcher);
+    public void setDispatcher(Dispatch dispatcher);
 
     /**
      * Sets the base dispatch priority for the queue. Setting to higher value

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java Sun Dec  6 14:32:37 2009
@@ -21,7 +21,7 @@
 import java.util.HashSet;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.flow.ISourceController;
 import org.apache.activemq.util.Mapper;
 import org.apache.activemq.util.buffer.AsciiBuffer;
@@ -31,7 +31,7 @@
     protected HashSet&lt;Subscription&lt;V&gt;&gt; subscriptions = new HashSet&lt;Subscription&lt;V&gt;&gt;();
     private HashMap&lt;Integer, IQueue&lt;K, V&gt;&gt; partitions = new HashMap&lt;Integer, IQueue&lt;K, V&gt;&gt;();
     protected QueueStore&lt;K, V&gt; store;
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
     protected boolean started;
     protected boolean shutdown = false;
     protected QueueDescriptor queueDescriptor;
@@ -253,7 +253,7 @@
         this.autoRelease = autoRelease;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         checkShutdown();
         this.dispatcher = dispatcher;
         synchronized (this) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java Sun Dec  6 14:32:37 2009
@@ -18,6 +18,7 @@
 
 import java.util.HashMap;
 
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
 import org.apache.activemq.flow.IFlowController;
@@ -273,7 +274,7 @@
                 }
             };
             controller.useOverFlowQueue(false);
-            controller.setExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+            controller.setExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
         }
 
         return queue.openCursor(name, controller, pageInElements, skipAcquired);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/AbstractTestConnection.java Sun Dec  6 14:32:37 2009
@@ -10,7 +10,8 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.flow.AbstractLimiter;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.IFlowLimiter;
@@ -65,12 +66,12 @@
     private final int inputWindowSize = 1000;
     private final int inputResumeThreshold = 500;
 
-    private AdvancedDispatchSPI dispatcher;
+    private Dispatch dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean(false);
     protected boolean blockingTransport = false;
     ExecutorService blockingWriter;
 
-    public static void setInShutdown(boolean val, AdvancedDispatchSPI dispatcher) {
+    public static void setInShutdown(boolean val, Dispatch dispatcher) {
         if (val != inShutdown.getAndSet(val)) {
             if (val) {
                 if (USE_RATE_BASED_LIMITER) {
@@ -104,7 +105,7 @@
                 dt.setName(name + "-transport");
             }
             dt.setDispatcher(getDispatcher());
-            dt.setDispatchPriority(dispatcher.getDispatchPriorities() - 1);
+            dt.setDispatchPriority(DispatchPriority.HIGH);
         }
         transport.start();
     }
@@ -153,7 +154,7 @@
             queue.getFlowController(flow).useOverFlowQueue(false);
             inputQueue = queue;
         }
-        inputQueue.setFlowExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+        inputQueue.setFlowExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
         inputQueue.setDrain(new QueueDispatchTarget&lt;Message&gt;() {
 
             public void drain(Message message, ISourceController&lt;Message&gt; controller) {
@@ -191,7 +192,7 @@
             queue.addFlowReadyListener(asyncCommandQueue);
         }
         // Set the executor to be used by the queue's flow controllers:
-        outputQueue.setFlowExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
+        outputQueue.setFlowExecutor(dispatcher.getGlobalQueue(DispatchPriority.HIGH));
 
         limiter.start();
         outboundLimiter.start();
@@ -274,11 +275,11 @@
         this.priorityLevels = priorityLevels;
     }
 
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -455,12 +456,12 @@
 
     protected static class RateBasedLimiterCollector implements Runnable {
 
-        private AdvancedDispatchSPI dispatcher;
+        private Dispatch dispatcher;
         private int samplingPeriod = 50;
         private boolean scheduled = false;
         private HashSet&lt;RateBasedLimiter&gt; limiters = new HashSet&lt;RateBasedLimiter&gt;();
 
-        public synchronized void setDispatcher(AdvancedDispatchSPI d) {
+        public synchronized void setDispatcher(Dispatch d) {
             if (d != dispatcher) {
                 scheduled = false;
                 dispatcher = d;
@@ -517,7 +518,7 @@
                 }
                 if (!scheduled &amp;&amp; !limiters.isEmpty()) {
                     scheduled = true;
-                    dispatcher.schedule(this, samplingPeriod, TimeUnit.MILLISECONDS);
+                    dispatcher.getGlobalQueue().dispatchAfter(this, samplingPeriod, TimeUnit.MILLISECONDS);
                 }
             }
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBroker.java Sun Dec  6 14:32:37 2009
@@ -21,10 +21,9 @@
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.activemq.dispatch.DispatcherAware;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
+import org.apache.activemq.dispatch.DispatchAware;
 import org.apache.activemq.flow.IFlowSink;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.transport.Transport;
@@ -54,7 +53,7 @@
     private TransportServer transportServer;
     private String uri;
     private String name;
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
     private final AtomicBoolean stopping = new AtomicBoolean();
     private boolean useInputQueues = false;
 
@@ -126,8 +125,8 @@
 
         transportServer = TransportFactory.bind(new URI(uri));
         transportServer.setAcceptListener(this);
-        if (transportServer instanceof DispatcherAware) {
-            ((DispatcherAware) transportServer).setDispatcher(dispatcher);
+        if (transportServer instanceof DispatchAware) {
+            ((DispatchAware) transportServer).setDispatcher(dispatcher);
         }
         transportServer.start();
 
@@ -160,7 +159,7 @@
         error.printStackTrace();
     }
 
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
 
@@ -168,7 +167,7 @@
         this.name = name;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -190,7 +189,7 @@
 
     protected void createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), Message.MAX_PRIORITY);
+            dispatcher = DispatchFactory.create("mock-broker", Runtime.getRuntime().availableProcessors());
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockBrokerTest.java Sun Dec  6 14:32:37 2009
@@ -20,9 +20,8 @@
 
 import junit.framework.TestCase;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -64,7 +63,7 @@
     protected MockBroker rcvBroker;
     protected MockClient client;
 
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
 
     static public final Mapper&lt;Long, Message&gt; KEY_MAPPER = new Mapper&lt;Long, Message&gt;() {
         public Long map(Message element) {
@@ -95,8 +94,8 @@
         }
     }
 
-    protected AdvancedDispatchSPI createDispatcher(String name) {
-        return new AdvancedDispatchSPI(threadsPerDispatcher, Message.MAX_PRIORITY);
+    protected Dispatch createDispatcher(String name) {
+        return DispatchFactory.create("test", threadsPerDispatcher);
     }
 
     public void test_1_1_0() throws Exception {
@@ -285,7 +284,7 @@
             }
         }
 
-        AdvancedDispatchSPI clientDispatcher = null;
+        Dispatch clientDispatcher = null;
         if (SEPARATE_CLIENT_DISPATCHER) {
             clientDispatcher = createDispatcher("ClientDispatcher");
             clientDispatcher.start();
@@ -344,9 +343,8 @@
             broker.stopServices();
         }
 
-        client.getDispatcher().shutdown();
         if (dispatcher != null) {
-            dispatcher.shutdown();
+            dispatcher.release();
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/MockClient.java Sun Dec  6 14:32:37 2009
@@ -7,9 +7,8 @@
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
+import org.apache.activemq.dispatch.Dispatch;
+import org.apache.activemq.dispatch.DispatchFactory;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Destination.DestinationBean;
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
@@ -44,7 +43,7 @@
     protected ArrayList&lt;MetricCounter&gt; additionalReportMetrics = new ArrayList&lt;MetricCounter&gt;();
     protected boolean includeDetailedRates = false;
 
-    protected AdvancedDispatchSPI dispatcher;
+    protected Dispatch dispatcher;
 
     public RemoteConsumer consumer(int index) {
         return consumers.get(index);
@@ -215,7 +214,7 @@
         return testName;
     }
 
-    public void setDispatcher(AdvancedDispatchSPI dispatcher) {
+    public void setDispatcher(Dispatch dispatcher) {
         this.dispatcher = dispatcher;
     }
 
@@ -275,13 +274,13 @@
         }
     }
 
-    public AdvancedDispatchSPI getDispatcher() {
+    public Dispatch getDispatcher() {
         return dispatcher;
     }
 
-    protected AdvancedDispatchSPI createDispatcher() {
+    protected Dispatch createDispatcher() {
         if (dispatcher == null) {
-            dispatcher = new AdvancedDispatchSPI(threadsPerDispatcher, numPriorities);
+            dispatcher = DispatchFactory.create("client", threadsPerDispatcher);
         }
         return dispatcher;
     }
@@ -311,7 +310,7 @@
         }
         finally
         {
-            test.getDispatcher().shutdown();
+            test.getDispatcher().release();
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteConsumer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteConsumer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteConsumer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteConsumer.java Sun Dec  6 14:32:37 2009
@@ -1,14 +1,11 @@
 package org.apache.activemq.queue.perf;
 
-import java.net.URI;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.flow.ISourceController;
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.MetricCounter;
-import org.apache.activemq.transport.DispatchableTransport;
-import org.apache.activemq.transport.TransportFactory;
 
 public class RemoteConsumer extends ClientConnection {
 
@@ -32,7 +29,7 @@
     protected void messageReceived(final ISourceController&lt;Message&gt; controller, final Message elem) {
         if (schedualWait) {
             if (thinkTime &gt; 0) {
-                getDispatcher().schedule(new Runnable() {
+                getDispatcher().getGlobalQueue().dispatchAfter(new Runnable() {
 
                     public void run() {
                         consumerRate.increment();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java Sun Dec  6 14:32:37 2009
@@ -48,7 +48,7 @@
         super.start();
         outboundController = outputQueue.getFlowController(outboundFlow);
         
-        dispatchQueue = getDispatcher().createQueue(name + "-client");
+        dispatchQueue = getDispatcher().createSerialQueue(name + "-client");
         dispatchTask = new Runnable(){
             public void run() {
                 dispatch();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/test/java/org/apache/activemq/perf/broker/stomp/StompRemoteConsumer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/test/java/org/apache/activemq/perf/broker/stomp/StompRemoteConsumer.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/test/java/org/apache/activemq/perf/broker/stomp/StompRemoteConsumer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/test/java/org/apache/activemq/perf/broker/stomp/StompRemoteConsumer.java Sun Dec  6 14:32:37 2009
@@ -9,6 +9,7 @@
 import org.apache.activemq.apollo.stomp.StompFrame;
 import org.apache.activemq.apollo.stomp.StompMessageDelivery;
 import org.apache.activemq.broker.RemoteConsumer;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
 import org.apache.activemq.flow.IFlowResource;
@@ -64,7 +65,7 @@
                 return null;
             }
         }, flow, limiter, inboundMutex);
-        inboundController.setExecutor(getDispatcher().createPriorityExecutor(getDispatcher().getDispatchPriorities() - 1));
+        inboundController.setExecutor(getDispatcher().getGlobalQueue(DispatchPriority.HIGH));
     }
     
     public void onCommand(Object command) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/DispatchableTransport.java Sun Dec  6 14:32:37 2009
@@ -16,11 +16,12 @@
  */
 package org.apache.activemq.transport;
 
-import org.apache.activemq.dispatch.DispatcherAware;
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.DispatchAware;
 
-public interface DispatchableTransport extends Transport, DispatcherAware {
+public interface DispatchableTransport extends Transport, DispatchAware {
 
-    public void setDispatchPriority(int priority);
+    public void setDispatchPriority(DispatchPriority priority);
 
     public void setName(String name);
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java?rev=887686&amp;r1=887685&amp;r2=887686&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java Sun Dec  6 14:32:37 2009
@@ -13,9 +13,11 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.dispatch.DispatchPriority;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.Dispatch;
 import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.transport.DispatchableTransport;
 import org.apache.activemq.transport.FutureResponse;
 import org.apache.activemq.transport.ResponseCallback;
@@ -69,7 +71,7 @@
         	pipe.write(EOF_TOKEN);
             if (dispatchQueue != null) {
                 RunnableCountDownLatch done = new RunnableCountDownLatch(1);
-                dispatchQueue.setFinalizer(done);
+                dispatchQueue.setShutdownHandler(done);
                 dispatchQueue.release();
                 done.await();
             } else {
@@ -80,8 +82,8 @@
             }
         }
 
-        public void setDispatcher(AdvancedDispatchSPI dispatcher) {
-            dispatchQueue = dispatcher.createQueue(name);
+        public void setDispatcher(Dispatch dispatcher) {
+            dispatchQueue = dispatcher.createSerialQueue(name);
             dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();
@@ -227,7 +229,7 @@
             this.wireFormat = wireFormat;
         }
 
-        public void setDispatchPriority(int priority) {
+        public void setDispatchPriority(DispatchPriority priority) {
 //            TODO:
 //            readContext.updatePriority(priority);
         }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887630 - in /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src: main/java/org/apache/activemq/dispatch/ main/java/org/apache/activemq/dispatch/internal/ main/java/org/apache/activemq/dispatch/internal/advanced/ main/java/org/a...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091206025255.E411A2388998@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206025255-E411A2388998@eris-apache-org%3e</id>
<updated>2009-12-06T02:52:47Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sun Dec  6 02:52:35 2009
New Revision: 887630

URL: http://svn.apache.org/viewvc?rev=887630&amp;view=rev
Log:
simple package now implements dispatchAfter 

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchPriority.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java Sun Dec  6 02:52:35 2009
@@ -20,18 +20,14 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public interface DispatchObject {
+public interface DispatchObject extends Retained {
     
-    public void retain();
-    public void release();
-
     public &lt;Context&gt; Context getContext();
     public &lt;Context&gt; void setContext(Context context);
 
     public void suspend();
     public void resume();
 
-    public void setFinalizer(Runnable finalizer);
     public void setTargetQueue(DispatchQueue queue);
     public DispatchQueue getTargetQueue();
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchPriority.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchPriority.java?rev=887630&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchPriority.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchPriority.java Sun Dec  6 02:52:35 2009
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch;
+
+public enum DispatchPriority {
+    HIGH,
+    DEFAULT,
+    LOW;
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -16,16 +16,19 @@
  */
 package org.apache.activemq.dispatch;
 
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+
 /**
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public interface DispatchQueue extends DispatchObject {
+public interface DispatchQueue extends DispatchObject, Executor {
 
     public void dispatchAsync(Runnable runnable);
     public void dispatchSync(Runnable runnable) throws InterruptedException;
     
-    public void dispatchAfter(long delayMS, Runnable runnable);
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit);
     public void dispatchApply(int iterations, Runnable runnable) throws InterruptedException;
     
     String getLabel();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSPI.java Sun Dec  6 02:52:35 2009
@@ -19,15 +19,16 @@
 
 import java.nio.channels.SelectableChannel;
 
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
 
-public interface DispatchSPI {
+public interface DispatchSPI extends Retained {
     public void start();
     public void shutdown(Runnable onShutdown);
     
     public DispatchQueue getMainQueue();
-    public DispatchQueue getGlobalQueue(DispatchQueuePriority priority);
+    public DispatchQueue getGlobalQueue();
+    public DispatchQueue getGlobalQueue(DispatchPriority priority);
     public DispatchQueue createQueue(String label);
     public void dispatchMain();
     public DispatchSource createSource(SelectableChannel channel, int interestOps, DispatchQueue queue);
+    
 }
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java Sun Dec  6 02:52:35 2009
@@ -26,26 +26,24 @@
  */
 public class DispatchSystem {
 
-    public static enum DispatchQueuePriority {
-        HIGH,
-        DEFAULT,
-        LOW;
-    }
-
     public final static ThreadLocal&lt;DispatchQueue&gt; CURRENT_QUEUE = new ThreadLocal&lt;DispatchQueue&gt;();
     static public DispatchQueue getCurrentQueue() {
         return CURRENT_QUEUE.get();
     }
 
     private static DispatchSPI spi;
-    
-    private static DispatchSPI cretateDispatchSystemSPI() {
-        return new SimpleDispatchSPI(Runtime.getRuntime().availableProcessors());
+
+    public static DispatchSPI create() {
+        return create("system", Runtime.getRuntime().availableProcessors());
+    }
+
+    public static SimpleDispatchSPI create(String name, int threads) {
+        return new SimpleDispatchSPI(name, threads);
     }
     
     synchronized public static DispatchSPI spi() {
         if(spi==null) {
-            spi = cretateDispatchSystemSPI();
+            spi = create();
         }
         return spi;
     }
@@ -54,7 +52,11 @@
         return spi().getMainQueue();
     }
     
-    static public DispatchQueue getGlobalQueue(DispatchQueuePriority priority) {
+    static public DispatchQueue getGlobalQueue() {
+        return spi().getGlobalQueue();
+    }
+    
+    static public DispatchQueue getGlobalQueue(DispatchPriority priority) {
         return spi().getGlobalQueue(priority);
     }
     

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatcherAware.java Sun Dec  6 02:52:35 2009
@@ -1,15 +1,14 @@
 package org.apache.activemq.dispatch;
 
-import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 
 /**
- * Handy interface to signal classes which would like an IDispatcher instance
+ * Handy interface to signal classes which would like an DispatchSPI instance
  * injected into them.
  *  
  * @author chirino
  */
 public interface DispatcherAware {
 
-	public void setDispatcher(AdvancedDispatchSPI dispatcher);
+	public void setDispatcher(DispatchSPI dispatcher);
 	
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java?rev=887630&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/Retained.java Sun Dec  6 02:52:35 2009
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.dispatch;
+
+/**
+ * 
+ * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
+ */
+public interface Retained {
+    
+    public void retain();
+    public void release();
+    public void setShutdownHandler(Runnable shutdownHandler);
+
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java Sun Dec  6 02:52:35 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.dispatch.internal;
 
-import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.activemq.dispatch.DispatchObject;
 import org.apache.activemq.dispatch.DispatchQueue;
 
@@ -25,11 +23,10 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-abstract public class AbstractDispatchObject implements DispatchObject {
+abstract public class AbstractDispatchObject extends BaseRetained implements DispatchObject {
 
     protected volatile Object context;
     protected volatile DispatchQueue targetQueue;
-    protected AtomicReference&lt;Runnable&gt; finalizer = new AtomicReference&lt;Runnable&gt;();
 
     @SuppressWarnings("unchecked")
     public &lt;Context&gt; Context getContext() {
@@ -40,10 +37,6 @@
         this.context = context;
     }
 
-    public void setFinalizer(Runnable finalizer) {
-        this.finalizer.set(finalizer);
-    }
-
     public void setTargetQueue(DispatchQueue targetQueue) {
         this.targetQueue = targetQueue;
     }
@@ -51,4 +44,6 @@
     public DispatchQueue getTargetQueue() {
         return this.targetQueue;
     }
+    
+
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java?rev=887630&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/BaseRetained.java Sun Dec  6 02:52:35 2009
@@ -0,0 +1,29 @@
+package org.apache.activemq.dispatch.internal;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class BaseRetained {
+    
+    final protected AtomicInteger reatinCounter = new AtomicInteger(1);
+    final protected AtomicReference&lt;Runnable&gt; shutdownHandler = new AtomicReference&lt;Runnable&gt;();
+
+    public void setShutdownHandler(Runnable finalizer) {
+        this.shutdownHandler.set(finalizer);
+    }
+    
+    public void retain() {
+        int prev = reatinCounter.getAndIncrement();
+        assert prev!=0;
+    }
+
+    public void release() {
+        if( reatinCounter.decrementAndGet()==0 ) {
+            Runnable value = shutdownHandler.getAndSet(null);
+            if( value!=null ) {
+                value.run();
+            }
+        }
+    }
+
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -17,6 +17,7 @@
 package org.apache.activemq.dispatch.internal;
 
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -31,7 +32,6 @@
 
     private final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
     final private String label;
-    final private AtomicInteger reatinCounter = new AtomicInteger(1);
     final private AtomicInteger suspendCounter = new AtomicInteger();
     final private AtomicLong size = new AtomicLong();
     
@@ -57,10 +57,14 @@
         suspendCounter.incrementAndGet();
     }
 
-    public void dispatchAfter(long delayMS, Runnable runnable) {
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
         throw new RuntimeException("TODO: implement me.");
     }
 
+    public void execute(Runnable command) {
+        dispatchAsync(command);
+    }
+
     public void dispatchAsync(Runnable runnable) {
         if( runnable == null ) {
             throw new IllegalArgumentException();
@@ -112,18 +116,4 @@
         QueueSupport.dispatchApply(this, iterations, runnable);
     }
 
-    public void retain() {
-        int prev = reatinCounter.getAndIncrement();
-        assert prev!=0;
-    }
-
-    public void release() {
-        if( reatinCounter.decrementAndGet()==0 ) {
-            Runnable value = finalizer.getAndSet(null);
-            if( value!=null ) {
-                value.run();
-            }
-        }
-    }
-
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java Sun Dec  6 02:52:35 2009
@@ -25,14 +25,18 @@
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchSPI;
 import org.apache.activemq.dispatch.DispatchSource;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
-import static org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority.*;
+import static org.apache.activemq.dispatch.DispatchPriority.*;
 
-public class AdvancedDispatchSPI implements DispatchSPI {
+import static org.apache.activemq.dispatch.DispatchPriority.*;
+
+
+public class AdvancedDispatchSPI extends BaseRetained implements DispatchSPI {
 
     final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
     final GlobalDispatchQueue globalQueues[];
@@ -56,7 +60,7 @@
         
         globalQueues = new GlobalDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
-            globalQueues[i] = new GlobalDispatchQueue(this, DispatchQueuePriority.values()[i]);
+            globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i]);
         }
         
         loadBalancer = new SimpleLoadBalancer();
@@ -198,13 +202,17 @@
         return mainQueue;
     }
     
-    public DispatchQueue getGlobalQueue(DispatchQueuePriority priority) {
+    public DispatchQueue getGlobalQueue() {
+        return getGlobalQueue(DEFAULT);
+    }
+
+    public DispatchQueue getGlobalQueue(DispatchPriority priority) {
         return globalQueues[priority.ordinal()];
     }
     
     public DispatchQueue createQueue(String label) {
         AdvancedSerialDispatchQueue rc = new AdvancedSerialDispatchQueue(label);
-        rc.setTargetQueue(getGlobalQueue(DEFAULT));
+        rc.setTargetQueue(getGlobalQueue());
         return rc;
     }
     

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java Sun Dec  6 02:52:35 2009
@@ -24,8 +24,8 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchSystem;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
 import org.apache.activemq.util.Mapper;
 import org.apache.activemq.util.PriorityLinkedList;
 import org.apache.activemq.util.TimerHeap;
@@ -79,7 +79,7 @@
         
         this.dispatchQueues = new ThreadDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
-            dispatchQueues[i] = new ThreadDispatchQueue(this, DispatchQueuePriority.values()[i]);
+            dispatchQueues[i] = new ThreadDispatchQueue(this, DispatchPriority.values()[i]);
         }
 
         MAX_USER_PRIORITY = priorities - 1;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -19,7 +19,7 @@
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
 
 /**
@@ -30,9 +30,9 @@
 
     private final String label;
     private final AdvancedDispatchSPI spi;
-    private final DispatchQueuePriority priority;
+    private final DispatchPriority priority;
     
-    public GlobalDispatchQueue(AdvancedDispatchSPI spi, DispatchQueuePriority priority) {
+    public GlobalDispatchQueue(AdvancedDispatchSPI spi, DispatchPriority priority) {
         this.spi = spi;
         this.priority = priority;
         this.label=priority.toString();
@@ -42,12 +42,16 @@
         return label;
     }
 
+    public void execute(Runnable runnable) {
+        dispatchAsync(runnable);
+    }
+
     public void dispatchAsync(Runnable runnable) {
         spi.execute(runnable, priority.ordinal());
     }
 
-    public void dispatchAfter(long delayMS, Runnable runnable) {
-        spi.schedule(runnable, priority.ordinal(), delayMS, TimeUnit.MILLISECONDS);
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+        spi.schedule(runnable, priority.ordinal(), delay, TimeUnit.MILLISECONDS);
     }
 
     public void dispatchSync(final Runnable runnable) throws InterruptedException {
@@ -74,7 +78,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setFinalizer(Runnable finalizer) {
+    public void setShutdownHandler(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -19,7 +19,7 @@
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
 
 /**
@@ -30,9 +30,9 @@
 
     private final String label;
     private final DispatcherThread dispatcher;
-    private final DispatchQueuePriority priority;
+    private final DispatchPriority priority;
     
-    public ThreadDispatchQueue(DispatcherThread dispatcher, DispatchQueuePriority priority) {
+    public ThreadDispatchQueue(DispatcherThread dispatcher, DispatchPriority priority) {
         this.priority = priority;
         this.label=priority.toString()+" "+dispatcher.getName();
         this.dispatcher = dispatcher;
@@ -42,12 +42,16 @@
         return label;
     }
 
+    public void execute(Runnable runnable) {
+        dispatchAsync(runnable);
+    }
+
     public void dispatchAsync(Runnable runnable) {
         dispatcher.execute(runnable, priority.ordinal());
     }
 
-    public void dispatchAfter(long delayMS, Runnable runnable) {
-        dispatcher.schedule(runnable, priority.ordinal(), delayMS, TimeUnit.MILLISECONDS);
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+        dispatcher.schedule(runnable, priority.ordinal(), delay, TimeUnit.MILLISECONDS);
     }
 
     public void dispatchSync(final Runnable runnable) throws InterruptedException {
@@ -74,7 +78,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setFinalizer(Runnable finalizer) {
+    public void setShutdownHandler(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java?rev=887630&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatchObserver.java Sun Dec  6 02:52:35 2009
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal.simple;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchSource;
+
+public interface DispatchObserver {
+    
+    public void onThreadCreate(DispatcherThread thread);
+    public void onThreadDestroy(DispatcherThread thread);
+
+    public void onQueueCreate(DispatchQueue queue);
+    public void onQueueDestroy(DispatchQueue queue);
+    
+    public void onSourceCreate(DispatchSource source);
+    public void onSourceDestroy(DispatchSource source);
+    
+    public void onDispatchRequest(DispatchQueue target, Runnable request);
+
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/DispatcherThread.java Sun Dec  6 02:52:35 2009
@@ -19,8 +19,8 @@
 
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchSystem;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
 
 /**
  * 
@@ -36,9 +36,9 @@
         this.spi = spi;
         this.threadQueues = new ThreadDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
-            threadQueues[i] = new ThreadDispatchQueue(this, DispatchQueuePriority.values()[i] );
+            threadQueues[i] = new ThreadDispatchQueue(this, DispatchPriority.values()[i] );
         }
-        setName("dispatcher:"+(ordinal+1));
+        setName(spi.getLabel()+" dispatcher: "+(ordinal+1));
         setDaemon(true);
     }
     

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -17,10 +17,11 @@
 package org.apache.activemq.dispatch.internal.simple;
 
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
 
 /**
@@ -29,31 +30,35 @@
  */
 public class GlobalDispatchQueue implements SimpleQueue {
 
-    private final SimpleDispatchSPI system;
+    private final SimpleDispatchSPI spi;
     final String label;
     final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
     final AtomicLong counter;
-    private final DispatchQueuePriority priority;
+    private final DispatchPriority priority;
 
-    public GlobalDispatchQueue(SimpleDispatchSPI system, DispatchQueuePriority priority) {
-        this.system = system;
+    public GlobalDispatchQueue(SimpleDispatchSPI spi, DispatchPriority priority) {
+        this.spi = spi;
         this.priority = priority;
         this.label=priority.toString();
-        this.counter = system.globalQueuedRunnables;
+        this.counter = spi.globalQueuedRunnables;
     }
 
     public String getLabel() {
         return label;
     }
 
+    public void execute(Runnable runnable) {
+        dispatchAsync(runnable);
+    }
+
     public void dispatchAsync(Runnable runnable) {
         this.counter.incrementAndGet();
         runnables.add(runnable);
-        system.wakeup();
+        spi.wakeup();
     }
 
-    public void dispatchAfter(long delayMS, Runnable runnable) {
-        throw new RuntimeException("TODO: implement me.");
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+        spi.timerThread.addRelative(runnable, this, delay, unit);
     }
 
     public void dispatchSync(final Runnable runnable) throws InterruptedException {
@@ -80,7 +85,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setFinalizer(Runnable finalizer) {
+    public void setShutdownHandler(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 
@@ -100,7 +105,7 @@
         return rc;
     }
 
-    public DispatchQueuePriority getPriority() {
+    public DispatchPriority getPriority() {
         return priority;
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleDispatchSPI.java Sun Dec  6 02:52:35 2009
@@ -18,16 +18,19 @@
 
 import java.nio.channels.SelectableChannel;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.DispatchSPI;
 import org.apache.activemq.dispatch.DispatchSource;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.internal.BaseRetained;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
-import static org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority.*;
+import static org.apache.activemq.dispatch.DispatchPriority.*;
+
 
 
 /**
@@ -35,7 +38,7 @@
  * 
  * @author &lt;a href="http://hiramchirino.com"&gt;Hiram Chirino&lt;/a&gt;
  */
-public class SimpleDispatchSPI implements DispatchSPI {
+public class SimpleDispatchSPI extends BaseRetained implements DispatchSPI {
         
     final SerialDispatchQueue mainQueue = new SerialDispatchQueue("main");
     final GlobalDispatchQueue globalQueues[]; 
@@ -45,26 +48,38 @@
     final ConcurrentLinkedQueue&lt;DispatcherThread&gt; waitingDispatchers = new ConcurrentLinkedQueue&lt;DispatcherThread&gt;();
     final AtomicInteger waitingDispatcherCount = new AtomicInteger();
     final AtomicInteger startCounter = new AtomicInteger();
+    private final String label;
+    TimerThread timerThread;
     
-    public SimpleDispatchSPI(int size) {
+    public SimpleDispatchSPI(String label, int size) {
+        this.label = label;
         globalQueues = new GlobalDispatchQueue[3];
         for (int i = 0; i &lt; 3; i++) {
-            globalQueues[i] = new GlobalDispatchQueue(this, DispatchQueuePriority.values()[i] );
+            globalQueues[i] = new GlobalDispatchQueue(this, DispatchPriority.values()[i] );
         }
         dispatchers = new DispatcherThread[size];
     }
-    
+
     public DispatchQueue getMainQueue() {
         return mainQueue;
     }
     
-    public DispatchQueue getGlobalQueue(DispatchQueuePriority priority) {
+    public DispatchQueue getGlobalQueue() {
+        return getGlobalQueue(DEFAULT);
+    }
+
+    public DispatchQueue getGlobalQueue(DispatchPriority priority) {
         return globalQueues[priority.ordinal()];
     }
     
     public DispatchQueue createQueue(String label) {
-        SerialDispatchQueue rc = new SerialDispatchQueue(label);
-        rc.setTargetQueue(getGlobalQueue(DEFAULT));
+        SerialDispatchQueue rc = new SerialDispatchQueue(label) {
+            @Override
+            public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
+                timerThread.addRelative(runnable, this, delay, unit);
+            }
+        };
+        rc.setTargetQueue(getGlobalQueue());
         return rc;
     }
     
@@ -98,26 +113,34 @@
                 dispatchers[i] = new DispatcherThread(this, i);
                 dispatchers[i].start();
             }
+            timerThread = new TimerThread(this);
+            timerThread.start();
         }
     }
 
     public void shutdown(final Runnable onShutdown) {
         if( startCounter.decrementAndGet()==0 ) {
             
-            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.length);
+            final AtomicInteger shutdownCountDown = new AtomicInteger(dispatchers.length+1);
+            Runnable wrapper = new Runnable() {
+                public void run() {
+                    if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null) {
+                        onShutdown.run();
+                    }
+                    throw new DispatcherThread.Shutdown();
+                }
+            };
+
+            timerThread.shutdown(wrapper);
             for (int i = 0; i &lt; dispatchers.length; i++) {
                 ThreadDispatchQueue queue = dispatchers[i].threadQueues[LOW.ordinal()];
-                queue.runnables.add(new Runnable() {
-                    public void run() {
-                        if( shutdownCountDown.decrementAndGet()==0 &amp;&amp; onShutdown!=null) {
-                            onShutdown.run();
-                        }
-                        throw new DispatcherThread.Shutdown();
-                    }
-                });
+                queue.runnables.add(wrapper);
             }
         }
     }
 
+    public String getLabel() {
+        return label;
+    }
     
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/SimpleQueue.java Sun Dec  6 02:52:35 2009
@@ -1,10 +1,10 @@
 package org.apache.activemq.dispatch.internal.simple;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.DispatchPriority;
 
 public interface SimpleQueue extends DispatchQueue {
 
     Runnable poll();
-    DispatchQueuePriority getPriority();
+    DispatchPriority getPriority();
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java Sun Dec  6 02:52:35 2009
@@ -18,10 +18,11 @@
 
 import java.util.LinkedList;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.dispatch.DispatchQueue;
-import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
+import org.apache.activemq.dispatch.DispatchPriority;
 import org.apache.activemq.dispatch.internal.QueueSupport;
 
 /**
@@ -35,9 +36,9 @@
     final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
     private DispatcherThread dispatcher;
     final AtomicLong counter;
-    private final DispatchQueuePriority priority;
+    private final DispatchPriority priority;
     
-    public ThreadDispatchQueue(DispatcherThread dispatcher, DispatchQueuePriority priority) {
+    public ThreadDispatchQueue(DispatcherThread dispatcher, DispatchPriority priority) {
         this.dispatcher = dispatcher;
         this.priority = priority;
         this.label=priority.toString();
@@ -48,6 +49,10 @@
         return label;
     }
 
+    public void execute(Runnable runnable) {
+        dispatchAsync(runnable);
+    }
+    
     public void dispatchAsync(Runnable runnable) {
         // We don't have to take the synchronization hit 
         // if the current thread is the dispatcher since we know it's not
@@ -79,7 +84,7 @@
         return rc;
     }
 
-    public void dispatchAfter(long delayMS, Runnable runnable) {
+    public void dispatchAfter(Runnable runnable, long delay, TimeUnit unit) {
         throw new RuntimeException("TODO: implement me.");
     }
 
@@ -107,7 +112,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public void setFinalizer(Runnable finalizer) {
+    public void setShutdownHandler(Runnable finalizer) {
         throw new UnsupportedOperationException();
     }
 
@@ -118,8 +123,7 @@
         throw new UnsupportedOperationException();
     }
     
-    
-    public DispatchQueuePriority getPriority() {
+    public DispatchPriority getPriority() {
         return priority;
     }
 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java?rev=887630&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/TimerThread.java Sun Dec  6 02:52:35 2009
@@ -0,0 +1,138 @@
+package org.apache.activemq.dispatch.internal.simple;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.util.TimerHeap;
+
+import static org.apache.activemq.dispatch.internal.simple.TimerThread.Type.*;
+
+public class TimerThread extends Thread {
+    enum Type {
+        RELATIVE,
+        ABSOLUTE,
+        SHUTDOWN
+    }
+    final private static class TimerRequest {
+        Type type;
+        long time;
+        TimeUnit unit;
+        Runnable runnable;
+        DispatchQueue target;
+    }
+
+    private final Object mutex = new Object();
+    private ArrayList&lt;TimerRequest&gt; requests = new ArrayList&lt;TimerRequest&gt;();
+    
+    public TimerThread(SimpleDispatchSPI spi) {
+        setName(spi.getLabel()+" timer");
+        setDaemon(true);
+    }
+
+    public final void addAbsolute(Runnable runnable, DispatchQueue target, long time, TimeUnit unit) {
+        TimerRequest request = new TimerRequest();
+        request.type = ABSOLUTE;
+        request.time = time;
+        request.unit = unit;
+        request.runnable = runnable;
+        request.target = target;
+        add(request);
+    }
+
+    public final void addRelative(Runnable runnable, DispatchQueue target, long delay, TimeUnit unit) {
+        TimerRequest request = new TimerRequest();
+        request.type = RELATIVE;
+        request.time = delay;
+        request.unit = unit;
+        request.runnable = runnable;
+        request.target = target;
+        add(request);
+    }
+
+    public final void shutdown(Runnable onShutdown) {
+        TimerRequest request = new TimerRequest();
+        request.type = SHUTDOWN;
+        request.runnable = onShutdown;
+        add(request);
+    }
+
+    private void add(TimerRequest request) {
+        synchronized(mutex) {
+            requests.add(request);
+            mutex.notify();
+        }
+    }
+
+    public void run() {
+        
+        final TimerHeap&lt;TimerRequest&gt; timerHeap = new TimerHeap&lt;TimerRequest&gt;() {
+            @Override
+            protected final void execute(TimerRequest request) {
+                request.target.dispatchAsync(request.runnable);
+            }
+        };
+        
+        ArrayList&lt;TimerRequest&gt; swaped = new ArrayList&lt;TimerRequest&gt;();
+        
+        try {
+            for(;;) {
+
+                synchronized(mutex) {
+                    // Swap the arrays.
+                    ArrayList&lt;TimerRequest&gt; t = requests;
+                    requests = swaped;
+                    swaped = t;
+                }
+                
+                if( !swaped.isEmpty() ) {
+                    for (TimerRequest request : swaped) {
+                        switch( request.type ) {
+                        case RELATIVE:
+                            timerHeap.addRelative(request, request.time, request.unit);
+                            break;
+                        case ABSOLUTE:
+                            timerHeap.addAbsolute(request, request.time, request.unit);
+                            break;
+                        case SHUTDOWN:
+                            if( request.runnable!=null ) {
+                                request.runnable.run();
+                            }
+                            return;
+                        }
+                    }
+                    swaped.clear();
+                }
+                
+                timerHeap.executeReadyTimers();
+
+                long start = System.nanoTime();
+                long next = timerHeap.timeToNext(TimeUnit.NANOSECONDS);
+                
+                if( next==0 ) {
+                    continue;
+                }
+                
+                // if it's coming up soon.. just spin..
+                if( next&gt;0 &amp;&amp; next &lt; 1000 ) {
+                    while( System.nanoTime()-start &lt; next ) {
+                    }
+                    continue;
+                }
+                
+                long waitms = next / 1000000;
+                int waitns = (int) (next % 1000000);
+                synchronized(mutex) {
+                    if( requests.isEmpty() ) {
+                        if(next==-1) {
+                            mutex.wait();
+                        }  else {
+                            mutex.wait(waitms, waitns);
+                        }
+                    }
+                }                
+            }
+        } catch (InterruptedException e) {
+        }
+    }
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887630&amp;r1=887629&amp;r2=887630&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java Sun Dec  6 02:52:35 2009
@@ -22,8 +22,9 @@
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.dispatch.internal.simple.SimpleDispatchSPI;
 
+import static org.apache.activemq.dispatch.DispatchPriority.*;
+
 import static java.lang.String.*;
-import static org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority.*;
 
 /**
  * 
@@ -41,7 +42,7 @@
         advancedSystem.shutdown(latch);
         latch.await();
 
-        DispatchSPI simpleSystem = new SimpleDispatchSPI(Runtime.getRuntime().availableProcessors());
+        DispatchSPI simpleSystem = new SimpleDispatchSPI("test", Runtime.getRuntime().availableProcessors());
         simpleSystem.start();
         
         benchmark("simple global queue", simpleSystem, simpleSystem.getGlobalQueue(DEFAULT));




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887588 - in /activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src: examples/consumers/SimpleAsyncConsumer.cpp examples/main.cpp examples/producers/SimpleProducer.cpp main/activemq/core/ActiveMQSession.cpp</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091205205229.0FE2F23888E9@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205205229-0FE2F23888E9@eris-apache-org%3e</id>
<updated>2009-12-05T20:52:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sat Dec  5 20:52:26 2009
New Revision: 887588

URL: http://svn.apache.org/viewvc?rev=887588&amp;view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-271

Change the example code so that the shutdown is performed properly.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/main.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/producers/SimpleProducer.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp?rev=887588&amp;r1=887587&amp;r2=887588&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
Sat Dec  5 20:52:26 2009
@@ -77,7 +77,11 @@
     }
 
     virtual ~SimpleAsyncConsumer(){
-        cleanup();
+        this-&gt;cleanup();
+    }
+
+    void close() {
+        this-&gt;cleanup();
     }
 
     void runConsumer() {
@@ -156,7 +160,7 @@
     // registered as an ExceptionListener with the connection.
     virtual void onException( const CMSException&amp; ex AMQCPP_UNUSED ) {
         printf("CMS Exception occurred.  Shutting down client.\n");
-        exit(1);
+        //exit(1);
     }
 
     virtual void transportInterrupted() {
@@ -179,29 +183,29 @@
         // Destroy resources.
         try{
             if( destination != NULL ) delete destination;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         destination = NULL;
 
         try{
             if( consumer != NULL ) delete consumer;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         consumer = NULL;
 
         // Close open resources.
         try{
             if( session != NULL ) session-&gt;close();
             if( connection != NULL ) connection-&gt;close();
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
 
         // Now Destroy them
         try{
             if( session != NULL ) delete session;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         session = NULL;
 
         try{
             if( connection != NULL ) delete connection;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         connection = NULL;
     }
 };
@@ -270,6 +274,9 @@
     std::cout &lt;&lt; "Press 'q' to quit" &lt;&lt; std::endl;
     while( std::cin.get() != 'q') {}
 
+    // All CMS resources should be closed before the library is shutdown.
+    consumer.close();
+
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;
     std::cout &lt;&lt; "=====================================================\n";

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/main.cpp?rev=887588&amp;r1=887587&amp;r2=887588&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/main.cpp Sat
Dec  5 20:52:26 2009
@@ -76,6 +76,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     virtual void run() {
 
         try {
@@ -199,6 +203,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     void waitUntilReady() {
         latch.await();
     }
@@ -400,6 +408,9 @@
     long long endTime = System::currentTimeMillis();
     double totalTime = (endTime - startTime) / 1000.0;
 
+    consumer.close();
+    producer.close();
+
     std::cout &lt;&lt; "Time to completion = " &lt;&lt; totalTime &lt;&lt; " seconds." &lt;&lt;
std::endl;
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/producers/SimpleProducer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/producers/SimpleProducer.cpp?rev=887588&amp;r1=887587&amp;r2=887588&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/producers/SimpleProducer.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/examples/producers/SimpleProducer.cpp
Sat Dec  5 20:52:26 2009
@@ -81,6 +81,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     virtual void run() {
         try {
             // Create a ConnectionFactory
@@ -226,6 +230,7 @@
     // Create the producer and run it.
     SimpleProducer producer( brokerURI, numMessages, destURI, useTopics );
     producer.run();
+    producer.close();
 
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=887588&amp;r1=887587&amp;r2=887588&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.1.x/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
Sat Dec  5 20:52:26 2009
@@ -118,6 +118,9 @@
 
     try {
 
+        // Now indicate that this session is closed.
+        closed = true;
+
         // Stop the dispatch executor.
         stop();
 
@@ -163,9 +166,6 @@
         info-&gt;setObjectId( this-&gt;sessionInfo-&gt;getSessionId() );
         info-&gt;setLastDeliveredSequenceId( this-&gt;lastDeliveredSequenceId );
         this-&gt;connection-&gt;oneway( info );
-
-        // Now indicate that this session is closed.
-        closed = true;
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887584 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: examples/consumers/SimpleAsyncConsumer.cpp examples/main.cpp examples/producers/SimpleProducer.cpp main/activemq/core/ActiveMQSession.cpp</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091205202038.BFB0D23888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205202038-BFB0D23888DC@eris-apache-org%3e</id>
<updated>2009-12-05T20:20:37Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Sat Dec  5 20:20:36 2009
New Revision: 887584

URL: http://svn.apache.org/viewvc?rev=887584&amp;view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-271

Change the example code so that the shutdown is performed properly.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp?rev=887584&amp;r1=887583&amp;r2=887584&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
Sat Dec  5 20:20:36 2009
@@ -77,7 +77,11 @@
     }
 
     virtual ~SimpleAsyncConsumer(){
-        cleanup();
+        this-&gt;cleanup();
+    }
+
+    void close() {
+        this-&gt;cleanup();
     }
 
     void runConsumer() {
@@ -156,7 +160,7 @@
     // registered as an ExceptionListener with the connection.
     virtual void onException( const CMSException&amp; ex AMQCPP_UNUSED ) {
         printf("CMS Exception occurred.  Shutting down client.\n");
-        exit(1);
+        //exit(1);
     }
 
     virtual void transportInterrupted() {
@@ -179,29 +183,29 @@
         // Destroy resources.
         try{
             if( destination != NULL ) delete destination;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         destination = NULL;
 
         try{
             if( consumer != NULL ) delete consumer;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         consumer = NULL;
 
         // Close open resources.
         try{
             if( session != NULL ) session-&gt;close();
             if( connection != NULL ) connection-&gt;close();
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
 
         // Now Destroy them
         try{
             if( session != NULL ) delete session;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         session = NULL;
 
         try{
             if( connection != NULL ) delete connection;
-        }catch (CMSException&amp; e) { e.printStackTrace(); }
+        }catch (CMSException&amp; e) {}
         connection = NULL;
     }
 };
@@ -270,6 +274,9 @@
     std::cout &lt;&lt; "Press 'q' to quit" &lt;&lt; std::endl;
     while( std::cin.get() != 'q') {}
 
+    // All CMS resources should be closed before the library is shutdown.
+    consumer.close();
+
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;
     std::cout &lt;&lt; "=====================================================\n";

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp?rev=887584&amp;r1=887583&amp;r2=887584&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp Sat Dec  5 20:20:36 2009
@@ -76,6 +76,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     virtual void run() {
 
         try {
@@ -199,6 +203,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     void waitUntilReady() {
         latch.await();
     }
@@ -400,6 +408,9 @@
     long long endTime = System::currentTimeMillis();
     double totalTime = (endTime - startTime) / 1000.0;
 
+    consumer.close();
+    producer.close();
+
     std::cout &lt;&lt; "Time to completion = " &lt;&lt; totalTime &lt;&lt; " seconds." &lt;&lt;
std::endl;
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp?rev=887584&amp;r1=887583&amp;r2=887584&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp Sat
Dec  5 20:20:36 2009
@@ -81,6 +81,10 @@
         cleanup();
     }
 
+    void close() {
+        this-&gt;cleanup();
+    }
+
     virtual void run() {
         try {
             // Create a ConnectionFactory
@@ -226,6 +230,7 @@
     // Create the producer and run it.
     SimpleProducer producer( brokerURI, numMessages, destURI, useTopics );
     producer.run();
+    producer.close();
 
     std::cout &lt;&lt; "-----------------------------------------------------\n";
     std::cout &lt;&lt; "Finished with the example." &lt;&lt; std::endl;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=887584&amp;r1=887583&amp;r2=887584&amp;view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Sat
Dec  5 20:20:36 2009
@@ -118,6 +118,9 @@
 
     try {
 
+        // Now indicate that this session is closed.
+        closed = true;
+
         // Stop the dispatch executor.
         stop();
 
@@ -163,9 +166,6 @@
         info-&gt;setObjectId( this-&gt;sessionInfo-&gt;getSessionId() );
         info-&gt;setLastDeliveredSequenceId( this-&gt;lastDeliveredSequenceId );
         this-&gt;connection-&gt;oneway( info );
-
-        // Now indicate that this session is closed.
-        closed = true;
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887564 - in /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch: ./ internal/ internal/advanced/</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091205164354.EEEBB2388978@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205164354-EEEBB2388978@eris-apache-org%3e</id>
<updated>2009-12-05T16:43:51Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sat Dec  5 16:43:47 2009
New Revision: 887564

URL: http://svn.apache.org/viewvc?rev=887564&amp;view=rev
Log:
simplifying the advanced package a bit

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ForeignEvent.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/TimerEvent.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/UpdateEvent.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchSystem.java
Sat Dec  5 16:43:47 2009
@@ -43,7 +43,7 @@
         return new SimpleDispatchSPI(Runtime.getRuntime().availableProcessors());
     }
     
-    synchronized private static DispatchSPI spi() {
+    synchronized public static DispatchSPI spi() {
         if(spi==null) {
             spi = cretateDispatchSystemSPI();
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
Sat Dec  5 16:43:47 2009
@@ -48,7 +48,7 @@
     public void resume() {
         if( suspendCounter.decrementAndGet() == 0 ) {
             if( size.get() != 0 ) {
-                targetQueue.dispatchAsync(this);
+                dispatchSelfAsync();
             }
         }
     }
@@ -71,10 +71,14 @@
         }
         runnables.add(runnable);
         if( lastSize == 0 &amp;&amp; suspendCounter.get()&lt;=0 ) {
-            targetQueue.dispatchAsync(this);
+            dispatchSelfAsync();
         }
     }
 
+    protected void dispatchSelfAsync() {
+        targetQueue.dispatchAsync(this);
+    }
+
     public void run() {
         DispatchQueue original = DispatchSystem.CURRENT_QUEUE.get();
         DispatchSystem.CURRENT_QUEUE.set(this);

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
Sat Dec  5 16:43:47 2009
@@ -38,8 +38,6 @@
     final GlobalDispatchQueue globalQueues[];
     final AtomicLong globalQueuedRunnables = new AtomicLong();
 
-    private final ThreadLocal&lt;DispatcherThread&gt; dispatcher = new ThreadLocal&lt;DispatcherThread&gt;();
-    private final ThreadLocal&lt;DispatchContext&gt; dispatcherContext = new ThreadLocal&lt;DispatchContext&gt;();
     private final ArrayList&lt;DispatcherThread&gt; dispatchers = new ArrayList&lt;DispatcherThread&gt;();
 
     final AtomicInteger startCounter = new AtomicInteger();
@@ -115,30 +113,12 @@
         }
     }
 
-    public void setCurrentDispatchContext(DispatchContext context) {
-        dispatcherContext.set(context);
-    }
-
-    public DispatchContext getCurrentDispatchContext() {
-        return dispatcherContext.get();
-    }
-
-    /**
-     * Returns the currently executing dispatcher, or null if the current thread
-     * is not a dispatcher:
-     * 
-     * @return The currently executing dispatcher
-     */
-    public DispatcherThread getCurrentDispatcher() {
-        return dispatcher.get();
-    }
-
     /**
      * A Dispatcher must call this to indicate that is has started it's dispatch
      * loop.
      */
     public void onDispatcherStarted(DispatcherThread d) {
-        dispatcher.set(d);
+        DispatcherThread.CURRENT.set(d);
         loadBalancer.onDispatcherStarted(d);
     }
 
@@ -159,7 +139,7 @@
     }
 
     protected DispatcherThread chooseDispatcher() {
-        DispatcherThread d = dispatcher.get();
+        DispatcherThread d = DispatcherThread.CURRENT.get();
         if (d == null) {
             synchronized (dispatchers) {
                 if(dispatchers.isEmpty())
@@ -223,7 +203,7 @@
     }
     
     public DispatchQueue createQueue(String label) {
-        SerialDispatchQueue rc = new SerialDispatchQueue(label);
+        AdvancedSerialDispatchQueue rc = new AdvancedSerialDispatchQueue(label);
         rc.setTargetQueue(getGlobalQueue(DEFAULT));
         return rc;
     }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedQueue.java?rev=887564&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedQueue.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedQueue.java
Sat Dec  5 16:43:47 2009
@@ -0,0 +1,5 @@
+package org.apache.activemq.dispatch.internal.advanced;
+
+public interface AdvancedQueue {
+
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java?rev=887564&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedSerialDispatchQueue.java
Sat Dec  5 16:43:47 2009
@@ -0,0 +1,19 @@
+package org.apache.activemq.dispatch.internal.advanced;
+
+import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
+
+public class AdvancedSerialDispatchQueue extends SerialDispatchQueue {
+
+    
+    public AdvancedSerialDispatchQueue(String label) {
+        super(label);
+//        context = new DispatchContext(this, true, label);
+}
+    
+//    @Override
+//    protected void dispatchSelfAsync() {
+//        AdvancedQueue aq = ((AdvancedQueue)targetQueue);
+//        super.dispatchSelfAsync();
+//    }
+
+}

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
Sat Dec  5 16:43:47 2009
@@ -3,29 +3,30 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.RejectedExecutionException;
 
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread.UpdateEvent;
 import org.apache.activemq.util.list.LinkedNode;
 
 /**
  * 
  */
-class DispatchContext extends LinkedNode&lt;DispatchContext&gt; {
+class DispatchContext extends LinkedNode&lt;DispatchContext&gt; implements Runnable {
+    
+    public static final ThreadLocal&lt;DispatchContext&gt; CURRENT = new ThreadLocal&lt;DispatchContext&gt;();
 
-    private final DispatcherThread dispacher;
     // The target:
     private final Runnable runnable;
     // The name of this context:
-    final String name;
+    final String label;
+
     // list prio can only be updated in the thread of of the owning
     // dispatcher
     protected int listPrio;
 
     // The update events are used to update fields in the dispatch context
     // from foreign threads:
-    final UpdateEvent updateEvent[];
+    final UpdateEvent updateEvent[] = new UpdateEvent[2];
 
     final DispatchObserver tracker;
-    protected DispatcherThread currentOwner;
+    protected DispatcherThread target;
     private DispatcherThread updateDispatcher = null;
 
     int priority;
@@ -33,36 +34,22 @@
     private boolean closed = false;
     final CountDownLatch closeLatch = new CountDownLatch(1);
 
-    protected DispatchContext(DispatcherThread dispatcherThread, Runnable runnable, boolean
persistent, String name) {
-        dispacher = dispatcherThread;
+    protected DispatchContext(DispatcherThread thread, Runnable runnable, boolean persistent,
String label) {
         this.runnable = runnable;
-        this.name = name;
-        this.currentOwner = (DispatcherThread) dispacher;
-        if (persistent &amp;&amp; dispacher.spi != null) {
-            this.tracker = dispacher.spi.getLoadBalancer().createExecutionTracker((DispatchContext)
this);
+        this.label = label;
+        this.target = thread;
+        if (persistent &amp;&amp; target.spi != null) {
+            this.tracker = target.spi.getLoadBalancer().createExecutionTracker((DispatchContext)
this);
         } else {
             this.tracker = null;
         }
-        updateEvent = createUpdateEvent();
-        updateEvent[0] = dispacher.new UpdateEvent(this);
-        updateEvent[1] = dispacher.new UpdateEvent(this);
+        updateEvent[0] = new UpdateEvent(this);
+        updateEvent[1] = new UpdateEvent(this);
         if (persistent) {
-            currentOwner.takeOwnership(this);
+            target.takeOwnership(this);
         }
     }
 
-    private final DispatcherThread.UpdateEvent[] createUpdateEvent() {
-        return new DispatcherThread.UpdateEvent[2];
-    }
-
-    /**
-     * Gets the execution tracker for the context.
-     * 
-     * @return the execution tracker for the context:
-     */
-    public DispatchObserver getExecutionTracker() {
-        return tracker;
-    }
 
     /**
      * This can only be called by the owning dispatch thread:
@@ -77,7 +64,7 @@
         synchronized (this) {
 
             // If we're already set to this dispatcher
-            if (newDispatcher == currentOwner) {
+            if (newDispatcher == target) {
                 if (updateDispatcher == null || updateDispatcher == newDispatcher) {
                     return;
                 }
@@ -85,18 +72,18 @@
 
             updateDispatcher = (DispatcherThread) newDispatcher;
             if (DispatcherThread.DEBUG)
-                System.out.println(getName() + " updating to " + updateDispatcher);
+                System.out.println(getLabel() + " updating to " + updateDispatcher);
 
-            currentOwner.onForeignUpdate(this);
+            target.onForeignUpdate(this);
         }
 
     }
 
     public void requestDispatch() {
 
-        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+        DispatcherThread callingDispatcher = DispatcherThread.CURRENT.get();
         if (tracker != null)
-            tracker.onDispatch(callingDispatcher, dispacher.getCurrentDispatchContext());
+            tracker.onDispatch(callingDispatcher, DispatchContext.CURRENT.get());
 
         // Otherwise this is coming off another thread, so we need to
         // synchronize
@@ -104,22 +91,22 @@
         synchronized (this) {
             // If the owner of this context is the calling thread, then
             // delegate to the dispatcher.
-            if (currentOwner == callingDispatcher) {
+            if (target == callingDispatcher) {
 
-                if (!currentOwner.running) {
+                if (!target.running) {
                     // TODO In the event that the current dispatcher
                     // failed due to a runtime exception, we could
                     // try to switch to a new dispatcher.
                     throw new RejectedExecutionException();
                 }
                 if (!isLinked()) {
-                    currentOwner.priorityQueue.add(this, listPrio);
+                    target.priorityQueue.add(this, listPrio);
                 }
                 return;
             }
 
             dispatchRequested = true;
-            currentOwner.onForeignUpdate(this);
+            target.onForeignUpdate(this);
         }
     }
 
@@ -129,12 +116,12 @@
             return;
         }
 
-        priority = Math.min(priority, dispacher.MAX_USER_PRIORITY);
+        priority = Math.min(priority, target.MAX_USER_PRIORITY);
 
         if (this.priority == priority) {
             return;
         }
-        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+        DispatcherThread callingDispatcher = DispatcherThread.CURRENT.get();
 
         // Otherwise this is coming off another thread, so we need to
         // synchronize to protect against ownership changes:
@@ -146,7 +133,7 @@
 
             // If this is called by the owning dispatcher, then we go ahead
             // and update:
-            if (currentOwner == callingDispatcher) {
+            if (target == callingDispatcher) {
 
                 if (priority != listPrio) {
 
@@ -155,13 +142,13 @@
                     // at the new priority:
                     if (isLinked()) {
                         unlink();
-                        currentOwner.priorityQueue.add(this, listPrio);
+                        target.priorityQueue.add(this, listPrio);
                     }
                 }
                 return;
             }
 
-            currentOwner.onForeignUpdate(this);
+            target.onForeignUpdate(this);
         }
 
     }
@@ -176,16 +163,16 @@
 
             if (updateDispatcher != null &amp;&amp; updateDispatcher.takeOwnership(this))
{
                 if (DispatcherThread.DEBUG) {
-                    System.out.println("Assigning " + getName() + " to " + updateDispatcher);
+                    System.out.println("Assigning " + getLabel() + " to " + updateDispatcher);
                 }
 
-                if (currentOwner.removeDispatchContext(this)) {
+                if (target.removeDispatchContext(this)) {
                     dispatchRequested = true;
                 }
 
                 updateDispatcher.onForeignUpdate(this);
-                switchedDispatcher(currentOwner, updateDispatcher);
-                currentOwner = updateDispatcher;
+                switchedDispatcher(target, updateDispatcher);
+                target = updateDispatcher;
                 updateDispatcher = null;
 
             } else {
@@ -199,14 +186,7 @@
         }
     }
 
-    /**
-     * May be overriden by subclass to additional work on dispatcher switch
-     * 
-     * @param oldDispatcher The old dispatcher
-     * @param newDispatcher The new Dispatcher
-     */
     protected void switchedDispatcher(DispatcherThread oldDispatcher, DispatcherThread newDispatcher)
{
-
     }
 
     public boolean isClosed() {
@@ -214,20 +194,20 @@
     }
 
     public void close(boolean sync) {
-        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+        DispatcherThread callingDispatcher = DispatcherThread.CURRENT.get();
         // System.out.println(this + "Closing");
         synchronized (this) {
             closed = true;
             // If the owner of this context is the calling thread, then
             // delegate to the dispatcher.
-            if (currentOwner == callingDispatcher) {
-                dispacher.removeDispatchContext(this);
+            if (target == callingDispatcher) {
+                target.removeDispatchContext(this);
                 closeLatch.countDown();
                 return;
             }
         }
 
-        currentOwner.onForeignUpdate(this);
+        target.onForeignUpdate(this);
         if (sync) {
             boolean interrupted = false;
             while (true) {
@@ -245,16 +225,12 @@
         }
     }
 
-    public final String toString() {
-        return getName();
-    }
-
     public DispatcherThread getTargetQueue() {
-        return currentOwner;
+        return target;
     }
 
-    public String getName() {
-        return name;
+    public String getLabel() {
+        return label;
     }
 
 }
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
Sat Dec  5 16:43:47 2009
@@ -29,11 +29,12 @@
 import org.apache.activemq.util.Mapper;
 import org.apache.activemq.util.PriorityLinkedList;
 import org.apache.activemq.util.TimerHeap;
-import org.apache.activemq.util.list.LinkedNode;
 import org.apache.activemq.util.list.LinkedNodeList;
 
 public class DispatcherThread implements Runnable {
 
+    static public final ThreadLocal&lt;DispatcherThread&gt; CURRENT = new ThreadLocal&lt;DispatcherThread&gt;();
+
     private final ThreadDispatchQueue dispatchQueues[];
     
     static final boolean DEBUG = false;
@@ -50,9 +51,10 @@
     protected final PriorityLinkedList&lt;DispatchContext&gt; priorityQueue;
 
     // Dispatch queue for requests from other threads:
-    private final LinkedNodeList&lt;ForeignEvent&gt;[] foreignQueue;
+    final LinkedNodeList&lt;ForeignEvent&gt;[] foreignQueue = createForeignQueue();
+
     private static final int[] TOGGLE = new int[] { 1, 0 };
-    private int foreignToggle = 0;
+    int foreignToggle = 0;
 
     // Timed Execution List
     protected final TimerHeap&lt;Runnable&gt; timerHeap = new TimerHeap&lt;Runnable&gt;()
{
@@ -63,7 +65,7 @@
     };
 
     protected final String name;
-    private final AtomicBoolean foreignAvailable = new AtomicBoolean(false);
+    final AtomicBoolean foreignAvailable = new AtomicBoolean(false);
     private final Semaphore foreignPermits = new Semaphore(0);
 
     private final Mapper&lt;Integer, DispatchContext&gt; PRIORITY_MAPPER = new Mapper&lt;Integer,
DispatchContext&gt;() {
@@ -82,33 +84,17 @@
 
         MAX_USER_PRIORITY = priorities - 1;
         priorityQueue = new PriorityLinkedList&lt;DispatchContext&gt;(MAX_USER_PRIORITY +
1, PRIORITY_MAPPER);
-        foreignQueue = createForeignEventQueue();
         for (int i = 0; i &lt; 2; i++) {
             foreignQueue[i] = new LinkedNodeList&lt;ForeignEvent&gt;();
         }
         this.spi = spi;
     }
-
+    
     @SuppressWarnings("unchecked")
-    private LinkedNodeList&lt;ForeignEvent&gt;[] createForeignEventQueue() {
+    private LinkedNodeList&lt;ForeignEvent&gt;[] createForeignQueue() {
         return new LinkedNodeList[2];
     }
 
-    protected abstract class ForeignEvent extends LinkedNode&lt;ForeignEvent&gt; {
-        public abstract void execute();
-
-        final void addToList() {
-            synchronized (foreignQueue) {
-                if (!this.isLinked()) {
-                    foreignQueue[foreignToggle].addLast(this);
-                    if (!foreignAvailable.getAndSet(true)) {
-                        wakeup();
-                    }
-                }
-            }
-        }
-    }
-
     public boolean isThreaded() {
         return threaded;
     }
@@ -121,19 +107,6 @@
         return MAX_USER_PRIORITY;
     }
 
-    class UpdateEvent extends ForeignEvent {
-        private final DispatchContext pdc;
-
-        UpdateEvent(DispatchContext pdc) {
-            this.pdc = pdc;
-        }
-
-        // Can only be called by the owner of this dispatch context:
-        public void execute() {
-            pdc.processForeignUpdates();
-        }
-    }
-
     public DispatchContext register(Runnable runnable, String name) {
         return new DispatchContext(this, runnable, true, name);
     }
@@ -202,11 +175,7 @@
 
     public void run() {
 
-        if (spi != null) {
-            // Inform the dispatcher that we have started:
-            spi.onDispatcherStarted((DispatcherThread) this);
-        }
-
+        spi.onDispatcherStarted((DispatcherThread) this);
         DispatchContext pdc;
         try {
             while (running) {
@@ -218,14 +187,14 @@
                     }
                     
                     if (pdc.tracker != null) {
-                        spi.setCurrentDispatchContext(pdc);
+                        DispatchContext.CURRENT.set(pdc);
                     }
 
                     counter++;
                     pdc.run();
 
                     if (pdc.tracker != null) {
-                        spi.setCurrentDispatchContext(null);
+                        DispatchContext.CURRENT.set(null);
                     }
                 }
 
@@ -256,7 +225,7 @@
                         }
 
                         fe.unlink();
-                        fe.execute();
+                        fe.run();
                     }
                 }
             }
@@ -265,9 +234,7 @@
         } catch (Throwable thrown) {
             thrown.printStackTrace();
         } finally {
-            if (spi != null) {
-                spi.onDispatcherStopped((DispatcherThread) this);
-            }
+            spi.onDispatcherStopped((DispatcherThread) this);
             cleanup();
         }
     }
@@ -354,13 +321,6 @@
         context.requestDispatch();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.activemq.dispatch.IDispatcher#dispatch(org.apache.activemq
-     * .dispatch.Dispatcher.Dispatchable)
-     */
     public final void dispatch(Runnable runnable, int priority) {
         DispatchContext context = new DispatchContext(this, runnable, false, name);
         context.updatePriority(priority);
@@ -390,13 +350,6 @@
         dispatch(runnable, prio);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.activemq.dispatch.IDispatcher#schedule(java.lang.Runnable,
-     * long, java.util.concurrent.TimeUnit)
-     */
     public void schedule(final Runnable runnable, final long delay, final TimeUnit timeUnit)
{
         schedule(runnable, 0, delay, timeUnit);
     }
@@ -407,36 +360,29 @@
                 execute(runnable, prio);
             }
         };
-        if (getCurrentDispatcher() == this) {
+        if (DispatcherThread.CURRENT.get() == this) {
             timerHeap.addRelative(wrapper, delay, timeUnit);
         } else {
-            new ForeignEvent() {
-                public void execute() {
-                    timerHeap.addRelative(wrapper, delay, timeUnit);
+            add(new TimerEvent(this, wrapper, delay, timeUnit));
+        }
+    }
+    
+    final void add(ForeignEvent event) {
+        synchronized (foreignQueue) {
+            if (!event.isLinked()) {
+                foreignQueue[foreignToggle].addLast(event);
+                if (!foreignAvailable.getAndSet(true)) {
+                    wakeup();
                 }
-            }.addToList();
+            }
         }
     }
 
+
     public String toString() {
         return name;
     }
 
-    final DispatcherThread getCurrentDispatcher() {
-        if (spi != null) {
-            return (DispatcherThread) spi.getCurrentDispatcher();
-        } else if (Thread.currentThread() == thread) {
-            return (DispatcherThread) this;
-        } else {
-            return null;
-        }
-
-    }
-
-    final DispatchContext getCurrentDispatchContext() {
-        return spi.getCurrentDispatchContext();
-    }
-
     public String getName() {
         return name;
     }

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ForeignEvent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ForeignEvent.java?rev=887564&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ForeignEvent.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ForeignEvent.java
Sat Dec  5 16:43:47 2009
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal.advanced;
+
+import org.apache.activemq.util.list.LinkedNode;
+
+abstract class ForeignEvent extends LinkedNode&lt;ForeignEvent&gt; implements Runnable {
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java?rev=887564&amp;r1=887563&amp;r2=887564&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java
Sat Dec  5 16:43:47 2009
@@ -28,7 +28,7 @@
 
     private final boolean DEBUG = false;
 
-    //TODO: Added plumbing for periodic rebalancing which we should
+    //TODO: Added plumbing for periodic re-balancing which we should
     //consider implementing
     private static final boolean ENABLE_UPDATES = false;
     private final ArrayList&lt;DispatcherThread&gt; dispatchers = new ArrayList&lt;DispatcherThread&gt;();

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/TimerEvent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/TimerEvent.java?rev=887564&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/TimerEvent.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/TimerEvent.java
Sat Dec  5 16:43:47 2009
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal.advanced;
+
+import java.util.concurrent.TimeUnit;
+
+final class TimerEvent extends ForeignEvent {
+
+    private final long delay;
+    private final Runnable wrapper;
+    private final TimeUnit timeUnit;
+    private final DispatcherThread thread;
+
+    public TimerEvent(DispatcherThread thread, Runnable wrapper, long delay, TimeUnit timeUnit)
{
+        this.thread = thread;
+        this.delay = delay;
+        this.wrapper = wrapper;
+        this.timeUnit = timeUnit;
+    }
+
+    public void run() {
+        thread.timerHeap.addRelative(wrapper, delay, timeUnit);
+    }
+}
\ No newline at end of file

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/UpdateEvent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/UpdateEvent.java?rev=887564&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/UpdateEvent.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/UpdateEvent.java
Sat Dec  5 16:43:47 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal.advanced;
+
+
+class UpdateEvent extends ForeignEvent {
+    protected final DispatchContext dispatchContext;
+
+    public UpdateEvent(DispatchContext dispatchContext) {
+        this.dispatchContext = dispatchContext;
+    }
+
+    // Can only be called by the owner of this dispatch context:
+    public void run() {
+        dispatchContext.processForeignUpdates();
+    }
+}
\ No newline at end of file




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887556 - /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091205162313.929D42388978@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205162313-929D42388978@eris-apache-org%3e</id>
<updated>2009-12-05T16:23:13Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Sat Dec  5 16:23:11 2009
New Revision: 887556

URL: http://svn.apache.org/viewvc?rev=887556&amp;view=rev
Log:
added some code that can dump the generated class file for inspection/debugging

Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java?rev=887556&amp;r1=887555&amp;r2=887556&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
Sat Dec  5 16:23:11 2009
@@ -7,8 +7,10 @@
  **************************************************************************************/
 package org.apache.activemq.actor;
 
+import java.io.FileOutputStream;
 import java.lang.reflect.Method;
 
+import net.sf.cglib.core.DefaultGeneratorStrategy;
 import net.sf.cglib.proxy.Enhancer;
 import net.sf.cglib.proxy.MethodInterceptor;
 import net.sf.cglib.proxy.MethodProxy;
@@ -31,6 +33,20 @@
         e.setSuperclass(target.getClass());
         e.setInterfaces(interfaces);
         e.setCallback(new ActorMethodInterceptor(queue));
+//      Un-comment the following if you want store the generated class file:
+//        e.setStrategy(new DefaultGeneratorStrategy() {
+//            protected byte[] transform(byte[] b) {
+//                try {
+//                    FileOutputStream os = new FileOutputStream("test.class");
+//                    os.write(b);
+//                    os.close();
+//                } catch (Throwable e) {
+//                    e.printStackTrace();
+//                }
+//                return b;
+//            }
+//        });
+
         return (T) e.create();
     }
 
@@ -50,7 +66,8 @@
     /**
      * Tests if a given method has a Message annotation
      * 
-     * @param method The mehod.
+     * @param method
+     *            The mehod.
      */
     private static boolean isMessage(Method method) {
         if (method.isAnnotationPresent(Message.class)) {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887448 - in /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src: main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java test/java/org/apache/activemq/actor/ActorTest.java</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204232530.DA45923888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204232530-DA45923888EC@eris-apache-org%3e</id>
<updated>2009-12-04T23:25:30Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Fri Dec  4 23:25:30 2009
New Revision: 887448

URL: http://svn.apache.org/viewvc?rev=887448&amp;view=rev
Log:
Redispatch the serial queue once resumed

Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887448&amp;r1=887447&amp;r2=887448&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
Fri Dec  4 23:25:30 2009
@@ -46,7 +46,11 @@
     }
 
     public void resume() {
-        suspendCounter.decrementAndGet();
+        if( suspendCounter.decrementAndGet() == 0 ) {
+            if( size.get() != 0 ) {
+                targetQueue.dispatchAsync(this);
+            }
+        }
     }
 
     public void suspend() {
@@ -66,7 +70,7 @@
             retain();
         }
         runnables.add(runnable);
-        if( targetQueue!=null &amp;&amp; lastSize == 0 &amp;&amp; suspendCounter.get()&lt;=0
) {
+        if( lastSize == 0 &amp;&amp; suspendCounter.get()&lt;=0 ) {
             targetQueue.dispatchAsync(this);
         }
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887448&amp;r1=887447&amp;r2=887448&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
Fri Dec  4 23:25:30 2009
@@ -7,8 +7,6 @@
  **************************************************************************************/
 package org.apache.activemq.actor;
 
-import static java.lang.String.format;
-
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -16,7 +14,6 @@
 
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSPI;
-import org.apache.activemq.dispatch.DispatchSystem;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887445 - /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java</title>
<author><name>cmacnaug@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204232334.9C85823888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204232334-9C85823888EC@eris-apache-org%3e</id>
<updated>2009-12-04T23:23:34Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cmacnaug
Date: Fri Dec  4 23:23:34 2009
New Revision: 887445

URL: http://svn.apache.org/viewvc?rev=887445&amp;view=rev
Log:
Fixing unittest problem

Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887445&amp;r1=887444&amp;r2=887445&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
Fri Dec  4 23:23:34 2009
@@ -7,6 +7,8 @@
  **************************************************************************************/
 package org.apache.activemq.actor;
 
+import static java.lang.String.format;
+
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -14,6 +16,7 @@
 
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSPI;
+import org.apache.activemq.dispatch.DispatchSystem;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 
 
@@ -54,14 +57,13 @@
         CountDownLatch latch = new CountDownLatch(1);
         testObject.actorInvocation(latch);
         assertTrue(latch.await(1, TimeUnit.SECONDS));
-        
-        latch = new CountDownLatch(1);
+         
         queue.suspend();
-        assertFalse(latch.await(2, TimeUnit.SECONDS));
+        latch = new CountDownLatch(1);
+        testObject.actorInvocation(latch);
+        assertFalse("Suspended Queue shouldn't invoked method", latch.await(2, TimeUnit.SECONDS));
         
         queue.resume();
-        assertTrue(latch.await(2, TimeUnit.SECONDS));
-        
+        assertTrue("Resumed Queue should invoke method", latch.await(2, TimeUnit.SECONDS));
     }
-    
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887437 - in /activemq/sandbox/activemq-apollo-actor/activemq-dispatcher: ./ src/main/java/org/apache/activemq/actor/ src/test/java/org/apache/activemq/actor/</title>
<author><name>cmacnaug@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204231201.4B4AB23888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204231201-4B4AB23888DC@eris-apache-org%3e</id>
<updated>2009-12-04T23:12:01Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cmacnaug
Date: Fri Dec  4 23:12:00 2009
New Revision: 887437

URL: http://svn.apache.org/viewvc?rev=887437&amp;view=rev
Log:
Adding Actor class which facilitates create wrappers around Actor classes to perform method
execution on a DispatchQueue

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
  (with props)
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java
  (with props)
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
  (with props)
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/pom.xml

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/pom.xml?rev=887437&amp;r1=887436&amp;r2=887437&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/pom.xml (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/pom.xml Fri Dec  4 23:12:00
2009
@@ -49,6 +49,11 @@
       &lt;artifactId&gt;log4j&lt;/artifactId&gt;
       &lt;scope&gt;test&lt;/scope&gt;
     &lt;/dependency&gt;
+    &lt;dependency&gt;
+    	&lt;groupId&gt;cglib&lt;/groupId&gt;
+    	&lt;artifactId&gt;cglib&lt;/artifactId&gt;
+    	&lt;version&gt;2.2&lt;/version&gt;
+    &lt;/dependency&gt;
     
   &lt;/dependencies&gt;
 

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java?rev=887437&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
Fri Dec  4 23:12:00 2009
@@ -0,0 +1,98 @@
+/**************************************************************************************
+ * Copyright (C) 2009 Progress Software, Inc. All rights reserved.                    *
+ * http://fusesource.com                                                              *
+ * ---------------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the AGPL license      *
+ * a copy of which has been included with this distribution in the license.txt file.  *
+ **************************************************************************************/
+package org.apache.activemq.actor;
+
+import java.lang.reflect.Method;
+
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+
+/**
+ * Allows creation of wrapper objects that intercept {@link Message} annotated
+ * methods and dispatch them asynchronously on a given {@link DispatchQueue}.
+ * 
+ * @author cmacnaug
+ * @version 1.0
+ */
+public class Actor {
+
+    public static &lt;T&gt; T create(T target, DispatchQueue queue, Class&lt;?&gt;... interfaces)
{
+
+        validateMessageMethods(target);
+        Enhancer e = new Enhancer();
+        e.setSuperclass(target.getClass());
+        e.setInterfaces(interfaces);
+        e.setCallback(new ActorMethodInterceptor(queue));
+        return (T) e.create();
+    }
+
+    private static final &lt;T&gt; void validateMessageMethods(T target) throws IllegalArgumentException
{
+        for (Method m : target.getClass().getDeclaredMethods()) {
+            if (isMessage(m)) {
+                if (m.getReturnType() == null) {
+                    throw new IllegalArgumentException("Illegal method declaration: " + m
+ ". Actor methods must return void");
+                }
+                if (m.getExceptionTypes().length &gt; 0) {
+                    throw new IllegalArgumentException("Illegal method declaration: " + m
+ ". Actor methods must not throw exceptions");
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests if a given method has a Message annotation
+     * 
+     * @param method The mehod.
+     */
+    private static boolean isMessage(Method method) {
+        if (method.isAnnotationPresent(Message.class)) {
+            return true;
+        }
+        if (method.getDeclaringClass().isAnnotationPresent(Message.class)) {
+            return true;
+        }
+        return false;
+    }
+
+    private static class ActorMethodInterceptor implements MethodInterceptor {
+
+        private final DispatchQueue queue;
+
+        ActorMethodInterceptor(DispatchQueue queue) {
+            this.queue = queue;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object,
+         * java.lang.reflect.Method, java.lang.Object[],
+         * net.sf.cglib.proxy.MethodProxy)
+         */
+        public Object intercept(final Object obj, Method method, final Object[] args, final
MethodProxy proxy) throws Throwable {
+            if (isMessage(method)) {
+                queue.dispatchAsync(new Runnable() {
+                    public void run() {
+                        try {
+                            proxy.invokeSuper(obj, args);
+                        } catch (Throwable thrown) {
+                            throw new IllegalStateException(thrown);
+                        }
+                    }
+                });
+                return null;
+            } else {
+                return proxy.invokeSuper(obj, args);
+            }
+        }
+    }
+
+}

Propchange: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Actor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java?rev=887437&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java
Fri Dec  4 23:12:00 2009
@@ -0,0 +1,25 @@
+/**************************************************************************************
+ * Copyright (C) 2009 Progress Software, Inc. All rights reserved.                    *
+ * http://fusesource.com                                                              *
+ * ---------------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the AGPL license      *
+ * a copy of which has been included with this distribution in the license.txt file.  *
+ **************************************************************************************/
+package org.apache.activemq.actor;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+
+/**
+ * Indicates that a given method, class or interface should be treated as an actor. 
+ * 
+ * @author cmacnaug 
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@java.lang.annotation.Target( { java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE
})
+public @interface Message {
+
+}

Propchange: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/actor/Message.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java?rev=887437&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
Fri Dec  4 23:12:00 2009
@@ -0,0 +1,67 @@
+/**************************************************************************************
+ * Copyright (C) 2009 Progress Software, Inc. All rights reserved.                    *
+ * http://fusesource.com                                                              *
+ * ---------------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the AGPL license      *
+ * a copy of which has been included with this distribution in the license.txt file.  *
+ **************************************************************************************/
+package org.apache.activemq.actor;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.DispatchSPI;
+import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
+
+
+/** 
+ * ActorTest
+ * &lt;p&gt;
+ * Description:
+ * &lt;/p&gt;
+ * @author cmacnaug
+ * @version 1.0
+ */
+public class ActorTest extends TestCase {
+
+    
+    public static class ActorTestObject
+    {
+        @Message
+        public void actorInvocation(CountDownLatch latch)
+        {
+            latch.countDown();
+        }
+        
+        public void straightThrough(CountDownLatch latch)
+        {
+            latch.countDown();
+        }
+        
+    }
+    
+    public void testActorInvocation() throws Exception
+    {
+        DispatchSPI advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(),
3);
+        advancedSystem.start();
+        
+        DispatchQueue queue = advancedSystem.createQueue("test");
+        ActorTestObject testObject = Actor.create(new ActorTestObject(), queue);
+        
+        CountDownLatch latch = new CountDownLatch(1);
+        testObject.actorInvocation(latch);
+        assertTrue(latch.await(1, TimeUnit.SECONDS));
+        
+        latch = new CountDownLatch(1);
+        queue.suspend();
+        assertFalse(latch.await(2, TimeUnit.SECONDS));
+        
+        queue.resume();
+        assertTrue(latch.await(2, TimeUnit.SECONDS));
+        
+    }
+    
+}

Propchange: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/actor/ActorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887420 [2/3] - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/ src/main/csharp/Commands/ src/main/csharp/Threads/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204225343.CE4E223889E4@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204225343-CE4E223889E4@eris-apache-org%3e</id>
<updated>2009-12-04T22:53:42Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,1087 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Threading;
+using System.Collections;
+using System.Collections.Generic;
+using Apache.NMS.Stomp.Commands;
+using Apache.NMS.Stomp.Util;
+using Apache.NMS;
+using Apache.NMS.Util;
+
+namespace Apache.NMS.Stomp
+{
+    public enum AckType
+    {
+        DeliveredAck = 0, // Message delivered but not consumed
+        PoisonAck = 1, // Message could not be processed due to poison pill but discard anyway
+        ConsumedAck = 2, // Message consumed, discard
+        RedeliveredAck = 3, // Message has been Redelivered and is not yet poisoned.
+        IndividualAck = 4 // Only the given message is to be treated as consumed.
+    }
+
+    /// &lt;summary&gt;
+    /// An object capable of receiving messages from some destination
+    /// &lt;/summary&gt;
+    public class MessageConsumer : IMessageConsumer, IDispatcher
+    {
+        private readonly MessageDispatchChannel unconsumedMessages = new MessageDispatchChannel();
+        private readonly LinkedList&lt;MessageDispatch&gt; dispatchedMessages = new LinkedList&lt;MessageDispatch&gt;();
+        private readonly ConsumerInfo info;
+        private Session session;
+
+        private MessageAck pendingAck = null;
+
+        private Atomic&lt;bool&gt; started = new Atomic&lt;bool&gt;();
+        private Atomic&lt;bool&gt; deliveringAcks = new Atomic&lt;bool&gt;();
+
+        private int maximumRedeliveryCount = 10;
+        private int redeliveryTimeout = 500;
+        protected bool disposed = false;
+        private long lastDeliveredSequenceId = 0;
+        private int deliveredCounter = 0;
+        private int additionalWindowSize = 0;
+        private long redeliveryDelay = 0;
+        private int dispatchedCount = 0;
+        private volatile bool synchronizationRegistered = false;
+        private bool clearDispatchList = false;
+
+        private const int DEFAULT_REDELIVERY_DELAY = 0;
+        private const int DEFAULT_MAX_REDELIVERIES = 5;
+
+        private event MessageListener listener;
+
+        private IRedeliveryPolicy redeliveryPolicy;
+
+        // Constructor internal to prevent clients from creating an instance.
+        internal MessageConsumer(Session session, ConsumerInfo info)
+        {
+            this.session = session;
+            this.info = info;
+            this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy;
+        }
+
+        ~MessageConsumer()
+        {
+            Dispose(false);
+        }
+
+        #region Property Accessors
+
+        public long LastDeliveredSequenceId
+        {
+            get { return this.lastDeliveredSequenceId; }
+        }
+
+        public ConsumerId ConsumerId
+        {
+            get { return info.ConsumerId; }
+        }
+
+        public int MaximumRedeliveryCount
+        {
+            get { return maximumRedeliveryCount; }
+            set { maximumRedeliveryCount = value; }
+        }
+
+        public int RedeliveryTimeout
+        {
+            get { return redeliveryTimeout; }
+            set { redeliveryTimeout = value; }
+        }
+
+        public int PrefetchSize
+        {
+            get { return this.info.PrefetchSize; }
+        }
+
+        public IRedeliveryPolicy RedeliveryPolicy
+        {
+            get { return this.redeliveryPolicy; }
+            set { this.redeliveryPolicy = value; }
+        }
+
+        #endregion
+
+        #region IMessageConsumer Members
+
+        public event MessageListener Listener
+        {
+            add
+            {
+                CheckClosed();
+
+                if(this.PrefetchSize == 0)
+                {
+                    throw new NMSException("Cannot set Asynchronous Listener on a Consumer with a zero Prefetch size");
+                }
+
+                bool wasStarted = this.session.Started;
+
+                if(wasStarted == true)
+                {
+                    this.session.Stop();
+                }
+
+                listener += value;
+                this.session.Redispatch(this.unconsumedMessages);
+
+                if(wasStarted == true)
+                {
+                    this.session.Start();
+                }
+            }
+            remove { listener -= value; }
+        }
+
+        public IMessage Receive()
+        {
+            CheckClosed();
+            CheckMessageListener();
+
+            SendPullRequest(0);
+            MessageDispatch dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
+
+            if(dispatch == null)
+            {
+                return null;
+            }
+
+            BeforeMessageIsConsumed(dispatch);
+            AfterMessageIsConsumed(dispatch, false);
+
+            return CreateActiveMQMessage(dispatch);
+        }
+
+        public IMessage Receive(TimeSpan timeout)
+        {
+            CheckClosed();
+            CheckMessageListener();
+
+            MessageDispatch dispatch = null;
+            SendPullRequest((long) timeout.TotalMilliseconds);
+
+            if(this.PrefetchSize == 0)
+            {
+                dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
+            }
+            else
+            {
+                dispatch = this.Dequeue(timeout);
+            }
+
+            if(dispatch == null)
+            {
+                return null;
+            }
+
+            BeforeMessageIsConsumed(dispatch);
+            AfterMessageIsConsumed(dispatch, false);
+
+            return CreateActiveMQMessage(dispatch);
+        }
+
+        public IMessage ReceiveNoWait()
+        {
+            CheckClosed();
+            CheckMessageListener();
+
+            MessageDispatch dispatch = null;
+            SendPullRequest(-1);
+
+            if(this.PrefetchSize == 0)
+            {
+                dispatch = this.Dequeue(TimeSpan.FromMilliseconds(-1));
+            }
+            else
+            {
+                dispatch = this.Dequeue(TimeSpan.Zero);
+            }
+
+            if(dispatch == null)
+            {
+                return null;
+            }
+
+            BeforeMessageIsConsumed(dispatch);
+            AfterMessageIsConsumed(dispatch, false);
+
+            return CreateActiveMQMessage(dispatch);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected void Dispose(bool disposing)
+        {
+            if(disposed)
+            {
+                return;
+            }
+
+            if(disposing)
+            {
+                // Dispose managed code here.
+            }
+
+            try
+            {
+                Close();
+            }
+            catch
+            {
+                // Ignore network errors.
+            }
+
+            disposed = true;
+        }
+
+        public void Close()
+        {
+            if(!this.unconsumedMessages.Closed)
+            {
+                if(this.session.IsTransacted &amp;&amp; this.session.TransactionContext.InTransaction)
+                {
+                    this.session.TransactionContext.AddSynchronization(new ConsumerCloseSynchronization(this));
+                }
+                else
+                {
+                    this.DoClose();
+                }
+            }
+        }
+
+        internal void DoClose()
+        {
+            if(!this.unconsumedMessages.Closed)
+            {
+                Tracer.Debug("Closing down the Consumer");
+
+                // Do we have any acks we need to send out before closing?
+                // Ack any delivered messages now.
+                if(!this.session.IsTransacted)
+                {
+                    DeliverAcks();
+                    if(this.IsAutoAcknowledgeBatch)
+                    {
+                        Acknowledge();
+                    }
+                }
+
+                if(!this.session.IsTransacted)
+                {
+                    lock(this.dispatchedMessages)
+                    {
+                        dispatchedMessages.Clear();
+                    }
+                }
+
+                this.unconsumedMessages.Close();
+                this.session.DisposeOf(this.info.ConsumerId, this.lastDeliveredSequenceId);
+
+                RemoveInfo removeCommand = new RemoveInfo();
+                removeCommand.ObjectId = this.info.ConsumerId;
+                removeCommand.LastDeliveredSequenceId = this.lastDeliveredSequenceId;
+
+                this.session.Connection.Oneway(removeCommand);
+                this.session = null;
+
+                Tracer.Debug("Consumer instnace Closed.");
+            }
+        }
+
+        #endregion
+
+        protected void SendPullRequest(long timeout)
+        {
+            if(this.info.PrefetchSize == 0 &amp;&amp; this.unconsumedMessages.Empty)
+            {
+                MessagePull messagePull = new MessagePull();
+                messagePull.ConsumerId = this.info.ConsumerId;
+                messagePull.Destination = this.info.Destination;
+                messagePull.Timeout = timeout;
+                messagePull.ResponseRequired = false;
+
+                if(Tracer.IsDebugEnabled)
+                {
+                    Tracer.Debug("Sending MessagePull: " + messagePull);
+                }
+
+                session.Connection.Oneway(messagePull);
+            }
+        }
+
+        protected void DoIndividualAcknowledge(Message message)
+        {
+            MessageDispatch dispatch = null;
+
+            lock(this.dispatchedMessages)
+            {
+                foreach(MessageDispatch originalDispatch in this.dispatchedMessages)
+                {
+                    if(originalDispatch.Message.MessageId.Equals(message.MessageId))
+                    {
+                        dispatch = originalDispatch;
+                        this.dispatchedMessages.Remove(originalDispatch);
+                        break;
+                    }
+                }
+            }
+
+            if(dispatch == null)
+            {
+                Tracer.DebugFormat("Attempt to Ack MessageId[{0}] failed because the original dispatch is not in the Dispatch List", message.MessageId);
+                return;
+            }
+
+            MessageAck ack = new MessageAck();
+
+            ack.AckType = (byte) AckType.IndividualAck;
+            ack.ConsumerId = this.info.ConsumerId;
+            ack.Destination = dispatch.Destination;
+            ack.LastMessageId = dispatch.Message.MessageId;
+            ack.MessageCount = 1;
+
+            Tracer.Debug("Sending Individual Ack for MessageId: " + ack.LastMessageId.ToString());
+            this.session.Connection.Oneway(ack);
+        }
+
+        protected void DoNothingAcknowledge(Message message)
+        {
+        }
+
+        protected void DoClientAcknowledge(Message message)
+        {
+            this.CheckClosed();
+            Tracer.Debug("Sending Client Ack:");
+            this.session.Acknowledge();
+        }
+
+        public void Start()
+        {
+            if(this.unconsumedMessages.Closed)
+            {
+                return;
+            }
+
+            this.started.Value = true;
+            this.unconsumedMessages.Start();
+            this.session.Executor.Wakeup();
+        }
+
+        public void Stop()
+        {
+            this.started.Value = false;
+            this.unconsumedMessages.Stop();
+        }
+
+        public void ClearMessagesInProgress()
+        {
+            // we are called from inside the transport reconnection logic
+            // which involves us clearing all the connections' consumers
+            // dispatch lists and clearing them
+            // so rather than trying to grab a mutex (which could be already
+            // owned by the message listener calling the send) we will just set
+            // a flag so that the list can be cleared as soon as the
+            // dispatch thread is ready to flush the dispatch list
+            this.clearDispatchList = true;
+        }
+
+        public void DeliverAcks()
+        {
+            MessageAck ack = null;
+
+            if(this.deliveringAcks.CompareAndSet(false, true))
+            {
+                if(this.IsAutoAcknowledgeEach)
+                {
+                    lock(this.dispatchedMessages)
+                    {
+                        ack = MakeAckForAllDeliveredMessages(AckType.DeliveredAck);
+                        if(ack != null)
+                        {
+                            this.dispatchedMessages.Clear();
+                        }
+                        else
+                        {
+                            ack = this.pendingAck;
+                            this.pendingAck = null;
+                        }
+                    }
+                }
+                else if(pendingAck != null &amp;&amp; pendingAck.AckType == (byte) AckType.ConsumedAck)
+                {
+                    ack = pendingAck;
+                    pendingAck = null;
+                }
+
+                if(ack != null)
+                {
+                    MessageAck ackToSend = ack;
+
+                    try
+                    {
+                        this.session.Connection.Oneway(ackToSend);
+                    }
+                    catch(Exception e)
+                    {
+                        Tracer.DebugFormat("{0} : Failed to send ack, {1}", this.info.ConsumerId, e);
+                    }
+                }
+                else
+                {
+                    this.deliveringAcks.Value = false;
+                }
+            }
+        }
+
+        public void Dispatch(MessageDispatch dispatch)
+        {
+            MessageListener listener = this.listener;
+
+            try
+            {
+                lock(this.unconsumedMessages.SyncRoot)
+                {
+                    if(this.clearDispatchList)
+                    {
+                        // we are reconnecting so lets flush the in progress messages
+                        this.clearDispatchList = false;
+                        this.unconsumedMessages.Clear();
+
+                        if(this.pendingAck != null &amp;&amp; this.pendingAck.AckType == (byte) AckType.DeliveredAck)
+                        {
+                            // on resumption a pending delivered ack will be out of sync with
+                            // re-deliveries.
+                            if(Tracer.IsDebugEnabled)
+                            {
+                                Tracer.Debug("removing pending delivered ack on transport interupt: " + pendingAck);
+                            }
+                            this.pendingAck = null;
+                        }
+                    }
+
+                    if(!this.unconsumedMessages.Closed)
+                    {
+                        if(listener != null &amp;&amp; this.unconsumedMessages.Running)
+                        {
+                            ActiveMQMessage message = CreateActiveMQMessage(dispatch);
+
+                            this.BeforeMessageIsConsumed(dispatch);
+
+                            try
+                            {
+                                bool expired = message.IsExpired();
+
+                                if(!expired)
+                                {
+                                    listener(message);
+                                }
+
+                                this.AfterMessageIsConsumed(dispatch, expired);
+                            }
+                            catch(Exception e)
+                            {
+                                if(IsAutoAcknowledgeBatch || IsAutoAcknowledgeEach || this.session.IsIndividualAcknowledge)
+                                {
+                                    // Redeliver the message
+                                }
+                                else
+                                {
+                                    // Transacted or Client ack: Deliver the next message.
+                                    this.AfterMessageIsConsumed(dispatch, false);
+                                }
+
+                                Tracer.Error(this.info.ConsumerId + " Exception while processing message: " + e);
+                            }
+                        }
+                        else
+                        {
+                            this.unconsumedMessages.Enqueue(dispatch);
+                        }
+                    }
+                }
+
+                if(++dispatchedCount % 1000 == 0)
+                {
+                    dispatchedCount = 0;
+                    Thread.Sleep(1);
+                }
+            }
+            catch(Exception e)
+            {
+                this.session.Connection.OnSessionException(this.session, e);
+            }
+        }
+
+        public bool Iterate()
+        {
+            if(this.listener != null)
+            {
+                MessageDispatch dispatch = this.unconsumedMessages.DequeueNoWait();
+                if(dispatch != null)
+                {
+                    try
+                    {
+                        Message message = CreateStompMessage(dispatch);
+                        BeforeMessageIsConsumed(dispatch);
+                        listener(message);
+                        AfterMessageIsConsumed(dispatch, false);
+                    }
+                    catch(NMSException e)
+                    {
+                        this.session.Connection.OnSessionException(this.session, e);
+                    }
+
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        /// &lt;summary&gt;
+        /// Used to get an enqueued message from the unconsumedMessages list. The
+        /// amount of time this method blocks is based on the timeout value.  if
+        /// timeout == Timeout.Infinite then it blocks until a message is received.
+        /// if timeout == 0 then it it tries to not block at all, it returns a
+        /// message if it is available if timeout &gt; 0 then it blocks up to timeout
+        /// amount of time.  Expired messages will consumed by this method.
+        /// &lt;/summary&gt;
+        /// &lt;param name="timeout"&gt;
+        /// A &lt;see cref="System.TimeSpan"/&gt;
+        /// &lt;/param&gt;
+        /// &lt;returns&gt;
+        /// A &lt;see cref="MessageDispatch"/&gt;
+        /// &lt;/returns&gt;
+        private MessageDispatch Dequeue(TimeSpan timeout)
+        {
+            DateTime deadline = DateTime.Now;
+
+            if(timeout &gt; TimeSpan.Zero)
+            {
+                deadline += timeout;
+            }
+
+            while(true)
+            {
+                MessageDispatch dispatch = this.unconsumedMessages.Dequeue(timeout);
+
+                // Grab a single date/time for calculations to avoid timing errors.
+                DateTime dispatchTime = DateTime.Now;
+
+                if(dispatch == null)
+                {
+                    if(timeout &gt; TimeSpan.Zero &amp;&amp; !this.unconsumedMessages.Closed)
+                    {
+                        if(dispatchTime &gt; deadline)
+                        {
+                            // Out of time.
+                            timeout = TimeSpan.Zero;
+                        }
+                        else
+                        {
+                            // Adjust the timeout to the remaining time.
+                            timeout = deadline - dispatchTime;
+                        }
+                    }
+                    else
+                    {
+                        return null;
+                    }
+                }
+                else if(dispatch.Message == null)
+                {
+                    return null;
+                }
+                else if(dispatch.Message.IsExpired())
+                {
+                    Tracer.DebugFormat("{0} received expired message: {1}", info.ConsumerId, dispatch.Message.MessageId);
+
+                    BeforeMessageIsConsumed(dispatch);
+                    AfterMessageIsConsumed(dispatch, true);
+                    // Refresh the dispatch time
+                    dispatchTime = DateTime.Now;
+
+                    if(timeout &gt; TimeSpan.Zero &amp;&amp; !this.unconsumedMessages.Closed)
+                    {
+                        if(dispatchTime &gt; deadline)
+                        {
+                            // Out of time.
+                            timeout = TimeSpan.Zero;
+                        }
+                        else
+                        {
+                            // Adjust the timeout to the remaining time.
+                            timeout = deadline - dispatchTime;
+                        }
+                    }
+                }
+                else
+                {
+                    return dispatch;
+                }
+            }
+        }
+
+        public void BeforeMessageIsConsumed(MessageDispatch dispatch)
+        {
+            this.lastDeliveredSequenceId = dispatch.Message.MessageId.BrokerSequenceId;
+
+            if(!IsAutoAcknowledgeBatch)
+            {
+                lock(this.dispatchedMessages)
+                {
+                    this.dispatchedMessages.AddFirst(dispatch);
+                }
+
+                if(this.session.IsTransacted)
+                {
+                    this.AckLater(dispatch, AckType.DeliveredAck);
+                }
+            }
+        }
+
+        public void AfterMessageIsConsumed(MessageDispatch dispatch, bool expired)
+        {
+            if(this.unconsumedMessages.Closed)
+            {
+                return;
+            }
+
+            if(expired == true)
+            {
+                lock(this.dispatchedMessages)
+                {
+                    this.dispatchedMessages.Remove(dispatch);
+                }
+
+                AckLater(dispatch, AckType.DeliveredAck);
+            }
+            else
+            {
+                if(this.session.IsTransacted)
+                {
+                    // Do nothing.
+                }
+                else if(this.IsAutoAcknowledgeEach)
+                {
+                    if(this.deliveringAcks.CompareAndSet(false, true))
+                    {
+                        lock(this.dispatchedMessages)
+                        {
+                            if(this.dispatchedMessages.Count != 0)
+                            {
+                                MessageAck ack = MakeAckForAllDeliveredMessages(AckType.ConsumedAck);
+                                if(ack != null)
+                                {
+                                    this.dispatchedMessages.Clear();
+                                    this.session.Connection.Oneway(ack);
+                                }
+                            }
+                        }
+                        this.deliveringAcks.Value = false;
+                    }
+                }
+                else if(this.IsAutoAcknowledgeBatch)
+                {
+                    AckLater(dispatch, AckType.ConsumedAck);
+                }
+                else if(this.session.IsClientAcknowledge || this.session.IsIndividualAcknowledge)
+                {
+                    bool messageAckedByConsumer = false;
+
+                    lock(this.dispatchedMessages)
+                    {
+                        messageAckedByConsumer = this.dispatchedMessages.Contains(dispatch);
+                    }
+
+                    if(messageAckedByConsumer)
+                    {
+                        AckLater(dispatch, AckType.DeliveredAck);
+                    }
+                }
+                else
+                {
+                    throw new NMSException("Invalid session state.");
+                }
+            }
+        }
+
+        private MessageAck MakeAckForAllDeliveredMessages(AckType type)
+        {
+            lock(this.dispatchedMessages)
+            {
+                if(this.dispatchedMessages.Count == 0)
+                {
+                    return null;
+                }
+
+                MessageDispatch dispatch = this.dispatchedMessages.First.Value;
+                MessageAck ack = new MessageAck();
+
+                ack.AckType = (byte) type;
+                ack.ConsumerId = this.info.ConsumerId;
+                ack.Destination = dispatch.Destination;
+                ack.LastMessageId = dispatch.Message.MessageId;
+                ack.MessageCount = this.dispatchedMessages.Count;
+                ack.FirstMessageId = this.dispatchedMessages.Last.Value.Message.MessageId;
+
+                return ack;
+            }
+        }
+
+        private void AckLater(MessageDispatch dispatch, AckType type)
+        {
+            // Don't acknowledge now, but we may need to let the broker know the
+            // consumer got the message to expand the pre-fetch window
+            if(this.session.IsTransacted)
+            {
+                this.session.DoStartTransaction();
+
+                if(!synchronizationRegistered)
+                {
+                    this.synchronizationRegistered = true;
+                    this.session.TransactionContext.AddSynchronization(new MessageConsumerSynchronization(this));
+                }
+            }
+
+            this.deliveredCounter++;
+
+            MessageAck oldPendingAck = pendingAck;
+
+            pendingAck = new MessageAck();
+            pendingAck.AckType = (byte) type;
+            pendingAck.ConsumerId = this.info.ConsumerId;
+            pendingAck.Destination = dispatch.Destination;
+            pendingAck.LastMessageId = dispatch.Message.MessageId;
+            pendingAck.MessageCount = deliveredCounter;
+
+            if(this.session.IsTransacted &amp;&amp; this.session.TransactionContext.InTransaction)
+            {
+                pendingAck.TransactionId = this.session.TransactionContext.TransactionId;
+            }
+
+            if(oldPendingAck == null)
+            {
+                pendingAck.FirstMessageId = pendingAck.LastMessageId;
+            }
+            else if(oldPendingAck.AckType == pendingAck.AckType)
+            {
+                pendingAck.FirstMessageId = oldPendingAck.FirstMessageId;
+            }
+            else
+            {
+                // old pending ack being superseded by ack of another type, if is is not a delivered
+                // ack and hence important, send it now so it is not lost.
+                if(oldPendingAck.AckType != (byte) AckType.DeliveredAck)
+                {
+                    if(Tracer.IsDebugEnabled)
+                    {
+                        Tracer.Debug("Sending old pending ack " + oldPendingAck + ", new pending: " + pendingAck);
+                    }
+
+                    this.session.Connection.Oneway(oldPendingAck);
+                }
+                else
+                {
+                    if(Tracer.IsDebugEnabled)
+                    {
+                        Tracer.Debug("dropping old pending ack " + oldPendingAck + ", new pending: " + pendingAck);
+                    }
+                }
+            }
+
+            if((0.5 * this.info.PrefetchSize) &lt;= (this.deliveredCounter - this.additionalWindowSize))
+            {
+                this.session.Connection.Oneway(pendingAck);
+                this.pendingAck = null;
+                this.deliveredCounter = 0;
+                this.additionalWindowSize = 0;
+            }
+        }
+
+        internal void Acknowledge()
+        {
+            lock(this.dispatchedMessages)
+            {
+                // Acknowledge all messages so far.
+                MessageAck ack = MakeAckForAllDeliveredMessages(AckType.ConsumedAck);
+
+                if(ack == null)
+                {
+                    return; // no msgs
+                }
+
+                if(this.session.IsTransacted)
+                {
+                    this.session.DoStartTransaction();
+                    ack.TransactionId = this.session.TransactionContext.TransactionId;
+                }
+
+                this.session.Connection.Oneway(ack);
+                this.pendingAck = null;
+
+                // Adjust the counters
+                this.deliveredCounter = Math.Max(0, this.deliveredCounter - this.dispatchedMessages.Count);
+                this.additionalWindowSize = Math.Max(0, this.additionalWindowSize - this.dispatchedMessages.Count);
+
+                if(!this.session.IsTransacted)
+                {
+                    this.dispatchedMessages.Clear();
+                }
+            }
+        }
+
+        private void Commit()
+        {
+            lock(this.dispatchedMessages)
+            {
+                this.dispatchedMessages.Clear();
+            }
+
+            this.redeliveryDelay = 0;
+        }
+
+        private void Rollback()
+        {
+            lock(this.unconsumedMessages.SyncRoot)
+            {
+                lock(this.dispatchedMessages)
+                {
+                    if(this.dispatchedMessages.Count == 0)
+                    {
+                        return;
+                    }
+
+                    // Only increase the redelivery delay after the first redelivery..
+                    MessageDispatch lastMd = this.dispatchedMessages.First.Value;
+                    int currentRedeliveryCount = lastMd.Message.RedeliveryCounter;
+
+                    redeliveryDelay = this.redeliveryPolicy.RedeliveryDelay(currentRedeliveryCount);
+
+                    MessageId firstMsgId = this.dispatchedMessages.Last.Value.Message.MessageId;
+
+                    foreach(MessageDispatch dispatch in this.dispatchedMessages)
+                    {
+                        // Allow the message to update its internal to reflect a Rollback.
+                        dispatch.Message.OnMessageRollback();
+                    }
+
+                    if(this.redeliveryPolicy.MaximumRedeliveries &gt;= 0 &amp;&amp;
+                       lastMd.Message.RedeliveryCounter &gt; this.redeliveryPolicy.MaximumRedeliveries)
+                    {
+                        // We need to NACK the messages so that they get sent to the DLQ.
+                        MessageAck ack = new MessageAck();
+
+                        ack.AckType = (byte) AckType.PoisonAck;
+                        ack.ConsumerId = this.info.ConsumerId;
+                        ack.Destination = lastMd.Destination;
+                        ack.LastMessageId = lastMd.Message.MessageId;
+                        ack.MessageCount = this.dispatchedMessages.Count;
+                        ack.FirstMessageId = firstMsgId;
+
+                        this.session.Connection.Oneway(ack);
+
+                        // Adjust the window size.
+                        additionalWindowSize = Math.Max(0, this.additionalWindowSize - this.dispatchedMessages.Count);
+
+                        this.redeliveryDelay = 0;
+                    }
+                    else
+                    {
+                        // We only send a RedeliveryAck after the first redelivery
+                        if(currentRedeliveryCount &gt; 0)
+                        {
+                            MessageAck ack = new MessageAck();
+
+                            ack.AckType = (byte) AckType.RedeliveredAck;
+                            ack.ConsumerId = this.info.ConsumerId;
+                            ack.Destination = lastMd.Destination;
+                            ack.LastMessageId = lastMd.Message.MessageId;
+                            ack.MessageCount = this.dispatchedMessages.Count;
+                            ack.FirstMessageId = firstMsgId;
+
+                            this.session.Connection.Oneway(ack);
+                        }
+
+                        // stop the delivery of messages.
+                        this.unconsumedMessages.Stop();
+
+                        foreach(MessageDispatch dispatch in this.dispatchedMessages)
+                        {
+                            this.unconsumedMessages.EnqueueFirst(dispatch);
+                        }
+
+                        if(redeliveryDelay &gt; 0 &amp;&amp; !this.unconsumedMessages.Closed)
+                        {
+                            DateTime deadline = DateTime.Now.AddMilliseconds(redeliveryDelay);
+                            ThreadPool.QueueUserWorkItem(this.RollbackHelper, deadline);
+                        }
+                        else
+                        {
+                            Start();
+                        }
+                    }
+
+                    this.deliveredCounter -= this.dispatchedMessages.Count;
+                    this.dispatchedMessages.Clear();
+                }
+            }
+
+            // Only redispatch if there's an async listener otherwise a synchronous
+            // consumer will pull them from the local queue.
+            if(this.listener != null)
+            {
+                this.session.Redispatch(this.unconsumedMessages);
+            }
+        }
+
+        private void RollbackHelper(Object arg)
+        {
+            try
+            {
+                TimeSpan waitTime = (DateTime) arg - DateTime.Now;
+
+                if(waitTime.CompareTo(TimeSpan.Zero) &gt; 0)
+                {
+                    Thread.Sleep(waitTime);
+                }
+
+                this.Start();
+            }
+            catch(Exception e)
+            {
+                if(!this.unconsumedMessages.Closed)
+                {
+                    this.session.Connection.OnSessionException(this.session, e);
+                }
+            }
+        }
+
+        private Message CreateStompMessage(MessageDispatch dispatch)
+        {
+            Message message = dispatch.Message.Clone() as Message;
+
+            message.Connection = this.session.Connection;
+
+            if(this.session.IsClientAcknowledge)
+            {
+                message.Acknowledger += new AcknowledgeHandler(DoClientAcknowledge);
+            }
+            else if(this.session.IsIndividualAcknowledge)
+            {
+                message.Acknowledger += new AcknowledgeHandler(DoIndividualAcknowledge);
+            }
+            else
+            {
+                message.Acknowledger += new AcknowledgeHandler(DoNothingAcknowledge);
+            }
+
+            return message;
+        }
+
+        private void CheckClosed()
+        {
+            if(this.unconsumedMessages.Closed)
+            {
+                throw new NMSException("The Consumer has been Closed");
+            }
+        }
+
+        private void CheckMessageListener()
+        {
+            if(this.listener != null)
+            {
+                throw new NMSException("Cannot set Async listeners on Consumers with a prefetch limit of zero");
+            }
+        }
+
+        private bool IsAutoAcknowledgeEach
+        {
+            get
+            {
+                return this.session.IsAutoAcknowledge ||
+                       (this.session.IsDupsOkAcknowledge &amp;&amp; this.info.Destination.IsQueue);
+            }
+        }
+
+        private bool IsAutoAcknowledgeBatch
+        {
+            get { return this.session.IsDupsOkAcknowledge &amp;&amp; !this.info.Destination.IsQueue; }
+        }
+
+        #region Nested ISyncronization Types
+
+        class MessageConsumerSynchronization : ISynchronization
+        {
+            private readonly MessageConsumer consumer;
+
+            public MessageConsumerSynchronization(MessageConsumer consumer)
+            {
+                this.consumer = consumer;
+            }
+
+            public void BeforeEnd()
+            {
+                this.consumer.Acknowledge();
+                this.consumer.synchronizationRegistered = false;
+            }
+
+            public void AfterCommit()
+            {
+                this.consumer.Commit();
+                this.consumer.synchronizationRegistered = false;
+            }
+
+            public void AfterRollback()
+            {
+                this.consumer.Rollback();
+                this.consumer.synchronizationRegistered = false;
+            }
+        }
+
+        class ConsumerCloseSynchronization : ISynchronization
+        {
+            private readonly MessageConsumer consumer;
+
+            public ConsumerCloseSynchronization(MessageConsumer consumer)
+            {
+                this.consumer = consumer;
+            }
+
+            public void BeforeEnd()
+            {
+            }
+
+            public void AfterCommit()
+            {
+                this.consumer.DoClose();
+            }
+
+            public void AfterRollback()
+            {
+                this.consumer.DoClose();
+            }
+        }
+
+        #endregion
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+using Apache.NMS.Util;
+using Apache.NMS.Stomp.Commands;
+using Apache.NMS.Stomp.Util;
+
+namespace Apache.NMS.Stomp
+{
+    /// &lt;summary&gt;
+    /// An object capable of sending messages to some destination
+    /// &lt;/summary&gt;
+    public class MessageProducer : IMessageProducer
+    {
+        private Session session;
+        private bool closed = false;
+        private object closedLock = new object();
+        private readonly ProducerInfo info;
+        private int producerSequenceId = 0;
+
+        private MsgDeliveryMode msgDeliveryMode = NMSConstants.defaultDeliveryMode;
+        private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout;
+        private TimeSpan msgTimeToLive = NMSConstants.defaultTimeToLive;
+        private MsgPriority msgPriority = NMSConstants.defaultPriority;
+        private bool disableMessageID = false;
+        private bool disableMessageTimestamp = false;
+        protected bool disposed = false;
+
+        public MessageProducer(Session session, ProducerInfo info)
+        {
+            this.session = session;
+            this.info = info;
+            this.RequestTimeout = session.RequestTimeout;
+        }
+
+        ~MessageProducer()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected void Dispose(bool disposing)
+        {
+            if(disposed)
+            {
+                return;
+            }
+
+            if(disposing)
+            {
+                // Dispose managed code here.
+            }
+
+            try
+            {
+                Close();
+            }
+            catch
+            {
+                // Ignore network errors.
+            }
+
+            disposed = true;
+        }
+
+        public void Close()
+        {
+            lock(closedLock)
+            {
+                if(closed)
+                {
+                    return;
+                }
+
+                DoClose();
+                RemoveInfo removeInfo = new RemoveInfo();
+                removeInfo.ObjectId = this.info.ProducerId;
+                this.session.Connection.Oneway(removeInfo);
+                this.session = null;
+            }
+        }
+
+        internal void DoClose()
+        {
+            lock(closedLock)
+            {
+                if(closed)
+                {
+                    return;
+                }
+
+                try
+                {
+                    session.DisposeOf(info.ProducerId);
+                }
+                catch(Exception ex)
+                {
+                    Tracer.ErrorFormat("Error during producer close: {0}", ex);
+                }
+
+                if(this.usage != null)
+                {
+                    this.usage.Stop();
+                }
+
+                closed = true;
+            }
+        }
+
+        public void Send(IMessage message)
+        {
+            Send(info.Destination, message, this.msgDeliveryMode, this.msgPriority, this.msgTimeToLive, false);
+        }
+
+        public void Send(IDestination destination, IMessage message)
+        {
+            Send(destination, message, this.msgDeliveryMode, this.msgPriority, this.msgTimeToLive, false);
+        }
+
+        public void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+        {
+            Send(info.Destination, message, deliveryMode, priority, timeToLive, true);
+        }
+
+        public void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+        {
+            Send(destination, message, deliveryMode, priority, timeToLive, true);
+        }
+
+        protected void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, bool specifiedTimeToLive)
+        {
+            if(null == destination)
+            {
+                // See if this producer was created without a destination.
+                if(null == info.Destination)
+                {
+                    throw new NotSupportedException();
+                }
+
+                // The producer was created with a destination, but an invalid destination
+                // was specified.
+                throw new Apache.NMS.InvalidDestinationException();
+            }
+
+            Message stompMessage = (Message) message;
+
+            stompMessage.ProducerId = info.ProducerId;
+            stompMessage.FromDestination = destination;
+            stompMessage.NMSDeliveryMode = deliveryMode;
+            stompMessage.NMSPriority = priority;
+
+            // Always set the message Id regardless of the disable flag.
+            MessageId id = new MessageId();
+            id.ProducerId = info.ProducerId;
+            id.ProducerSequenceId = Interlocked.Increment(ref this.producerSequenceId);
+            stompMessage.MessageId = id;
+
+            if(!disableMessageTimestamp)
+            {
+                stompMessage.NMSTimestamp = DateTime.UtcNow;
+            }
+
+            if(specifiedTimeToLive)
+            {
+                stompMessage.NMSTimeToLive = timeToLive;
+            }
+
+            lock(closedLock)
+            {
+                if(closed)
+                {
+                    throw new ConnectionClosedException();
+                }
+
+                session.DoSend(stompMessage, this, this.usage, this.RequestTimeout);
+            }
+        }
+
+        public ProducerId ProducerId
+        {
+            get { return info.ProducerId; }
+        }
+
+        public MsgDeliveryMode DeliveryMode
+        {
+            get { return msgDeliveryMode; }
+            set { this.msgDeliveryMode = value; }
+        }
+
+        public TimeSpan TimeToLive
+        {
+            get { return msgTimeToLive; }
+            set { this.msgTimeToLive = value; }
+        }
+
+        public TimeSpan RequestTimeout
+        {
+            get { return requestTimeout; }
+            set { this.requestTimeout = value; }
+        }
+
+        public MsgPriority Priority
+        {
+            get { return msgPriority; }
+            set { this.msgPriority = value; }
+        }
+
+        public bool DisableMessageID
+        {
+            get { return disableMessageID; }
+            set { this.disableMessageID = value; }
+        }
+
+        public bool DisableMessageTimestamp
+        {
+            get { return disableMessageTimestamp; }
+            set { this.disableMessageTimestamp = value; }
+        }
+
+        public IMessage CreateMessage()
+        {
+            return session.CreateMessage();
+        }
+
+        public ITextMessage CreateTextMessage()
+        {
+            return session.CreateTextMessage();
+        }
+
+        public ITextMessage CreateTextMessage(string text)
+        {
+            return session.CreateTextMessage(text);
+        }
+
+        public IMapMessage CreateMapMessage()
+        {
+            return session.CreateMapMessage();
+        }
+
+        public IObjectMessage CreateObjectMessage(object body)
+        {
+            throw new NotSupportedException("No Object Message in Stomp");
+        }
+
+        public IBytesMessage CreateBytesMessage()
+        {
+            return session.CreateBytesMessage();
+        }
+
+        public IBytesMessage CreateBytesMessage(byte[] body)
+        {
+            return session.CreateBytesMessage(body);
+        }
+
+        public IStreamMessage CreateStreamMessage()
+        {
+            return session.CreateStreamMessage();
+        }
+
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using Apache.NMS;
+using Apache.NMS.Util;
+
+namespace Apache.NMS.Stomp
+{
+    /// &lt;summary&gt;
+    /// Class used to define the various limits that should be used for the Prefetch
+    /// limit on destination based on the type of Destination in use.
+    /// &lt;/summary&gt;
+    public class PrefetchPolicy : ICloneable
+    {
+        public const int MAX_PREFETCH_SIZE = Int16.MaxValue - 1;
+        public const int DEFAULT_QUEUE_PREFETCH = 1000;
+        public const int DEFAULT_QUEUE_BROWSER_PREFETCH = 500;
+        public const int DEFAULT_DURABLE_TOPIC_PREFETCH = 100;
+        public const int DEFAULT_TOPIC_PREFETCH = MAX_PREFETCH_SIZE;
+
+        private int queuePrefetch;
+        private int queueBrowserPrefetch;
+        private int topicPrefetch;
+        private int durableTopicPrefetch;
+        private int maximumPendingMessageLimit;
+
+        public PrefetchPolicy()
+        {
+            this.queuePrefetch = DEFAULT_QUEUE_PREFETCH;
+            this.queueBrowserPrefetch = DEFAULT_QUEUE_BROWSER_PREFETCH;
+            this.topicPrefetch = DEFAULT_TOPIC_PREFETCH;
+            this.durableTopicPrefetch = DEFAULT_DURABLE_TOPIC_PREFETCH;
+        }
+
+        public int QueuePrefetch
+        {
+            get { return this.queuePrefetch; }
+            set { this.queuePrefetch = RestrictToMaximum(value); }
+        }
+
+        public int QueueBrowserPrefetch
+        {
+            get { return this.queueBrowserPrefetch; }
+            set { this.queueBrowserPrefetch = RestrictToMaximum(value); }
+        }
+
+        public int TopicPrefetch
+        {
+            get { return this.topicPrefetch; }
+            set { this.topicPrefetch = RestrictToMaximum(value); }
+        }
+
+        public int DurableTopicPrefetch
+        {
+            get { return this.durableTopicPrefetch; }
+            set { this.durableTopicPrefetch = RestrictToMaximum(value); }
+        }
+
+        public int MaximumPendingMessageLimit
+        {
+            get { return this.maximumPendingMessageLimit; }
+            set { this.maximumPendingMessageLimit = value; }
+        }
+
+        public void SetAll(int value)
+        {
+            this.queuePrefetch = value;
+            this.queueBrowserPrefetch = value;
+            this.topicPrefetch = value;
+            this.durableTopicPrefetch = value;
+        }
+
+        private int RestrictToMaximum(int value)
+        {
+            return System.Math.Min(value, MAX_PREFETCH_SIZE);
+        }
+
+        public Object Clone()
+        {
+            return this.MemberwiseClone();
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,834 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using System.Threading;
+using Apache.NMS.Stomp.Commands;
+using Apache.NMS.Stomp.Util;
+using Apache.NMS.Util;
+
+namespace Apache.NMS.Stomp
+{
+    /// &lt;summary&gt;
+    /// Default provider of ISession
+    /// &lt;/summary&gt;
+    public class Session : ISession, IDispatcher
+    {
+        /// &lt;summary&gt;
+        /// Private object used for synchronization, instead of public "this"
+        /// &lt;/summary&gt;
+        private readonly object myLock = new object();
+
+        private readonly IDictionary consumers = Hashtable.Synchronized(new Hashtable());
+        private readonly IDictionary producers = Hashtable.Synchronized(new Hashtable());
+
+        private SessionExecutor executor;
+        private TransactionContext transactionContext;
+        private Connection connection;
+
+        private bool dispatchAsync;
+        private bool exclusive;
+        private bool retroactive;
+        private byte priority;
+
+        private readonly SessionInfo info;
+        private int consumerCounter;
+        private int producerCounter;
+        private long nextDeliveryId;
+        private long lastDeliveredSequenceId;
+        private bool disposed = false;
+        private bool closed = false;
+        private bool closing = false;
+        private TimeSpan requestTimeout = Apache.NMS.NMSConstants.defaultRequestTimeout;
+        private AcknowledgementMode acknowledgementMode;
+
+        public Session(Connection connection, SessionInfo info, AcknowledgementMode acknowledgementMode)
+        {
+            this.connection = connection;
+            this.info = info;
+            this.acknowledgementMode = acknowledgementMode;
+            this.requestTimeout = connection.RequestTimeout;
+
+            if(acknowledgementMode == AcknowledgementMode.Transactional)
+            {
+                this.transactionContext = new TransactionContext(this);
+            }
+
+            this.executor = new SessionExecutor(this, this.consumers);
+        }
+
+        ~Session()
+        {
+            Dispose(false);
+        }
+
+        #region Property Accessors
+
+        /// &lt;summary&gt;
+        /// Sets the prefetch size, the maximum number of messages a broker will dispatch to consumers
+        /// until acknowledgements are received.
+        /// &lt;/summary&gt;
+        public int PrefetchSize
+        {
+            set{ this.connection.PrefetchPolicy.SetAll(value); }
+        }
+
+        /// &lt;summary&gt;
+        /// Sets the maximum number of messages to keep around per consumer
+        /// in addition to the prefetch window for non-durable topics until messages
+        /// will start to be evicted for slow consumers.
+        /// Must be &gt; 0 to enable this feature
+        /// &lt;/summary&gt;
+        public int MaximumPendingMessageLimit
+        {
+            set{ this.connection.PrefetchPolicy.MaximumPendingMessageLimit = value; }
+        }
+
+        /// &lt;summary&gt;
+        /// Enables or disables whether asynchronous dispatch should be used by the broker
+        /// &lt;/summary&gt;
+        public bool DispatchAsync
+        {
+            get{ return this.dispatchAsync; }
+            set{ this.dispatchAsync = value; }
+        }
+
+        /// &lt;summary&gt;
+        /// Enables or disables exclusive consumers when using queues. An exclusive consumer means
+        /// only one instance of a consumer is allowed to process messages on a queue to preserve order
+        /// &lt;/summary&gt;
+        public bool Exclusive
+        {
+            get{ return this.exclusive; }
+            set{ this.exclusive = value; }
+        }
+
+        /// &lt;summary&gt;
+        /// Enables or disables retroactive mode for consumers; i.e. do they go back in time or not?
+        /// &lt;/summary&gt;
+        public bool Retroactive
+        {
+            get{ return this.retroactive; }
+            set{ this.retroactive = value; }
+        }
+
+        /// &lt;summary&gt;
+        /// Sets the default consumer priority for consumers
+        /// &lt;/summary&gt;
+        public byte Priority
+        {
+            get{ return this.priority; }
+            set{ this.priority = value; }
+        }
+
+        public Connection Connection
+        {
+            get { return this.connection; }
+        }
+
+        public SessionId SessionId
+        {
+            get { return info.SessionId; }
+        }
+
+        public TransactionContext TransactionContext
+        {
+            get { return this.transactionContext; }
+        }
+
+        public TimeSpan RequestTimeout
+        {
+            get { return this.requestTimeout; }
+            set { this.requestTimeout = value; }
+        }
+
+        public bool Transacted
+        {
+            get { return this.AcknowledgementMode == AcknowledgementMode.Transactional; }
+        }
+
+        public AcknowledgementMode AcknowledgementMode
+        {
+            get { return this.acknowledgementMode; }
+        }
+
+        public bool IsClientAcknowledge
+        {
+            get { return this.acknowledgementMode == AcknowledgementMode.ClientAcknowledge; }
+        }
+
+        public bool IsAutoAcknowledge
+        {
+            get { return this.acknowledgementMode == AcknowledgementMode.AutoAcknowledge; }
+        }
+
+        public bool IsDupsOkAcknowledge
+        {
+            get { return this.acknowledgementMode == AcknowledgementMode.DupsOkAcknowledge; }
+        }
+
+        public bool IsIndividualAcknowledge
+        {
+            get { return this.acknowledgementMode == AcknowledgementMode.IndividualAcknowledge; }
+        }
+
+        public bool IsTransacted
+        {
+            get { return this.acknowledgementMode == AcknowledgementMode.Transactional; }
+        }
+
+        public SessionExecutor Executor
+        {
+            get { return this.executor; }
+        }
+
+        public long NextDeliveryId
+        {
+            get { return Interlocked.Increment(ref this.nextDeliveryId); }
+        }
+
+        #endregion
+
+        #region ISession Members
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected void Dispose(bool disposing)
+        {
+            if(this.disposed)
+            {
+                return;
+            }
+
+            if(disposing)
+            {
+                // Dispose managed code here.
+            }
+
+            try
+            {
+                Close();
+            }
+            catch
+            {
+                // Ignore network errors.
+            }
+
+            this.disposed = true;
+        }
+
+        public void Close()
+        {
+            lock(myLock)
+            {
+                if(this.closed)
+                {
+                    return;
+                }
+
+                try
+                {
+                    Tracer.InfoFormat("Closing The Session with Id {0}", this.info.SessionId.ToString());
+                    DoClose();
+                    Tracer.InfoFormat("Closed The Session with Id {0}", this.info.SessionId.ToString());
+                }
+                catch(Exception ex)
+                {
+                    Tracer.ErrorFormat("Error during session close: {0}", ex);
+                }
+                finally
+                {
+                    // Make sure we attempt to inform the broker this Session is done.
+                    RemoveInfo info = new RemoveInfo();
+                    info.ObjectId = this.info.SessionId;
+                    info.LastDeliveredSequenceId = this.lastDeliveredSequenceId;
+                    this.connection.Oneway(info);
+                    this.connection = null;
+                    this.closed = true;
+                    this.closing = false;
+                }
+            }
+        }
+
+        internal void DoClose()
+        {
+            lock(myLock)
+            {
+                if(this.closed)
+                {
+                    return;
+                }
+
+                try
+                {
+                    this.closing = true;
+
+                    // Stop all message deliveries from this Session
+                    Stop();
+
+                    lock(consumers.SyncRoot)
+                    {
+                        foreach(MessageConsumer consumer in consumers.Values)
+                        {
+                            consumer.DoClose();
+                            this.lastDeliveredSequenceId =
+                                Math.Min(this.lastDeliveredSequenceId, consumer.LastDeliveredSequenceId);
+                        }
+                    }
+                    consumers.Clear();
+
+                    lock(producers.SyncRoot)
+                    {
+                        foreach(MessageProducer producer in producers.Values)
+                        {
+                            producer.DoClose();
+                        }
+                    }
+                    producers.Clear();
+
+                    // If in a transaction roll it back
+                    if(this.IsTransacted &amp;&amp; this.transactionContext.InTransaction)
+                    {
+                        try
+                        {
+                            this.transactionContext.Rollback();
+                        }
+                        catch
+                        {
+                        }
+                    }
+
+                    Connection.RemoveSession(this);
+                }
+                catch(Exception ex)
+                {
+                    Tracer.ErrorFormat("Error during session close: {0}", ex);
+                }
+                finally
+                {
+                    this.closed = true;
+                    this.closing = false;
+                }
+            }
+        }
+
+        public IMessageProducer CreateProducer()
+        {
+            return CreateProducer(null);
+        }
+
+        public IMessageProducer CreateProducer(IDestination destination)
+        {
+            ProducerInfo command = CreateProducerInfo(destination);
+            ProducerId producerId = command.ProducerId;
+            MessageProducer producer = null;
+
+            try
+            {
+                producer = new MessageProducer(this, command);
+                producers[producerId] = producer;
+                this.connection.Oneway(command);
+            }
+            catch(Exception)
+            {
+                if(producer != null)
+                {
+                    producer.Close();
+                }
+
+                throw;
+            }
+
+            // Registered with Connection so it can process Producer Acks.
+            connection.addProducer(producerId, producer);
+
+            return producer;
+        }
+
+        public IMessageConsumer CreateConsumer(IDestination destination)
+        {
+            return CreateConsumer(destination, null, false);
+        }
+
+        public IMessageConsumer CreateConsumer(IDestination destination, string selector)
+        {
+            return CreateConsumer(destination, selector, false);
+        }
+
+        public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal)
+        {
+            if (destination == null)
+            {
+                throw new InvalidDestinationException("Cannot create a Consumer with a Null destination");
+            }
+
+            ConsumerInfo command = CreateConsumerInfo(destination, selector);
+            command.NoLocal = noLocal;
+            ConsumerId consumerId = command.ConsumerId;
+            MessageConsumer consumer = null;
+
+            // Registered with Connection before we register at the broker.
+            connection.addDispatcher(consumerId, this);
+
+            try
+            {
+                consumer = new MessageConsumer(this, command);
+                // lets register the consumer first in case we start dispatching messages immediately
+                consumers[consumerId] = consumer;
+                this.Connection.SyncRequest(command);
+
+                if(this.Started)
+                {
+                    consumer.Start();
+                }
+
+                return consumer;
+            }
+            catch(Exception)
+            {
+                if(consumer != null)
+                {
+                    consumer.Close();
+                }
+
+                throw;
+            }
+        }
+
+        public IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal)
+        {
+            if (destination == null)
+            {
+                throw new InvalidDestinationException("Cannot create a Consumer with a Null destination");
+            }
+
+            ConsumerInfo command = CreateConsumerInfo(destination, selector);
+            ConsumerId consumerId = command.ConsumerId;
+            command.SubscriptionName = name;
+            command.NoLocal = noLocal;
+            command.PrefetchSize = this.connection.PrefetchPolicy.DurableTopicPrefetch;
+            MessageConsumer consumer = null;
+
+            // Registered with Connection before we register at the broker.
+            connection.addDispatcher(consumerId, this);
+
+            try
+            {
+                consumer = new MessageConsumer(this, command);
+                // lets register the consumer first in case we start dispatching messages immediately
+                consumers[consumerId] = consumer;
+
+                if(this.Started)
+                {
+                    consumer.Start();
+                }
+
+                this.connection.SyncRequest(command);
+            }
+            catch(Exception)
+            {
+                if(consumer != null)
+                {
+                    consumer.Close();
+                }
+
+                throw;
+            }
+
+            return consumer;
+        }
+
+        public void DeleteDurableConsumer(string name)
+        {
+            RemoveSubscriptionInfo command = new RemoveSubscriptionInfo();
+            command.ConnectionId = Connection.ConnectionId;
+            command.ClientId = Connection.ClientId;
+            command.SubcriptionName = name;
+            this.connection.SyncRequest(command);
+        }
+
+        public IQueueBrowser CreateBrowser(IQueue queue)
+        {
+            throw new NotSupportedException("Not Yet Implemented");
+        }
+
+        public IQueueBrowser CreateBrowser(IQueue queue, string selector)
+        {
+            throw new NotSupportedException("Not Yet Implemented");
+        }
+
+        public IQueue GetQueue(string name)
+        {
+            return new ActiveMQQueue(name);
+        }
+
+        public ITopic GetTopic(string name)
+        {
+            return new ActiveMQTopic(name);
+        }
+
+        public ITemporaryQueue CreateTemporaryQueue()
+        {
+            ActiveMQTempQueue answer = new ActiveMQTempQueue(Connection.CreateTemporaryDestinationName());
+            CreateTemporaryDestination(answer);
+            return answer;
+        }
+
+        public ITemporaryTopic CreateTemporaryTopic()
+        {
+            ActiveMQTempTopic answer = new ActiveMQTempTopic(Connection.CreateTemporaryDestinationName());
+            CreateTemporaryDestination(answer);
+            return answer;
+        }
+
+        /// &lt;summary&gt;
+        /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic).
+        /// &lt;/summary&gt;
+        public void DeleteDestination(IDestination destination)
+        {
+            DestinationInfo command = new DestinationInfo();
+            command.ConnectionId = Connection.ConnectionId;
+            command.OperationType = DestinationInfo.REMOVE_OPERATION_TYPE; // 1 is remove
+            command.Destination = (Destination) destination;
+
+            this.connection.Oneway(command);
+        }
+
+        public IMessage CreateMessage()
+        {
+            Message answer = new Message();
+            return ConfigureMessage(answer) as IMessage;
+        }
+
+        public ITextMessage CreateTextMessage()
+        {
+            ActiveMQTextMessage answer = new ActiveMQTextMessage();
+            return ConfigureMessage(answer) as ITextMessage;
+        }
+
+        public ITextMessage CreateTextMessage(string text)
+        {
+            ActiveMQTextMessage answer = new ActiveMQTextMessage(text);
+            return ConfigureMessage(answer) as ITextMessage;
+        }
+
+        public IMapMessage CreateMapMessage()
+        {
+            return ConfigureMessage(new ActiveMQMapMessage()) as IMapMessage;
+        }
+
+        public IBytesMessage CreateBytesMessage()
+        {
+            return ConfigureMessage(new ActiveMQBytesMessage()) as IBytesMessage;
+        }
+
+        public IBytesMessage CreateBytesMessage(byte[] body)
+        {
+            BytesMessage answer = new BytesMessage();
+            answer.Content = body;
+            return ConfigureMessage(answer) as IBytesMessage;
+        }
+
+        public IStreamMessage CreateStreamMessage()
+        {
+            return ConfigureMessage(new ActiveMQStreamMessage()) as IStreamMessage;
+        }
+
+        public IObjectMessage CreateObjectMessage(object body)
+        {
+            throw NotSupportedException("No Object Message in Stomp");
+        }
+
+        public void Commit()
+        {
+            if(!Transacted)
+            {
+                throw new InvalidOperationException(
+                        "You cannot perform a Commit() on a non-transacted session. Acknowlegement mode is: "
+                        + this.AcknowledgementMode);
+            }
+
+            this.TransactionContext.Commit();
+        }
+
+        public void Rollback()
+        {
+            if(!Transacted)
+            {
+                throw new InvalidOperationException(
+                        "You cannot perform a Commit() on a non-transacted session. Acknowlegement mode is: "
+                        + this.AcknowledgementMode);
+            }
+
+            this.TransactionContext.Rollback();
+        }
+
+        #endregion
+
+        protected void CreateTemporaryDestination(Destination tempDestination)
+        {
+            DestinationInfo command = new DestinationInfo();
+            command.ConnectionId = Connection.ConnectionId;
+            command.OperationType = DestinationInfo.ADD_OPERATION_TYPE; // 0 is add
+            command.Destination = tempDestination;
+
+            this.connection.SyncRequest(command);
+        }
+
+        public void DoSend( Message message, MessageProducer producer, TimeSpan sendTimeout )
+        {
+            Message msg = message;
+
+            if(Transacted)
+            {
+                DoStartTransaction();
+                msg.TransactionId = TransactionContext.TransactionId;
+            }
+
+            msg.RedeliveryCounter = 0;
+            msg.BrokerPath = null;
+
+            if(this.connection.CopyMessageOnSend)
+            {
+                msg = (Message)msg.Clone();
+            }
+
+            msg.OnSend();
+            msg.ProducerId = msg.MessageId.ProducerId;
+
+            if(sendTimeout.TotalMilliseconds &lt;= 0 &amp;&amp; !msg.ResponseRequired &amp;&amp; !connection.AlwaysSyncSend &amp;&amp;
+               (!msg.Persistent || connection.AsyncSend || msg.TransactionId != null))
+            {
+                this.connection.Oneway(msg);
+            }
+            else
+            {
+                if(sendTimeout.TotalMilliseconds &gt; 0)
+                {
+                    this.connection.SyncRequest(msg, sendTimeout);
+                }
+                else
+                {
+                    this.connection.SyncRequest(msg);
+                }
+            }
+        }
+
+        /// &lt;summary&gt;
+        /// Ensures that a transaction is started
+        /// &lt;/summary&gt;
+        public void DoStartTransaction()
+        {
+            if(Transacted)
+            {
+                this.TransactionContext.Begin();
+            }
+        }
+
+        public void DisposeOf(ConsumerId objectId, long lastDeliveredSequenceId)
+        {
+            connection.removeDispatcher(objectId);
+            this.lastDeliveredSequenceId = Math.Min(this.lastDeliveredSequenceId, lastDeliveredSequenceId);
+
+            if(!this.closing)
+            {
+                consumers.Remove(objectId);
+            }
+        }
+
+        public void DisposeOf(ProducerId objectId)
+        {
+            connection.removeProducer(objectId);
+            if(!this.closing)
+            {
+                producers.Remove(objectId);
+            }
+        }
+
+        protected virtual ConsumerInfo CreateConsumerInfo(IDestination destination, string selector)
+        {
+            ConsumerInfo answer = new ConsumerInfo();
+            ConsumerId id = new ConsumerId();
+            id.ConnectionId = info.SessionId.ConnectionId;
+            id.SessionId = info.SessionId.Value;
+            id.Value = Interlocked.Increment(ref consumerCounter);
+            answer.ConsumerId = id;
+            answer.Destination = Destination.Transform(destination);
+            answer.Selector = selector;
+            answer.Priority = this.Priority;
+            answer.Exclusive = this.Exclusive;
+            answer.DispatchAsync = this.DispatchAsync;
+            answer.Retroactive = this.Retroactive;
+            answer.MaximumPendingMessageLimit = this.connection.PrefetchPolicy.MaximumPendingMessageLimit;
+
+            if(destination is ITopic || destination is ITemporaryTopic)
+            {
+                answer.PrefetchSize = this.connection.PrefetchPolicy.TopicPrefetch;
+            }
+            else if(destination is IQueue || destination is ITemporaryQueue)
+            {
+                answer.PrefetchSize = this.connection.PrefetchPolicy.QueuePrefetch;
+            }
+
+            // If the destination contained a URI query, then use it to set public properties
+            // on the ConsumerInfo
+            Destination amqDestination = destination as Destination;
+            if(amqDestination != null &amp;&amp; amqDestination.Options != null)
+            {
+                URISupport.SetProperties(answer, amqDestination.Options, "consumer.");
+            }
+
+            return answer;
+        }
+
+        protected virtual ProducerInfo CreateProducerInfo(IDestination destination)
+        {
+            ProducerInfo answer = new ProducerInfo();
+            ProducerId id = new ProducerId();
+            id.ConnectionId = info.SessionId.ConnectionId;
+            id.SessionId = info.SessionId.Value;
+            id.Value = Interlocked.Increment(ref producerCounter);
+            answer.ProducerId = id;
+            answer.Destination = Destination.Transform(destination);
+            answer.WindowSize = connection.ProducerWindowSize;
+
+            // If the destination contained a URI query, then use it to set public
+            // properties on the ProducerInfo
+            Destination amqDestination = destination as Destination;
+            if(amqDestination != null &amp;&amp; amqDestination.Options != null)
+            {
+                URISupport.SetProperties(answer, amqDestination.Options, "producer.");
+            }
+
+            return answer;
+        }
+
+        public void Stop()
+        {
+            if(this.executor != null)
+            {
+                this.executor.Stop();
+            }
+        }
+
+        public void Start()
+        {
+            foreach(MessageConsumer consumer in this.consumers.Values)
+            {
+                consumer.Start();
+            }
+
+            if(this.executor != null)
+            {
+                this.executor.Start();
+            }
+        }
+
+        public bool Started
+        {
+            get
+            {
+                return this.executor != null ? this.executor.Running : false;
+            }
+        }
+
+        internal void Redispatch(MessageDispatchChannel channel)
+        {
+            MessageDispatch[] messages = channel.RemoveAll();
+            System.Array.Reverse(messages);
+
+            foreach(MessageDispatch message in messages)
+            {
+                if(Tracer.IsDebugEnabled)
+                {
+                    Tracer.DebugFormat("Resending Message Dispatch: ", message.ToString());
+                }
+                this.executor.ExecuteFirst(message);
+            }
+        }
+
+        public void Dispatch(MessageDispatch dispatch)
+        {
+            if(this.executor != null)
+            {
+                if(Tracer.IsDebugEnabled)
+                {
+                    Tracer.DebugFormat("Send Message Dispatch: ", dispatch.ToString());
+                }
+                this.executor.Execute(dispatch);
+            }
+        }
+
+        internal void ClearMessagesInProgress()
+        {
+            if( this.executor != null ) {
+                this.executor.ClearMessagesInProgress();
+            }
+
+            lock(this.consumers.SyncRoot)
+            {
+                foreach(MessageConsumer consumer in this.consumers)
+                {
+                    consumer.ClearMessagesInProgress();
+                }
+            }
+        }
+
+        internal void Acknowledge()
+        {
+            lock(this.consumers.SyncRoot)
+            {
+                foreach(MessageConsumer consumer in this.consumers.Values)
+                {
+                    consumer.Acknowledge();
+                }
+            }
+        }
+
+        private Message ConfigureMessage(Message message)
+        {
+            message.Connection = this.connection;
+
+            if(this.IsTransacted)
+            {
+                // Allows Acknowledge to be called in a transaction with no effect per JMS Spec.
+                message.Acknowledger += new AcknowledgeHandler(DoNothingAcknowledge);
+            }
+
+            return message;
+        }
+
+        /// &lt;summary&gt;
+        /// Prevents message from throwing an exception if a client calls Acknoweldge on
+        /// a message that is part of a transaction either being produced or consumed.  The
+        /// JMS Spec indicates that users should be able to call Acknowledge with no effect
+        /// if the message is in a transaction.
+        /// &lt;/summary&gt;
+        /// &lt;param name="message"&gt;
+        /// A &lt;see cref="Message"/&gt;
+        /// &lt;/param&gt;
+        private void DoNothingAcknowledge(Message message)
+        {
+        }
+
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using Apache.NMS.Stomp.Commands;
+using Apache.NMS.Stomp.Util;
+using Apache.NMS.Stomp.Threads;
+
+namespace Apache.NMS.Stomp
+{
+    public class SessionExecutor : Threads.Task
+    {
+        private MessageDispatchChannel messageQueue = new MessageDispatchChannel();
+        private TaskRunner taskRunner = null;
+
+        private Session session = null;
+        private IDictionary consumers = null;
+
+        public SessionExecutor(Session session, IDictionary consumers)
+        {
+            this.session = session;
+            this.consumers = consumers;
+        }
+
+        ~SessionExecutor()
+        {
+            try
+            {
+                Stop();
+                Close();
+                Clear();
+            }
+            catch
+            {
+            }
+        }
+
+        public void Execute(MessageDispatch dispatch)
+        {
+            // Add the data to the queue.
+            this.messageQueue.Enqueue(dispatch);
+            this.Wakeup();
+        }
+
+        public void ExecuteFirst(MessageDispatch dispatch)
+        {
+            // Add the data to the queue.
+            this.messageQueue.EnqueueFirst(dispatch);
+            this.Wakeup();
+        }
+
+        public void Wakeup()
+        {
+            TaskRunner taskRunner = this.taskRunner;
+
+            lock(messageQueue.SyncRoot)
+            {
+                if(this.taskRunner == null)
+                {
+                    this.taskRunner = new DedicatedTaskRunner(this);
+                }
+
+                taskRunner = this.taskRunner;
+            }
+
+            taskRunner.Wakeup();
+        }
+
+        public void Start()
+        {
+            if(!messageQueue.Running)
+            {
+                messageQueue.Start();
+
+                if(HasUncomsumedMessages)
+                {
+                    this.Wakeup();
+                }
+            }
+        }
+
+        public void Stop()
+        {
+            if(messageQueue.Running)
+            {
+                messageQueue.Stop();
+                TaskRunner taskRunner = this.taskRunner;
+
+                if(taskRunner != null)
+                {
+                    this.taskRunner = null;
+                    taskRunner.Shutdown();
+                }
+            }
+        }
+
+        public void Close()
+        {
+            this.messageQueue.Close();
+        }
+
+        public void Dispatch(MessageDispatch dispatch)
+        {
+            try
+            {
+                MessageConsumer consumer = null;
+
+                lock(this.consumers.SyncRoot)
+                {
+                    if(this.consumers.Contains(dispatch.ConsumerId))
+                    {
+                        consumer = this.consumers[dispatch.ConsumerId] as MessageConsumer;
+                    }
+
+                    // If the consumer is not available, just ignore the message.
+                    // Otherwise, dispatch the message to the consumer.
+                    if(consumer != null)
+                    {
+                        consumer.Dispatch(dispatch);
+                    }
+                }
+
+            }
+            catch(Exception ex)
+            {
+                Tracer.DebugFormat("Caught Exception While Dispatching: {0}", ex.Message );
+            }
+        }
+
+        public bool Iterate()
+        {
+            try
+            {
+                lock(this.consumers.SyncRoot)
+                {
+                    // Deliver any messages queued on the consumer to their listeners.
+                    foreach( MessageConsumer consumer in this.consumers.Values )
+                    {
+                        if(consumer.Iterate())
+                        {
+                            return true;
+                        }
+                    }
+                }
+
+                // No messages left queued on the listeners.. so now dispatch messages
+                // queued on the session
+                MessageDispatch message = messageQueue.DequeueNoWait();
+
+                if(message != null)
+                {
+                    this.Dispatch(message);
+                    return !messageQueue.Empty;
+                }
+
+                return false;
+            }
+            catch(Exception ex)
+            {
+                Tracer.DebugFormat("Caught Exception While Dispatching: {0}", ex.Message );
+                this.session.Connection.OnSessionException(this.session, ex);
+            }
+
+            return true;
+        }
+
+        public void ClearMessagesInProgress()
+        {
+            this.messageQueue.Clear();
+        }
+
+        public void Clear()
+        {
+            this.messageQueue.Clear();
+        }
+
+        public MessageDispatch[] UnconsumedMessages
+        {
+            get{ return messageQueue.RemoveAll(); }
+        }
+
+        public bool HasUncomsumedMessages
+        {
+            get{ return !messageQueue.Closed &amp;&amp; messageQueue.Running &amp;&amp; !messageQueue.Empty; }
+        }
+
+        public bool Running
+        {
+            get{ return this.messageQueue.Running; }
+        }
+
+        public bool Empty
+        {
+            get{ return this.messageQueue.Empty; }
+        }
+
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs
------------------------------------------------------------------------------
    svn:eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887420 [1/3] - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/ src/main/csharp/Commands/ src/main/csharp/Threads/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204225343.C8CF123889D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204225343-C8CF123889D0@eris-apache-org%3e</id>
<updated>2009-12-04T22:53:42Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Fri Dec  4 22:53:41 2009
New Revision: 887420

URL: http://svn.apache.org/viewvc?rev=887420&amp;view=rev
Log:
Fixing some compiler errors and bringing in more NMS Implementation for Stomp.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageConsumer.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/PrefetchPolicy.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Session.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/SessionExecutor.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs   (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs   (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseCommand.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BrokerError.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BytesMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Command.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ExceptionResponse.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageAck.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageDispatch.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Queue.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Response.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ShutdownInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/StreamMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SubscriptionInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempDestination.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TextMessage.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionInfo.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseCommand.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseCommand.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseCommand.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseCommand.cs Fri Dec  4 22:53:41 2009
@@ -15,15 +15,6 @@
  * limitations under the License.
  */
 
-//
-// Marshalling code for Open Wire Format for BaseCommand
-//
-//
-// NOTE!: This file is autogenerated - do not modify!
-//        if you need to make a change, please see the Groovy scripts in the
-//        activemq-openwire module
-//
-
 using System;
 
 namespace Apache.NMS.Stomp.Commands
@@ -57,7 +48,7 @@
 
         public override String ToString()
         {
-            string answer = GetDataStructureTypeAsString(GetDataStructureType());
+            string answer = DataStructureTypes.GetDataStructureTypeAsString(GetDataStructureType());
             if(answer.Length == 0)
             {
                 answer = base.ToString();
@@ -65,69 +56,6 @@
             return answer + ": id = " + CommandId;
         }
 
-        public static String GetDataStructureTypeAsString(int type)
-        {
-            String packetTypeStr = "";
-            switch(type)
-            {
-                case ActiveMQMessage.ID_ACTIVEMQMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_MESSAGE";
-                    break;
-                case ActiveMQTextMessage.ID_ACTIVEMQTEXTMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_TEXT_MESSAGE";
-                    break;
-                case ActiveMQObjectMessage.ID_ACTIVEMQOBJECTMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_OBJECT_MESSAGE";
-                    break;
-                case ActiveMQBytesMessage.ID_ACTIVEMQBYTESMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_BYTES_MESSAGE";
-                    break;
-                case ActiveMQStreamMessage.ID_ACTIVEMQSTREAMMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_STREAM_MESSAGE";
-                    break;
-                case ActiveMQMapMessage.ID_ACTIVEMQMAPMESSAGE:
-                    packetTypeStr = "ACTIVEMQ_MAP_MESSAGE";
-                    break;
-                case MessageAck.ID_MESSAGEACK:
-                    packetTypeStr = "ACTIVEMQ_MSG_ACK";
-                    break;
-                case Response.ID_RESPONSE:
-                    packetTypeStr = "RESPONSE";
-                    break;
-                case ConsumerInfo.ID_CONSUMERINFO:
-                    packetTypeStr = "CONSUMER_INFO";
-                    break;
-                case ProducerInfo.ID_PRODUCERINFO:
-                    packetTypeStr = "PRODUCER_INFO";
-                    break;
-                case TransactionInfo.ID_TRANSACTIONINFO:
-                    packetTypeStr = "TRANSACTION_INFO";
-                    break;
-                case BrokerInfo.ID_BROKERINFO:
-                    packetTypeStr = "BROKER_INFO";
-                    break;
-                case ConnectionInfo.ID_CONNECTIONINFO:
-                    packetTypeStr = "CONNECTION_INFO";
-                    break;
-                case SessionInfo.ID_SESSIONINFO:
-                    packetTypeStr = "SESSION_INFO";
-                    break;
-                case RemoveSubscriptionInfo.ID_REMOVESUBSCRIPTIONINFO:
-                    packetTypeStr = "DURABLE_UNSUBSCRIBE";
-                    break;
-                case IntegerResponse.ID_INTEGERRESPONSE:
-                    packetTypeStr = "INT_RESPONSE_RECEIPT_INFO";
-                    break;
-                case WireFormatInfo.ID_WIREFORMATINFO:
-                    packetTypeStr = "WIRE_FORMAT_INFO";
-                    break;
-                case RemoveInfo.ID_REMOVEINFO:
-                    packetTypeStr = "REMOVE_INFO";
-                    break;
-            }
-            return packetTypeStr;
-        }
-
         public virtual bool IsBrokerInfo
         {
             get
@@ -264,7 +192,7 @@
             }
         }
 
-        public virtual bool IsWireFormatInfo
+        public virtual bool IsErrorCommand
         {
             get
             {

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseMessage.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseMessage.cs Fri Dec  4 22:53:41 2009
@@ -24,8 +24,6 @@
 {
     public class BaseMessage : BaseCommand, MarshallAware, ICloneable
     {
-        public const byte ID_MESSAGE = 0;
-
         ProducerId producerId;
         Destination destination;
         TransactionId transactionId;
@@ -52,17 +50,6 @@
 
         ///
         /// &lt;summery&gt;
-        ///  Get the unique identifier that this object and its own
-        ///  Marshaler share.
-        /// &lt;/summery&gt;
-        ///
-        public override byte GetDataStructureType()
-        {
-            return ID_MESSAGE;
-        }
-
-        ///
-        /// &lt;summery&gt;
         ///  Clone this object and return a new instance that the caller now owns.
         /// &lt;/summery&gt;
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BrokerError.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BrokerError.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BrokerError.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BrokerError.cs Fri Dec  4 22:53:41 2009
@@ -38,6 +38,11 @@
         private StackTraceElement[] stackTraceElements = {};
         private BrokerError cause;
 
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.ErrorType;
+        }
+        
         public string Message
         {
             get { return message; }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BytesMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BytesMessage.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BytesMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BytesMessage.cs Fri Dec  4 22:53:41 2009
@@ -25,8 +25,6 @@
 {
     public class BytesMessage : Message, IBytesMessage
     {
-        public const byte ID_ACTIVEMQBYTESMESSAGE = 24;
-
         private EndianBinaryReader dataIn = null;
         private EndianBinaryWriter dataOut = null;
         private MemoryStream outputBuffer = null;
@@ -34,7 +32,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQBYTESMESSAGE;
+            return DataStructureTypes.BytesMessageType;
         }
 
         public override Object Clone()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Command.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Command.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Command.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Command.cs Fri Dec  4 22:53:41 2009
@@ -41,11 +41,6 @@
             get;
         }
 
-        bool IsConnectedCommand
-        {
-            get;
-        }
-
         bool IsErrorCommand
         {
             get;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionId.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionId.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionId.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class ConnectionId : BaseDataStructure
     {
-        public const byte ID_CONNECTIONID = 120;
-
         string value;
 
         public ConnectionId()
@@ -53,7 +51,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_CONNECTIONID;
+            return DataStructureTypes.ConnectionIdType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConnectionInfo.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class ConnectionInfo : BaseCommand
     {
-        public const byte ID_CONNECTIONINFO = 3;
-
         ConnectionId connectionId;
         string clientId;
         string password;
@@ -37,7 +35,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_CONNECTIONINFO;
+            return DataStructureTypes.ConnectionInfoType;
         }
 
         ///

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Apache.NMS.Stomp.Commands
+{      
+    public class DataStructureTypes
+    {
+        public const byte ErrorType = 0;
+        
+        public const byte MessageType = 1;
+        public const byte BytesMessageType = 2;
+        public const byte MapMessageType = 3;
+        public const byte StreamMessageType = 4;
+        public const byte TextMessageType = 5;
+
+        public const byte MessageDispatchType = 9;        
+        public const byte MessageIdType = 10;
+        public const byte MessageAckType = 11;
+
+        public const byte ConnectionInfoType = 12;
+        public const byte ConnectionIdType = 13;
+        public const byte ConsumerInfoType = 14;
+        public const byte ConsumerIdType = 15;
+        public const byte ProducerInfoType = 16;
+        public const byte ProducerIdType = 17;
+        public const byte SessionInfoType = 18;
+        public const byte SessionIdType = 19;
+        public const byte TransactionInfoType = 20;
+        public const byte TransactionIdType = 21;
+        public const byte SubscriptionInfoType = 22;
+        public const byte ShutdownInfoType = 23;
+        public const byte ResponseType = 24;
+        public const byte RemoveInfoType = 25;
+        public const byte ErrorResponseType = 26;
+        
+        public const byte DestinationType = 48;
+        public const byte TempDestinationType = 49;
+        public const byte TopicType = 50;
+        public const byte TempTopicType = 51;
+        public const byte QueueType = 52;
+        public const byte TempQueueType = 53;
+
+        public static String GetDataStructureTypeAsString(int type)
+        {
+            String packetTypeStr = "UnknownType";
+            switch(type)
+            {
+            case ErrorType:
+                packetTypeStr = "ErrorType";
+                break;
+            case MessageType:
+                packetTypeStr = "MessageType";
+                break;
+            case BytesMessageType:
+                packetTypeStr = "BytesMessageType";
+                break;
+            case StreamMessageType:
+                packetTypeStr = "StreamMessageType";
+                break;
+            case TextMessageType:
+                packetTypeStr = "TextMessageType";
+                break;
+            case MessageDispatchType:
+                packetTypeStr = "MessageDispatchType";
+                break;
+            case MessageIdType:
+                packetTypeStr = "MessageIdType";
+                break;
+            case MessageAckType:
+                packetTypeStr = "MessageAckType";
+                break;
+            case ConnectionInfoType:
+                packetTypeStr = "ConnectionInfoType";
+                break;
+            case ConnectionIdType:
+                packetTypeStr = "ConnectionIdType";
+                break;
+            case ConsumerInfoType:
+                packetTypeStr = "ConsumerInfoType";
+                break;
+            case ConsumerIdType:
+                packetTypeStr = "ConsumerIdType";
+                break;
+            case ProducerInfoType:
+                packetTypeStr = "ProducerInfoType";
+                break;
+            case ProducerIdType:
+                packetTypeStr = "ProducerIdType";
+                break;
+            case SessionInfoType:
+                packetTypeStr = "SessionInfoType";
+                break;
+            case TransactionInfoType:
+                packetTypeStr = "TransactionInfoType";
+                break;
+            case TransactionIdType:
+                packetTypeStr = "TransactionIdType";
+                break;
+            case SubscriptionInfoType:
+                packetTypeStr = "SubscriptionInfoType";
+                break;
+            case ShutdownInfoType:
+                packetTypeStr = "ShutdownInfoType";
+                break;
+            case ResponseType:
+                packetTypeStr = "ResponseType";
+                break;
+            case RemoveInfoType:
+                packetTypeStr = "RemoveInfoType";
+                break;
+            case ErrorResponseType:
+                packetTypeStr = "ErrorResponseType";
+                break;
+            case DestinationType:
+                packetTypeStr = "DestinationType";
+                break;
+            case TempDestinationType:
+                packetTypeStr = "TempDestinationType";
+                break;
+            case TopicType:
+                packetTypeStr = "TopicType";
+                break;
+            case TempTopicType:
+                packetTypeStr = "TempTopicType";
+                break;
+            case QueueType:
+                packetTypeStr = "QueueType";
+                break;
+            case TempQueueType:
+                packetTypeStr = "TempQueueType";
+                break;
+            }
+
+            return packetTypeStr;
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/DataStructureTypes.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Destination.cs Fri Dec  4 22:53:41 2009
@@ -42,27 +42,6 @@
         /// Temporary Queue Destination object
         /// &lt;/summary&gt;
         public const int STOMP_TEMPORARY_QUEUE = 4;
-        /// &lt;summary&gt;
-        /// prefix for Advisory message destinations
-        /// &lt;/summary&gt;
-        public const String ADVISORY_PREFIX = "ActiveMQ.Advisory.";
-        /// &lt;summary&gt;
-        /// prefix for consumer advisory destinations
-        /// &lt;/summary&gt;
-        public const String CONSUMER_ADVISORY_PREFIX = ADVISORY_PREFIX + "Consumers.";
-        /// &lt;summary&gt;
-        /// prefix for producer advisory destinations
-        /// &lt;/summary&gt;
-        public const String PRODUCER_ADVISORY_PREFIX = ADVISORY_PREFIX + "Producers.";
-        /// &lt;summary&gt;
-        /// prefix for connection advisory destinations
-        /// &lt;/summary&gt;
-        public const String CONNECTION_ADVISORY_PREFIX = ADVISORY_PREFIX + "Connections.";
-
-        /// &lt;summary&gt;
-        /// The default target for ordered destinations
-        /// &lt;/summary&gt;
-        public const String DEFAULT_ORDERED_TARGET = "coordinator";
 
         private const String TEMP_PREFIX = "{TD{";
         private const String TEMP_POSTFIX = "}TD}";
@@ -71,12 +50,6 @@
         private String physicalName = "";
         private StringDictionary options = null;
 
-        // Cached transient data
-        private bool exclusive;
-        private bool ordered;
-        private bool advisory;
-        private String orderedTarget = DEFAULT_ORDERED_TARGET;
-
         /// &lt;summary&gt;
         /// The Default Constructor
         /// &lt;/summary&gt;
@@ -91,7 +64,6 @@
         protected Destination(String name)
         {
             setPhysicalName(name);
-            //this.advisory = name != null &amp;&amp; name.StartsWith(ADVISORY_PREFIX);
         }
 
         public bool IsTopic
@@ -148,94 +120,6 @@
         }
 
         /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;Returns the advisory.&lt;/returns&gt;
-        public bool IsAdvisory()
-        {
-            return advisory;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;param name="advisory"&gt;The advisory to set.&lt;/param&gt;
-        public void SetAdvisory(bool advisory)
-        {
-            this.advisory = advisory;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;true if this is a destination for Consumer advisories&lt;/returns&gt;
-        public bool IsConsumerAdvisory()
-        {
-            return IsAdvisory() &amp;&amp; physicalName.StartsWith(CONSUMER_ADVISORY_PREFIX);
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;true if this is a destination for Producer advisories&lt;/returns&gt;
-        public bool IsProducerAdvisory()
-        {
-            return IsAdvisory() &amp;&amp; physicalName.StartsWith(PRODUCER_ADVISORY_PREFIX);
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;true if this is a destination for Connection advisories&lt;/returns&gt;
-        public bool IsConnectionAdvisory()
-        {
-            return IsAdvisory() &amp;&amp; physicalName.StartsWith(CONNECTION_ADVISORY_PREFIX);
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;Returns the exclusive.&lt;/returns&gt;
-        public bool IsExclusive()
-        {
-            return exclusive;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;param name="exclusive"&gt;The exclusive to set.&lt;/param&gt;
-        public void SetExclusive(bool exclusive)
-        {
-            this.exclusive = exclusive;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;Returns the ordered.&lt;/returns&gt;
-        public bool IsOrdered()
-        {
-            return ordered;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;param name="ordered"&gt;The ordered to set.&lt;/param&gt;
-        public void SetOrdered(bool ordered)
-        {
-            this.ordered = ordered;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;returns&gt;Returns the orderedTarget.&lt;/returns&gt;
-        public String GetOrderedTarget()
-        {
-            return orderedTarget;
-        }
-
-        /// &lt;summary&gt;
-        /// &lt;/summary&gt;
-        /// &lt;param name="orderedTarget"&gt;The orderedTarget to set.&lt;/param&gt;
-        public void SetOrderedTarget(String orderedTarget)
-        {
-            this.orderedTarget = orderedTarget;
-        }
-
-        /// &lt;summary&gt;
         /// A helper method to return a descriptive string for the topic or queue
         /// &lt;/summary&gt;
         /// &lt;param name="destination"&gt;&lt;/param&gt;
@@ -269,19 +153,19 @@
                 {
                     if(destination is ITemporaryQueue)
                     {
-                        result = new ActiveMQTempQueue(((IQueue) destination).QueueName);
+                        result = new TempQueue(((IQueue) destination).QueueName);
                     }
                     else if(destination is ITemporaryTopic)
                     {
-                        result = new ActiveMQTempTopic(((ITopic) destination).TopicName);
+                        result = new TempTopic(((ITopic) destination).TopicName);
                     }
                     else if(destination is IQueue)
                     {
-                        result = new ActiveMQQueue(((IQueue) destination).QueueName);
+                        result = new Queue(((IQueue) destination).QueueName);
                     }
                     else if(destination is ITopic)
                     {
-                        result = new ActiveMQTopic(((ITopic) destination).TopicName);
+                        result = new Topic(((ITopic) destination).TopicName);
                     }
                 }
             }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ExceptionResponse.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ExceptionResponse.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ExceptionResponse.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ExceptionResponse.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class ExceptionResponse : Response
     {
-        public const byte ID_EXCEPTIONRESPONSE = 31;
-
         BrokerError exception;
 
         ///
@@ -34,7 +32,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_EXCEPTIONRESPONSE;
+            return DataStructureTypes.ErrorResponseType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MapMessage.cs Fri Dec  4 22:53:41 2009
@@ -25,14 +25,12 @@
 {
     public class MapMessage : Message, IMapMessage
     {
-        public const byte ID_ACTIVEMQMAPMESSAGE = 25;
-
         private PrimitiveMap body;
         private PrimitiveMapInterceptor typeConverter;
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQMAPMESSAGE;
+            return DataStructureTypes.MapMessageType;
         }
 
         public override void ClearBody()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs Fri Dec  4 22:53:41 2009
@@ -22,12 +22,10 @@
 
 namespace Apache.NMS.Stomp.Commands
 {
-    public delegate void AcknowledgeHandler(ActiveMQMessage message);
+    public delegate void AcknowledgeHandler(Message message);
 
     public class Message : BaseMessage, IMessage, MarshallAware
     {
-        public const byte ID_ACTIVEMQMESSAGE = 23;
-
         private MessagePropertyIntercepter propertyHelper;
         private PrimitiveMap properties;
         private Connection connection;
@@ -44,6 +42,11 @@
             Timestamp = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
         }
 
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.MessageType;
+        }
+        
         public override int GetHashCode()
         {
             MessageId id = this.MessageId;
@@ -58,11 +61,6 @@
             }
         }
 
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQMESSAGE;
-        }
-
         public override bool Equals(object that)
         {
             if(that is Message)

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageAck.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageAck.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageAck.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageAck.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class MessageAck : BaseCommand
     {
-        public const byte ID_MESSAGEACK = 22;
-
         Destination destination;
         TransactionId transactionId;
         ConsumerId consumerId;
@@ -40,7 +38,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_MESSAGEACK;
+            return DataStructureTypes.MessageAckType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageDispatch.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageDispatch.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageDispatch.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageDispatch.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class MessageDispatch : BaseCommand
     {
-        public const byte ID_MESSAGEDISPATCH = 21;
-
         ConsumerId consumerId;
         Destination destination;
         Message message;
@@ -31,6 +29,17 @@
 
         ///
         /// &lt;summery&gt;
+        ///  Get the unique identifier that this object and its own
+        ///  Marshaler share.
+        /// &lt;/summery&gt;
+        ///
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.MessageDispatchType;
+        }
+        
+        ///
+        /// &lt;summery&gt;
         ///  Returns a string containing the information for this DataStructure
         ///  such as its type and value of its elements.
         /// &lt;/summery&gt;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class MessageId : BaseDataStructure
     {
-        public const byte ID_MESSAGEID = 110;
-
         ProducerId producerId;
         long producerSequenceId;
         long brokerSequenceId;
@@ -53,7 +51,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_MESSAGEID;
+            return DataStructureTypes.MessageIdType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class ProducerId : BaseDataStructure
     {
-        public const byte ID_PRODUCERID = 123;
-
         private SessionId parentId;
 
         string connectionId;
@@ -60,7 +58,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_PRODUCERID;
+            return DataStructureTypes.ProducerIdType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerInfo.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class ProducerInfo : BaseCommand
     {
-        public const byte ID_PRODUCERINFO = 6;
-
         ProducerId producerId;
         Destination destination;
         bool dispatchAsync;
@@ -37,7 +35,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_PRODUCERINFO;
+            return DataStructureTypes.ProducerInfoType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Queue.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Queue.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Queue.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Queue.cs Fri Dec  4 22:53:41 2009
@@ -23,8 +23,6 @@
     /// &lt;/summary&gt;
     public class Queue : Destination, IQueue
     {
-        public const byte ID_ACTIVEMQQUEUE = 100;
-
         public Queue()
             : base()
         {
@@ -50,7 +48,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQQUEUE;
+            return DataStructureTypes.QueueType;
         }
 
         public override int GetDestinationType()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/RemoveInfo.cs Fri Dec  4 22:53:41 2009
@@ -18,30 +18,15 @@
 using System;
 using System.Collections;
 
-using Apache.NMS.ActiveMQ.State;
-
 namespace Apache.NMS.Stomp.Commands
 {
     public class RemoveInfo : BaseCommand
     {
-        public const byte ID_REMOVEINFO = 12;
-
         DataStructure objectId;
         long lastDeliveredSequenceId;
 
         ///
         /// &lt;summery&gt;
-        ///  Get the unique identifier that this object and its own
-        ///  Marshaler share.
-        /// &lt;/summery&gt;
-        ///
-        public override byte GetDataStructureType()
-        {
-            return ID_REMOVEINFO;
-        }
-
-        ///
-        /// &lt;summery&gt;
         ///  Returns a string containing the information for this DataStructure
         ///  such as its type and value of its elements.
         /// &lt;/summery&gt;
@@ -54,6 +39,11 @@
                 "]";
         }
 
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.RemoveInfoType;
+        }
+        
         public DataStructure ObjectId
         {
             get { return objectId; }

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Response.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Response.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Response.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Response.cs Fri Dec  4 22:53:41 2009
@@ -25,6 +25,11 @@
     {
         int correlationId;
 
+        public override byte GetDataStructureType()
+        {
+            return DataStructureTypes.ResponseType;
+        }
+                
         ///
         /// &lt;summery&gt;
         ///  Returns a string containing the information for this DataStructure

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionId.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionId.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionId.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class SessionId : BaseDataStructure
     {
-        public const byte ID_SESSIONID = 121;
-
         private ConnectionId parentId;
 
         string connectionId;
@@ -59,7 +57,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_SESSIONID;
+            return DataStructureTypes.SessionIdType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SessionInfo.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class SessionInfo : BaseCommand
     {
-        public const byte ID_SESSIONINFO = 4;
-
         SessionId sessionId;
 
         public SessionInfo()
@@ -43,7 +41,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_SESSIONINFO;
+            return DataStructureTypes.SessionInfoType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ShutdownInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ShutdownInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ShutdownInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ShutdownInfo.cs Fri Dec  4 22:53:41 2009
@@ -20,19 +20,8 @@
 
 namespace Apache.NMS.Stomp.Commands
 {
-    /*
-     *
-     *  Command code for OpenWire format for ShutdownInfo
-     *
-     *  NOTE!: This file is auto generated - do not modify!
-     *         if you need to make a change, please see the Java Classes
-     *         in the nms-activemq-openwire-generator module
-     *
-     */
     public class ShutdownInfo : BaseCommand
     {
-        public const byte ID_SHUTDOWNINFO = 11;
-
         ///
         /// &lt;summery&gt;
         ///  Get the unique identifier that this object and its own
@@ -41,7 +30,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_SHUTDOWNINFO;
+            return DataStructureTypes.ShutdownInfoType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/StreamMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/StreamMessage.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/StreamMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/StreamMessage.cs Fri Dec  4 22:53:41 2009
@@ -32,11 +32,9 @@
         private MemoryStream byteBuffer = null;
         private int bytesRemaining = -1;
 
-        public const byte ID_ACTIVEMQSTREAMMESSAGE = 27;
-
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQSTREAMMESSAGE;
+            return DataStructureTypes.StreamMessageType;
         }
 
         public bool ReadBoolean()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SubscriptionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SubscriptionInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SubscriptionInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/SubscriptionInfo.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class SubscriptionInfo : BaseDataStructure
     {
-        public const byte ID_SUBSCRIPTIONINFO = 55;
-
         string clientId;
         Destination destination;
         string selector;
@@ -38,7 +36,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_SUBSCRIPTIONINFO;
+            return DataStructureTypes.SubscriptionInfoType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempDestination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempDestination.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempDestination.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempDestination.cs Fri Dec  4 22:53:41 2009
@@ -28,8 +28,7 @@
         /// &lt;returns&gt;An int&lt;/returns&gt;
         public override int GetDestinationType()
         {
-            // TODO: Implement this method
-            return 0;
+            return DataStructureTypes.TempDestinationType;
         }
 
         /// &lt;summary&gt;

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempQueue.cs Fri Dec  4 22:53:41 2009
@@ -23,8 +23,6 @@
     /// &lt;/summary&gt;
     public class TempQueue : TempDestination, ITemporaryQueue
     {
-        public const byte ID_ACTIVEMQTEMPQUEUE = 102;
-
         public TempQueue()
             : base()
         {
@@ -50,7 +48,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQTEMPQUEUE;
+            return DataStructureTypes.TempQueueType;
         }
 
         public override int GetDestinationType()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TempTopic.cs Fri Dec  4 22:53:41 2009
@@ -24,8 +24,6 @@
     /// &lt;/summary&gt;
     public class TempTopic : TempDestination, ITemporaryTopic
     {
-        public const byte ID_ACTIVEMQTEMPTOPIC = 103;
-
         public TempTopic()
             : base()
         {
@@ -52,7 +50,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQTEMPTOPIC;
+            return DataStructureTypes.TempTopicType;
         }
 
         public override int GetDestinationType()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TextMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TextMessage.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TextMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TextMessage.cs Fri Dec  4 22:53:41 2009
@@ -26,8 +26,6 @@
 {
     public class TextMessage : Message, ITextMessage
     {
-        public const byte ID_ACTIVEMQTEXTMESSAGE = 28;
-
         private String text = null;
 
         public TextMessage()
@@ -58,7 +56,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQTEXTMESSAGE;
+            return DataStructureTypes.TextMessageType;
         }
 
         // Properties

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Topic.cs Fri Dec  4 22:53:41 2009
@@ -24,8 +24,6 @@
     /// &lt;/summary&gt;
     public class StompTopic : Destination, ITopic
     {
-        public const byte ID_ACTIVEMQTOPIC = 101;
-
         public StompTopic() : base()
         {
         }
@@ -49,7 +47,7 @@
 
         public override byte GetDataStructureType()
         {
-            return ID_ACTIVEMQTOPIC;
+            return DataStructureTypes.TopicType;
         }
 
         public override int GetDestinationType()

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionId.cs Fri Dec  4 22:53:41 2009
@@ -22,8 +22,6 @@
 {
     public class TransactionId
     {
-        public const byte ID_TRANSACTIONID = 111;
-
         long value;
         ConnectionId connectionId;
 
@@ -35,7 +33,7 @@
         ///
         public byte GetDataStructureType()
         {
-            return ID_LOCALTRANSACTIONID;
+            return DataStructureTypes.TransactionIdType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionInfo.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/TransactionInfo.cs Fri Dec  4 22:53:41 2009
@@ -22,11 +22,9 @@
 {
     public class TransactionInfo : BaseCommand
     {
-        public const byte ID_TRANSACTIONINFO = 7;
-
         public const byte BEGIN = 0;
-        public const byte ROLLBACK = 1;
-        public const byte COMMIT = 2;
+        public const byte COMMIT = 1;
+        public const byte ROLLBACK = 2;
 
         ConnectionId connectionId;
         TransactionId transactionId;
@@ -40,7 +38,7 @@
         ///
         public override byte GetDataStructureType()
         {
-            return ID_TRANSACTIONINFO;
+            return DataStructureTypes.TransactionInfoType;
         }
 
         ///

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs Fri Dec  4 22:53:41 2009
@@ -656,9 +656,9 @@
         /// &lt;summary&gt;
         /// Creates a new local transaction ID
         /// &lt;/summary&gt;
-        public LocalTransactionId CreateLocalTransactionId()
+        public TransactionId CreateLocalTransactionId()
         {
-            LocalTransactionId id = new LocalTransactionId();
+            TransactionId id = new TransactionId();
             id.ConnectionId = ConnectionId;
             id.Value = Interlocked.Increment(ref localTransactionCounter);
             return id;

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp
+{
+    /// &lt;summary&gt;
+    /// Interface that provides for a Class to provide dispatching service for
+    /// an OpenWire MessageDispatch command.
+    /// &lt;/summary&gt;
+    public interface IDispatcher
+    {
+        void Dispatch(MessageDispatch messageDispatch);
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/IDispatcher.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs Fri Dec  4 22:53:41 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.Stomp
+{
+    public interface ISynchronization
+    {
+        /// &lt;summary&gt;
+        /// Called before a commit or rollback is applied.
+        /// &lt;/summary&gt;
+        void BeforeEnd();
+
+        /// &lt;summary&gt;
+        /// Called after a commit
+        /// &lt;/summary&gt;
+        void AfterCommit();
+
+        /// &lt;summary&gt;
+        /// Called after a transaction rollback
+        /// &lt;/summary&gt;
+        void AfterRollback();
+    }
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/ISynchronization.cs
------------------------------------------------------------------------------
    svn:eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887420 [3/3] - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/ src/main/csharp/Commands/ src/main/csharp/Threads/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204225343.D2FA023889FA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204225343-D2FA023889FA@eris-apache-org%3e</id>
<updated>2009-12-04T22:53:42Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
Fri Dec  4 22:53:41 2009
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+
+namespace Apache.NMS.Stomp.Threads
+{
+    /// &lt;summary&gt;
+    /// A TaskRunner that dedicates a single thread to running a single Task.
+    /// &lt;/summary&gt;
+    public class DedicatedTaskRunner : TaskRunner
+    {
+        private readonly Mutex mutex = new Mutex();
+        private Thread theThread = null;
+        private Task task = null;
+
+        private bool terminated = false;
+        private bool pending = false;
+        private bool shutdown = false;
+
+        public DedicatedTaskRunner(Task task)
+        {
+            if(task == null)
+            {
+                throw new NullReferenceException("Task was null");
+            }
+
+            this.task = task;
+
+            this.theThread = new Thread(Run);
+            this.theThread.IsBackground = true;
+            this.theThread.Start();
+        }
+
+        public void Shutdown(TimeSpan timeout)
+        {
+            lock(mutex)
+            {
+                this.shutdown = true;
+                this.pending = true;
+
+                Monitor.PulseAll(this.mutex);
+
+                // Wait till the thread stops ( no need to wait if shutdown
+                // is called from thread that is shutting down)
+                if(Thread.CurrentThread != this.theThread &amp;&amp; !this.terminated)
+                {
+                    Monitor.Wait(this.mutex, timeout);
+                }
+            }
+        }
+
+        public void Shutdown()
+        {
+            this.Shutdown(TimeSpan.FromMilliseconds(-1));
+        }
+
+        public void Wakeup()
+        {
+            lock(mutex)
+            {
+                if(this.shutdown)
+                {
+                    return;
+                }
+
+                this.pending = true;
+
+                Monitor.PulseAll(this.mutex);
+            }
+        }
+
+        internal void Run()
+        {
+            try
+            {
+                while(true)
+                {
+                    lock(this.mutex)
+                    {
+                        pending = false;
+
+                        if(this.shutdown)
+                        {
+
+                            return;
+                        }
+                    }
+
+                    if(!this.task.Iterate())
+                    {
+                        // wait to be notified.
+                        lock(this.mutex)
+                        {
+                            if(this.shutdown)
+                            {
+                                return;
+                            }
+
+                            while(!this.pending)
+                            {
+                                Monitor.Wait(this.mutex);
+                            }
+                        }
+                    }
+                }
+            }
+            catch
+            {
+            }
+            finally
+            {
+                // Make sure we notify any waiting threads that thread
+                // has terminated.
+                lock(this.mutex)
+                {
+                    this.terminated = true;
+                    Monitor.PulseAll(this.mutex);
+                }
+            }
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs Fri Dec
 4 22:53:41 2009
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.Stomp.Threads
+{
+    /// &lt;summary&gt;
+    /// Represents a task that may take a few iterations to complete.
+    /// &lt;/summary&gt;
+    public interface Task
+    {
+        bool Iterate();
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/Task.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs
Fri Dec  4 22:53:41 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Apache.NMS.Stomp.Threads
+{
+    /// &lt;summary&gt;
+    /// Allows you to request a thread execute the associated Task.
+    /// &lt;/summary&gt;
+    public interface TaskRunner
+    {
+        void Wakeup();
+        void Shutdown();
+        void Shutdown(TimeSpan timeout);
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunner.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs
Fri Dec  4 22:53:41 2009
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+
+namespace Apache.NMS.Stomp.Threads
+{
+    /// &lt;summary&gt;
+    /// Manages the thread pool for long running tasks. Long running tasks are not
+    /// always active but when they are active, they may need a few iterations of
+    /// processing for them to become idle. The manager ensures that each task is
+    /// processes but that no one task overtakes the system. This is kina like
+    /// cooperative multitasking.
+     /// &lt;/summary&gt;
+    public class TaskRunnerFactory
+    {
+        protected int maxIterationsPerRun;
+        protected String name;
+        protected ThreadPriority priority;
+        protected bool daemon;
+
+        public TaskRunnerFactory()
+        {
+            InitTaskRunnerFactory("ActiveMQ Task", ThreadPriority.Normal, true, 1000, false);
+        }
+
+        public TaskRunnerFactory(String name, ThreadPriority priority, bool daemon, int maxIterationsPerRun)
+        {
+            InitTaskRunnerFactory(name, priority, daemon, maxIterationsPerRun, false);
+        }
+
+        public TaskRunnerFactory(String name, ThreadPriority priority, bool daemon, int maxIterationsPerRun,
bool dedicatedTaskRunner)
+        {
+            InitTaskRunnerFactory(name, priority, daemon, maxIterationsPerRun, dedicatedTaskRunner);
+        }
+
+        public void InitTaskRunnerFactory(String name, ThreadPriority priority, bool daemon,
int maxIterationsPerRun, bool dedicatedTaskRunner)
+        {
+            this.name = name;
+            this.priority = priority;
+            this.daemon = daemon;
+            this.maxIterationsPerRun = maxIterationsPerRun;
+
+            // If your OS/JVM combination has a good thread model, you may want to avoid
+            // using a thread pool to run tasks and use a DedicatedTaskRunner instead.
+        }
+
+        public void Shutdown()
+        {
+        }
+
+        public TaskRunner CreateTaskRunner(Task task, String name)
+        {
+            return new PooledTaskRunner(task, maxIterationsPerRun);
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/TaskRunnerFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs?rev=887420&amp;view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
Fri Dec  4 22:53:41 2009
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using Apache.NMS.Stomp;
+using Apache.NMS.Stomp.Commands;
+using System.Collections;
+
+namespace Apache.NMS.Stomp
+{
+    public enum TransactionType
+    {
+        Begin = 0, Commit = 1, Rollback = 2
+    }
+}
+
+namespace Apache.NMS.Stomp
+{
+    public class TransactionContext
+    {
+        private TransactionId transactionId;
+        private Session session;
+        private ArrayList synchronizations = ArrayList.Synchronized(new ArrayList());
+
+        public TransactionContext(Session session)
+        {
+            this.session = session;
+        }
+
+        public bool InTransaction
+        {
+            get{ return this.transactionId != null; }
+        }
+
+        public TransactionId TransactionId
+        {
+            get { return transactionId; }
+        }
+
+        /// &lt;summary&gt;
+        /// Method AddSynchronization
+        /// &lt;/summary&gt;
+        public void AddSynchronization(ISynchronization synchronization)
+        {
+            synchronizations.Add(synchronization);
+        }
+
+        public void RemoveSynchronization(ISynchronization synchronization)
+        {
+            synchronizations.Remove(synchronization);
+        }
+
+        public void Begin()
+        {
+            if(!InTransaction)
+            {
+                this.transactionId = this.session.Connection.CreateLocalTransactionId();
+
+                TransactionInfo info = new TransactionInfo();
+                info.ConnectionId = this.session.Connection.ConnectionId;
+                info.TransactionId = transactionId;
+                info.Type = (int) TransactionType.Begin;
+
+                this.session.Connection.Oneway(info);
+            }
+        }
+
+        public void Rollback()
+        {
+            if(!InTransaction)
+            {
+                throw new NMSException("Invliad State: Not Currently in a Transaction");
+            }
+
+            this.BeforeEnd();
+
+            TransactionInfo info = new TransactionInfo();
+            info.ConnectionId = this.session.Connection.ConnectionId;
+            info.TransactionId = transactionId;
+            info.Type = (int) TransactionType.Rollback;
+
+            this.transactionId = null;
+            this.session.Connection.SyncRequest(info);
+
+            this.AfterRollback();
+            this.synchronizations.Clear();
+        }
+
+        public void Commit()
+        {
+            if(!InTransaction)
+            {
+                throw new NMSException("Invliad State: Not Currently in a Transaction");
+            }
+
+            this.BeforeEnd();
+
+            TransactionInfo info = new TransactionInfo();
+            info.ConnectionId = this.session.Connection.ConnectionId;
+            info.TransactionId = transactionId;
+            info.Type = (int) TransactionType.CommitOnePhase;
+
+            this.transactionId = null;
+            this.session.Connection.SyncRequest(info);
+
+            this.AfterCommit();
+            this.synchronizations.Clear();
+        }
+
+        internal void BeforeEnd()
+        {
+            lock(this.synchronizations.SyncRoot)
+            {
+                foreach(ISynchronization synchronization in this.synchronizations)
+                {
+                    synchronization.BeforeEnd();
+                }
+            }
+        }
+
+        internal void AfterCommit()
+        {
+            lock(this.synchronizations.SyncRoot)
+            {
+                foreach(ISynchronization synchronization in this.synchronizations)
+                {
+                    synchronization.AfterCommit();
+                }
+            }
+        }
+
+        internal void AfterRollback()
+        {
+            lock(this.synchronizations.SyncRoot)
+            {
+                foreach(ISynchronization synchronization in this.synchronizations)
+                {
+                    synchronization.AfterRollback();
+                }
+            }
+        }
+    }
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/TransactionContext.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj?rev=887420&amp;r1=887419&amp;r2=887420&amp;view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Fri Dec  4 22:53:41
2009
@@ -93,6 +93,19 @@
     &lt;Compile Include="src\main\csharp\ConnectionMetaData.cs" /&gt;
     &lt;Compile Include="src\main\csharp\Commands\MessageDispatch.cs" /&gt;
     &lt;Compile Include="src\main\csharp\Commands\ShutdownInfo.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\IDispatcher.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\ISynchronization.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\MessageConsumer.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\MessageProducer.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\PrefetchPolicy.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Session.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\SessionExecutor.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\TransactionContext.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Threads\DedicatedTaskRunner.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Threads\Task.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Threads\TaskRunner.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Threads\TaskRunnerFactory.cs" /&gt;
+    &lt;Compile Include="src\main\csharp\Commands\DataStructureTypes.cs" /&gt;
   &lt;/ItemGroup&gt;
   &lt;ItemGroup&gt;
     &lt;None Include="keyfile\NMSKey.snk" /&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887365 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/java/org/apache/activemq/apollo/broker/ activemq-broker/src/test/java/org/apache/activemq/broker/ activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/...</title>
<author><name>chirino@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204213635.CCB3823888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204213635-CCB3823888EC@eris-apache-org%3e</id>
<updated>2009-12-04T21:35:59Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: chirino
Date: Fri Dec  4 21:35:23 2009
New Revision: 887365

URL: http://svn.apache.org/viewvc?rev=887365&amp;view=rev
Log:
ported to the DispachSPI api

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/RunnableCountDownLatch.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchObserver.java
      - copied, changed from r887337, activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/LoadBalancer.java
      - copied, changed from r887337, activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/LoadBalancer.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/LoadBalancer.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Queue.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Transaction.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/VirtualHost.java
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/CursoredQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedPriorityQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java
    activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
    activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Queue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Queue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Queue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Queue.java Fri Dec  4 21:35:23 2009
@@ -60,9 +60,9 @@
         }
     }
 
-    public void shutdown(boolean sync) throws Exception {
+    public void shutdown(Runnable onShutdown) throws Exception {
         if (queue != null) {
-            queue.shutdown(sync);
+            queue.shutdown(onShutdown);
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Transaction.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Transaction.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Transaction.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/Transaction.java Fri Dec  4 21:35:23 2009
@@ -499,7 +499,7 @@
 
             //If we've reached the end of the op queue
             if (opQueue.getEnqueuedCount() == 0) {
-                opQueue.shutdown(false);
+                opQueue.shutdown(null);
             }
         }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/VirtualHost.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/VirtualHost.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/VirtualHost.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/VirtualHost.java Fri Dec  4 21:35:23 2009
@@ -27,6 +27,7 @@
 import org.apache.activemq.apollo.broker.path.PathFilter;
 import org.apache.activemq.broker.store.Store;
 import org.apache.activemq.broker.store.StoreFactory;
+import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
 import org.apache.activemq.queue.IQueue;
 import org.apache.activemq.util.IOHelper;
 import org.apache.activemq.util.buffer.AsciiBuffer;
@@ -161,14 +162,20 @@
         if (!started) {
             return;
         }
-        for (Queue queue : queues.values()) {
-            queue.shutdown(true);
-        }
-
-        for (IQueue&lt;Long, MessageDelivery&gt; queue : queueStore.getDurableQueues()) {
-            queue.shutdown(true);
+        ArrayList&lt;Queue&gt; q = new ArrayList&lt;Queue&gt;(queues.values());
+        RunnableCountDownLatch done = new RunnableCountDownLatch(q.size());
+        for (Queue queue : q) {
+            queue.shutdown(done);
+        }
+        done.await();
+
+        ArrayList&lt;IQueue&lt;Long, MessageDelivery&gt;&gt; durableQueues = new ArrayList&lt;IQueue&lt;Long,MessageDelivery&gt;&gt;(queueStore.getDurableQueues());
+        done = new RunnableCountDownLatch(durableQueues.size());
+        for (IQueue&lt;Long, MessageDelivery&gt; queue : durableQueues) {
+            queue.shutdown(done);
         }
-
+        done.await();
+        
         database.stop();
         started = false;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/java/org/apache/activemq/broker/RemoteProducer.java Fri Dec  4 21:35:23 2009
@@ -6,7 +6,7 @@
 import org.apache.activemq.apollo.Connection;
 import org.apache.activemq.apollo.broker.Destination;
 import org.apache.activemq.apollo.broker.MessageDelivery;
-import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.flow.IFlowController;
 import org.apache.activemq.flow.IFlowSink;
 import org.apache.activemq.flow.ISinkController;
@@ -29,13 +29,15 @@
     protected String property;
     protected MetricAggregator totalProducerRate;
     protected MessageDelivery next;
-    protected DispatchContext dispatchContext;
+    protected DispatchQueue dispatchQueue;
+    protected Runnable dispatchTask;
     protected String filler;
     protected int payloadSize = 20;
     protected URI uri;
 
     protected IFlowController&lt;MessageDelivery&gt; outboundController;
     protected IFlowSink&lt;MessageDelivery&gt; outboundQueue;
+
     
     public void start() throws Exception {
         
@@ -57,12 +59,13 @@
         
         setupProducer();
         
-        dispatchContext = getDispatcher().register(new Runnable(){
+        dispatchQueue = getDispatcher().createQueue(name + "-client");
+        dispatchTask = new Runnable(){
             public void run() {
                 dispatch();
             }
-        }, name + "-client");
-        dispatchContext.requestDispatch();
+        };
+        dispatchQueue.dispatchAsync(dispatchTask);
 
     }
     
@@ -96,12 +99,12 @@
 
     public void stop() throws Exception
     {
-    	dispatchContext.close(false);
+    	dispatchQueue.release();
     	super.stop();
     }
     
 	public void onFlowUnblocked(ISinkController&lt;MessageDelivery&gt; controller) {
-		dispatchContext.requestDispatch();
+        dispatchQueue.dispatchAsync(dispatchTask);
 	}
 
     protected String createPayload() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObject.java Fri Dec  4 21:35:23 2009
@@ -22,8 +22,12 @@
  */
 public interface DispatchObject {
     
+    public void retain();
+    public void release();
+
     public &lt;Context&gt; Context getContext();
     public &lt;Context&gt; void setContext(Context context);
+
     public void suspend();
     public void resume();
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/AbstractDispatchObject.java Fri Dec  4 21:35:23 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.dispatch.internal;
 
+import java.util.concurrent.atomic.AtomicReference;
+
 import org.apache.activemq.dispatch.DispatchObject;
 import org.apache.activemq.dispatch.DispatchQueue;
 
@@ -25,9 +27,9 @@
  */
 abstract public class AbstractDispatchObject implements DispatchObject {
 
-    protected Object context;
-    protected Runnable finalizer;
-    protected DispatchQueue targetQueue;
+    protected volatile Object context;
+    protected volatile DispatchQueue targetQueue;
+    protected AtomicReference&lt;Runnable&gt; finalizer = new AtomicReference&lt;Runnable&gt;();
 
     @SuppressWarnings("unchecked")
     public &lt;Context&gt; Context getContext() {
@@ -39,7 +41,7 @@
     }
 
     public void setFinalizer(Runnable finalizer) {
-        this.finalizer = finalizer;
+        this.finalizer.set(finalizer);
     }
 
     public void setTargetQueue(DispatchQueue targetQueue) {

Added: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/RunnableCountDownLatch.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/RunnableCountDownLatch.java?rev=887365&amp;view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/RunnableCountDownLatch.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/RunnableCountDownLatch.java Fri Dec  4 21:35:23 2009
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.dispatch.internal;
+
+import java.util.concurrent.CountDownLatch;
+
+public class RunnableCountDownLatch extends CountDownLatch implements Runnable {
+    public RunnableCountDownLatch(int count) {
+        super(count);
+    }
+    public void run() {
+        countDown();
+    }
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/SerialDispatchQueue.java Fri Dec  4 21:35:23 2009
@@ -31,6 +31,7 @@
 
     private final ConcurrentLinkedQueue&lt;Runnable&gt; runnables = new ConcurrentLinkedQueue&lt;Runnable&gt;();
     final private String label;
+    final private AtomicInteger reatinCounter = new AtomicInteger(1);
     final private AtomicInteger suspendCounter = new AtomicInteger();
     final private AtomicLong size = new AtomicLong();
     
@@ -60,9 +61,12 @@
         if( runnable == null ) {
             throw new IllegalArgumentException();
         }
-        long lastSize = size.incrementAndGet();
+        long lastSize = size.getAndIncrement();
+        if( lastSize==0 ) {
+            retain();
+        }
         runnables.add(runnable);
-        if( targetQueue!=null &amp;&amp; lastSize == 1 &amp;&amp; suspendCounter.get()&lt;=0 ) {
+        if( targetQueue!=null &amp;&amp; lastSize == 0 &amp;&amp; suspendCounter.get()&lt;=0 ) {
             targetQueue.dispatchAsync(this);
         }
     }
@@ -79,6 +83,9 @@
                     if( runnable!=null ) {
                         runnable.run();
                         lsize = size.decrementAndGet();
+                        if( lsize==0 ) {
+                            release();
+                        }
                     }
                 } catch (Throwable e) {
                     e.printStackTrace();
@@ -96,4 +103,19 @@
     public void dispatchApply(int iterations, Runnable runnable) throws InterruptedException {
         QueueSupport.dispatchApply(this, iterations, runnable);
     }
+
+    public void retain() {
+        int prev = reatinCounter.getAndIncrement();
+        assert prev!=0;
+    }
+
+    public void release() {
+        if( reatinCounter.decrementAndGet()==0 ) {
+            Runnable value = finalizer.getAndSet(null);
+            if( value!=null ) {
+                value.run();
+            }
+        }
+    }
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/AdvancedDispatchSPI.java Fri Dec  4 21:35:23 2009
@@ -27,7 +27,6 @@
 import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.DispatchSPI;
 import org.apache.activemq.dispatch.DispatchSource;
-import org.apache.activemq.dispatch.LoadBalancer;
 import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
 import org.apache.activemq.dispatch.internal.SerialDispatchQueue;
 
@@ -177,9 +176,9 @@
         }
     }
 
-    public DispatchContext register(Runnable runnable, String name) {
-        return chooseDispatcher().register(runnable, name);
-    }
+//    public DispatchContext register(Runnable runnable, String name) {
+//        return chooseDispatcher().register(runnable, name);
+//    }
 
 	public int getSize() {
 		return size;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchContext.java Fri Dec  4 21:35:23 2009
@@ -1,68 +1,260 @@
 package org.apache.activemq.dispatch.internal.advanced;
 
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.RejectedExecutionException;
 
-import org.apache.activemq.dispatch.DispatchObserver;
-
+import org.apache.activemq.dispatch.internal.advanced.DispatcherThread.UpdateEvent;
+import org.apache.activemq.util.list.LinkedNode;
 
 /**
- * Returned to callers registered with this dispathcer. Used by the caller
- * to inform the dispatcher that it is ready for dispatch.
  * 
- * Note that DispatchContext is not safe for concurrent access by multiple
- * threads.
  */
-public interface DispatchContext {
-    
-    /**
-     * Once registered with a dispatcher, this can be called to request
-     * dispatch. The {@link Dispatchable} will remain in the dispatch queue
-     * until a subsequent call to {@link Dispatchable#dispatch()} returns
-     * false;
-     * 
-     * @throws RejectedExecutionException If the dispatcher has been shutdown.
-     */
-    public void requestDispatch() throws RejectedExecutionException;
+class DispatchContext extends LinkedNode&lt;DispatchContext&gt; {
+
+    private final DispatcherThread dispacher;
+    // The target:
+    private final Runnable runnable;
+    // The name of this context:
+    final String name;
+    // list prio can only be updated in the thread of of the owning
+    // dispatcher
+    protected int listPrio;
+
+    // The update events are used to update fields in the dispatch context
+    // from foreign threads:
+    final UpdateEvent updateEvent[];
+
+    final DispatchObserver tracker;
+    protected DispatcherThread currentOwner;
+    private DispatcherThread updateDispatcher = null;
+
+    int priority;
+    private boolean dispatchRequested = false;
+    private boolean closed = false;
+    final CountDownLatch closeLatch = new CountDownLatch(1);
+
+    protected DispatchContext(DispatcherThread dispatcherThread, Runnable runnable, boolean persistent, String name) {
+        dispacher = dispatcherThread;
+        this.runnable = runnable;
+        this.name = name;
+        this.currentOwner = (DispatcherThread) dispacher;
+        if (persistent &amp;&amp; dispacher.spi != null) {
+            this.tracker = dispacher.spi.getLoadBalancer().createExecutionTracker((DispatchContext) this);
+        } else {
+            this.tracker = null;
+        }
+        updateEvent = createUpdateEvent();
+        updateEvent[0] = dispacher.new UpdateEvent(this);
+        updateEvent[1] = dispacher.new UpdateEvent(this);
+        if (persistent) {
+            currentOwner.takeOwnership(this);
+        }
+    }
+
+    private final DispatcherThread.UpdateEvent[] createUpdateEvent() {
+        return new DispatcherThread.UpdateEvent[2];
+    }
 
     /**
-     * This can be called to update the dispatch priority.
+     * Gets the execution tracker for the context.
      * 
-     * @param priority
+     * @return the execution tracker for the context:
      */
-    public void updatePriority(int priority);
+    public DispatchObserver getExecutionTracker() {
+        return tracker;
+    }
 
     /**
-     * Gets the name of the dispatch context
+     * This can only be called by the owning dispatch thread:
      * 
-     * @return The dispatchable
+     * @return False if the dispatchable has more work to do.
      */
-    public String getName();
+    public final void run() {
+        runnable.run();
+    }
 
-    /**
-     * This must be called to release any resource the dispatcher is holding
-     * on behalf of this context. Once called this {@link DispatchContext} should
-     * no longer be used. 
-     */
-    public void close(boolean sync);
-    
-    /**
-     * Called to transfer a {@link PooledDispatchContext} to a new
-     * Dispatcher.
-     */
-    public void setTargetQueue(DispatcherThread newDispatcher);
+    public final void setTargetQueue(DispatcherThread newDispatcher) {
+        synchronized (this) {
 
-    /**
-     * Gets the dispatcher to which this PooledDispatchContext currently
-     * belongs
-     * 
-     * @return
-     */
-    public DispatcherThread getTargetQueue();
+            // If we're already set to this dispatcher
+            if (newDispatcher == currentOwner) {
+                if (updateDispatcher == null || updateDispatcher == newDispatcher) {
+                    return;
+                }
+            }
+
+            updateDispatcher = (DispatcherThread) newDispatcher;
+            if (DispatcherThread.DEBUG)
+                System.out.println(getName() + " updating to " + updateDispatcher);
+
+            currentOwner.onForeignUpdate(this);
+        }
+
+    }
+
+    public void requestDispatch() {
+
+        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+        if (tracker != null)
+            tracker.onDispatch(callingDispatcher, dispacher.getCurrentDispatchContext());
+
+        // Otherwise this is coming off another thread, so we need to
+        // synchronize
+        // to protect against ownership changes:
+        synchronized (this) {
+            // If the owner of this context is the calling thread, then
+            // delegate to the dispatcher.
+            if (currentOwner == callingDispatcher) {
+
+                if (!currentOwner.running) {
+                    // TODO In the event that the current dispatcher
+                    // failed due to a runtime exception, we could
+                    // try to switch to a new dispatcher.
+                    throw new RejectedExecutionException();
+                }
+                if (!isLinked()) {
+                    currentOwner.priorityQueue.add(this, listPrio);
+                }
+                return;
+            }
+
+            dispatchRequested = true;
+            currentOwner.onForeignUpdate(this);
+        }
+    }
+
+    public void updatePriority(int priority) {
+
+        if (closed) {
+            return;
+        }
+
+        priority = Math.min(priority, dispacher.MAX_USER_PRIORITY);
+
+        if (this.priority == priority) {
+            return;
+        }
+        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+
+        // Otherwise this is coming off another thread, so we need to
+        // synchronize to protect against ownership changes:
+        synchronized (this) {
+            if (closed) {
+                return;
+            }
+            this.priority = priority;
+
+            // If this is called by the owning dispatcher, then we go ahead
+            // and update:
+            if (currentOwner == callingDispatcher) {
+
+                if (priority != listPrio) {
+
+                    listPrio = priority;
+                    // If there is a priority change relink the context
+                    // at the new priority:
+                    if (isLinked()) {
+                        unlink();
+                        currentOwner.priorityQueue.add(this, listPrio);
+                    }
+                }
+                return;
+            }
+
+            currentOwner.onForeignUpdate(this);
+        }
+
+    }
+
+    public void processForeignUpdates() {
+        synchronized (this) {
+
+            if (closed) {
+                close(false);
+                return;
+            }
+
+            if (updateDispatcher != null &amp;&amp; updateDispatcher.takeOwnership(this)) {
+                if (DispatcherThread.DEBUG) {
+                    System.out.println("Assigning " + getName() + " to " + updateDispatcher);
+                }
+
+                if (currentOwner.removeDispatchContext(this)) {
+                    dispatchRequested = true;
+                }
+
+                updateDispatcher.onForeignUpdate(this);
+                switchedDispatcher(currentOwner, updateDispatcher);
+                currentOwner = updateDispatcher;
+                updateDispatcher = null;
+
+            } else {
+                updatePriority(priority);
+
+                if (dispatchRequested) {
+                    dispatchRequested = false;
+                    requestDispatch();
+                }
+            }
+        }
+    }
 
     /**
-     * Gets the execution tracker for the context.
+     * May be overriden by subclass to additional work on dispatcher switch
      * 
-     * @return the execution tracker for the context:
+     * @param oldDispatcher The old dispatcher
+     * @param newDispatcher The new Dispatcher
      */
-    public DispatchObserver getExecutionTracker();    
+    protected void switchedDispatcher(DispatcherThread oldDispatcher, DispatcherThread newDispatcher) {
+
+    }
+
+    public boolean isClosed() {
+        return closed;
+    }
+
+    public void close(boolean sync) {
+        DispatcherThread callingDispatcher = dispacher.getCurrentDispatcher();
+        // System.out.println(this + "Closing");
+        synchronized (this) {
+            closed = true;
+            // If the owner of this context is the calling thread, then
+            // delegate to the dispatcher.
+            if (currentOwner == callingDispatcher) {
+                dispacher.removeDispatchContext(this);
+                closeLatch.countDown();
+                return;
+            }
+        }
+
+        currentOwner.onForeignUpdate(this);
+        if (sync) {
+            boolean interrupted = false;
+            while (true) {
+                try {
+                    closeLatch.await();
+                    break;
+                } catch (InterruptedException e) {
+                    interrupted = true;
+                }
+            }
+
+            if (interrupted) {
+                Thread.currentThread().interrupt();
+            }
+        }
+    }
+
+    public final String toString() {
+        return getName();
+    }
+
+    public DispatcherThread getTargetQueue() {
+        return currentOwner;
+    }
+
+    public String getName() {
+        return name;
+    }
+
 }
\ No newline at end of file

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchObserver.java (from r887337, activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchObserver.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchObserver.java&amp;p1=activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java&amp;r1=887337&amp;r2=887365&amp;rev=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/DispatchObserver.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatchObserver.java Fri Dec  4 21:35:23 2009
@@ -15,10 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.activemq.dispatch;
+package org.apache.activemq.dispatch.internal.advanced;
 
 import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
 
 public interface DispatchObserver {
     

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/DispatcherThread.java Fri Dec  4 21:35:23 2009
@@ -18,15 +18,12 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.activemq.dispatch.DispatchObserver;
 import org.apache.activemq.dispatch.DispatchSystem;
 import org.apache.activemq.dispatch.DispatchSystem.DispatchQueuePriority;
 import org.apache.activemq.util.Mapper;
@@ -39,18 +36,18 @@
 
     private final ThreadDispatchQueue dispatchQueues[];
     
-    private static final boolean DEBUG = false;
+    static final boolean DEBUG = false;
     private Thread thread;
     protected boolean running = false;
     private boolean threaded = false;
     protected final int MAX_USER_PRIORITY;
-    protected final HashSet&lt;PriorityDispatchContext&gt; contexts = new HashSet&lt;PriorityDispatchContext&gt;();
+    protected final HashSet&lt;DispatchContext&gt; contexts = new HashSet&lt;DispatchContext&gt;();
 
     // Set if this dispatcher is part of a dispatch pool:
     protected final AdvancedDispatchSPI spi;
 
     // The local dispatch queue:
-    protected final PriorityLinkedList&lt;PriorityDispatchContext&gt; priorityQueue;
+    protected final PriorityLinkedList&lt;DispatchContext&gt; priorityQueue;
 
     // Dispatch queue for requests from other threads:
     private final LinkedNodeList&lt;ForeignEvent&gt;[] foreignQueue;
@@ -69,8 +66,8 @@
     private final AtomicBoolean foreignAvailable = new AtomicBoolean(false);
     private final Semaphore foreignPermits = new Semaphore(0);
 
-    private final Mapper&lt;Integer, PriorityDispatchContext&gt; PRIORITY_MAPPER = new Mapper&lt;Integer, PriorityDispatchContext&gt;() {
-        public Integer map(PriorityDispatchContext element) {
+    private final Mapper&lt;Integer, DispatchContext&gt; PRIORITY_MAPPER = new Mapper&lt;Integer, DispatchContext&gt;() {
+        public Integer map(DispatchContext element) {
             return element.listPrio;
         }
     };
@@ -84,7 +81,7 @@
         }
 
         MAX_USER_PRIORITY = priorities - 1;
-        priorityQueue = new PriorityLinkedList&lt;PriorityDispatchContext&gt;(MAX_USER_PRIORITY + 1, PRIORITY_MAPPER);
+        priorityQueue = new PriorityLinkedList&lt;DispatchContext&gt;(MAX_USER_PRIORITY + 1, PRIORITY_MAPPER);
         foreignQueue = createForeignEventQueue();
         for (int i = 0; i &lt; 2; i++) {
             foreignQueue[i] = new LinkedNodeList&lt;ForeignEvent&gt;();
@@ -124,10 +121,10 @@
         return MAX_USER_PRIORITY;
     }
 
-    private class UpdateEvent extends ForeignEvent {
-        private final PriorityDispatchContext pdc;
+    class UpdateEvent extends ForeignEvent {
+        private final DispatchContext pdc;
 
-        UpdateEvent(PriorityDispatchContext pdc) {
+        UpdateEvent(DispatchContext pdc) {
             this.pdc = pdc;
         }
 
@@ -138,7 +135,7 @@
     }
 
     public DispatchContext register(Runnable runnable, String name) {
-        return new PriorityDispatchContext(runnable, true, name);
+        return new DispatchContext(this, runnable, true, name);
     }
 
     /*
@@ -191,14 +188,14 @@
     }
 
     protected void cleanup() {
-        ArrayList&lt;PriorityDispatchContext&gt; toClose = null;
+        ArrayList&lt;DispatchContext&gt; toClose = null;
         synchronized (this) {
             running = false;
-            toClose = new ArrayList&lt;PriorityDispatchContext&gt;(contexts.size());
+            toClose = new ArrayList&lt;DispatchContext&gt;(contexts.size());
             toClose.addAll(contexts);
         }
 
-        for (PriorityDispatchContext context : toClose) {
+        for (DispatchContext context : toClose) {
             context.close(false);
         }
     }
@@ -210,7 +207,7 @@
             spi.onDispatcherStarted((DispatcherThread) this);
         }
 
-        PriorityDispatchContext pdc;
+        DispatchContext pdc;
         try {
             while (running) {
                 int counter = 0;
@@ -303,7 +300,7 @@
         foreignPermits.release();
     }
 
-    protected final void onForeignUpdate(PriorityDispatchContext context) {
+    protected final void onForeignUpdate(DispatchContext context) {
         synchronized (foreignQueue) {
 
             ForeignEvent fe = context.updateEvent[foreignToggle];
@@ -316,7 +313,7 @@
         }
     }
 
-    protected final boolean removeDispatchContext(PriorityDispatchContext context) {
+    protected final boolean removeDispatchContext(DispatchContext context) {
         synchronized (foreignQueue) {
 
             if (context.updateEvent[0].isLinked()) {
@@ -339,7 +336,7 @@
         return false;
     }
 
-    protected final boolean takeOwnership(PriorityDispatchContext context) {
+    protected final boolean takeOwnership(DispatchContext context) {
         synchronized (this) {
             if (running) {
                 contexts.add(context);
@@ -352,7 +349,7 @@
 
     //Special dispatch method that allow high priority dispatch:
     private final void dispatchInternal(Runnable runnable, int priority) {
-        PriorityDispatchContext context = new PriorityDispatchContext(runnable, false, name);
+        DispatchContext context = new DispatchContext(this, runnable, false, name);
         context.priority = priority;
         context.requestDispatch();
     }
@@ -365,7 +362,7 @@
      * .dispatch.Dispatcher.Dispatchable)
      */
     public final void dispatch(Runnable runnable, int priority) {
-        PriorityDispatchContext context = new PriorityDispatchContext(runnable, false, name);
+        DispatchContext context = new DispatchContext(this, runnable, false, name);
         context.updatePriority(priority);
         context.requestDispatch();
     }
@@ -425,7 +422,7 @@
         return name;
     }
 
-    private final DispatcherThread getCurrentDispatcher() {
+    final DispatcherThread getCurrentDispatcher() {
         if (spi != null) {
             return (DispatcherThread) spi.getCurrentDispatcher();
         } else if (Thread.currentThread() == thread) {
@@ -436,260 +433,10 @@
 
     }
 
-    private final DispatchContext getCurrentDispatchContext() {
+    final DispatchContext getCurrentDispatchContext() {
         return spi.getCurrentDispatchContext();
     }
 
-    /**
-     * 
-     */
-    protected class PriorityDispatchContext extends LinkedNode&lt;PriorityDispatchContext&gt; implements DispatchContext {
-        // The target:
-        private final Runnable runnable;
-        // The name of this context:
-        final String name;
-        // list prio can only be updated in the thread of of the owning
-        // dispatcher
-        protected int listPrio;
-
-        // The update events are used to update fields in the dispatch context
-        // from foreign threads:
-        final UpdateEvent updateEvent[];
-
-        private final DispatchObserver tracker;
-        protected DispatcherThread currentOwner;
-        private DispatcherThread updateDispatcher = null;
-
-        private int priority;
-        private boolean dispatchRequested = false;
-        private boolean closed = false;
-        final CountDownLatch closeLatch = new CountDownLatch(1);
-
-        protected PriorityDispatchContext(Runnable runnable, boolean persistent, String name) {
-            this.runnable = runnable;
-            this.name = name;
-            this.currentOwner = (DispatcherThread) DispatcherThread.this;
-            if (persistent &amp;&amp; spi != null) {
-                this.tracker = spi.getLoadBalancer().createExecutionTracker((DispatchContext) this);
-            } else {
-                this.tracker = null;
-            }
-            updateEvent = createUpdateEvent();
-            updateEvent[0] = new UpdateEvent(this);
-            updateEvent[1] = new UpdateEvent(this);
-            if (persistent) {
-                currentOwner.takeOwnership(this);
-            }
-        }
-
-        private final DispatcherThread.UpdateEvent[] createUpdateEvent() {
-            return new DispatcherThread.UpdateEvent[2];
-        }
-
-        /**
-         * Gets the execution tracker for the context.
-         * 
-         * @return the execution tracker for the context:
-         */
-        public DispatchObserver getExecutionTracker() {
-            return tracker;
-        }
-
-        /**
-         * This can only be called by the owning dispatch thread:
-         * 
-         * @return False if the dispatchable has more work to do.
-         */
-        public final void run() {
-            runnable.run();
-        }
-
-        public final void setTargetQueue(DispatcherThread newDispatcher) {
-            synchronized (this) {
-
-                // If we're already set to this dispatcher
-                if (newDispatcher == currentOwner) {
-                    if (updateDispatcher == null || updateDispatcher == newDispatcher) {
-                        return;
-                    }
-                }
-
-                updateDispatcher = (DispatcherThread) newDispatcher;
-                if (DEBUG)
-                    System.out.println(getName() + " updating to " + updateDispatcher);
-
-                currentOwner.onForeignUpdate(this);
-            }
-
-        }
-
-        public void requestDispatch() {
-
-            DispatcherThread callingDispatcher = getCurrentDispatcher();
-            if (tracker != null)
-                tracker.onDispatch(callingDispatcher, getCurrentDispatchContext());
-
-            // Otherwise this is coming off another thread, so we need to
-            // synchronize
-            // to protect against ownership changes:
-            synchronized (this) {
-                // If the owner of this context is the calling thread, then
-                // delegate to the dispatcher.
-                if (currentOwner == callingDispatcher) {
-
-                    if (!currentOwner.running) {
-                        // TODO In the event that the current dispatcher
-                        // failed due to a runtime exception, we could
-                        // try to switch to a new dispatcher.
-                        throw new RejectedExecutionException();
-                    }
-                    if (!isLinked()) {
-                        currentOwner.priorityQueue.add(this, listPrio);
-                    }
-                    return;
-                }
-
-                dispatchRequested = true;
-                currentOwner.onForeignUpdate(this);
-            }
-        }
-
-        public void updatePriority(int priority) {
-
-            if (closed) {
-                return;
-            }
-
-            priority = Math.min(priority, MAX_USER_PRIORITY);
-
-            if (this.priority == priority) {
-                return;
-            }
-            DispatcherThread callingDispatcher = getCurrentDispatcher();
-
-            // Otherwise this is coming off another thread, so we need to
-            // synchronize to protect against ownership changes:
-            synchronized (this) {
-                if (closed) {
-                    return;
-                }
-                this.priority = priority;
-
-                // If this is called by the owning dispatcher, then we go ahead
-                // and update:
-                if (currentOwner == callingDispatcher) {
-
-                    if (priority != listPrio) {
-
-                        listPrio = priority;
-                        // If there is a priority change relink the context
-                        // at the new priority:
-                        if (isLinked()) {
-                            unlink();
-                            currentOwner.priorityQueue.add(this, listPrio);
-                        }
-                    }
-                    return;
-                }
-
-                currentOwner.onForeignUpdate(this);
-            }
-
-        }
-
-        public void processForeignUpdates() {
-            synchronized (this) {
-
-                if (closed) {
-                    close(false);
-                    return;
-                }
-
-                if (updateDispatcher != null &amp;&amp; updateDispatcher.takeOwnership(this)) {
-                    if (DEBUG) {
-                        System.out.println("Assigning " + getName() + " to " + updateDispatcher);
-                    }
-
-                    if (currentOwner.removeDispatchContext(this)) {
-                        dispatchRequested = true;
-                    }
-
-                    updateDispatcher.onForeignUpdate(this);
-                    switchedDispatcher(currentOwner, updateDispatcher);
-                    currentOwner = updateDispatcher;
-                    updateDispatcher = null;
-
-                } else {
-                    updatePriority(priority);
-
-                    if (dispatchRequested) {
-                        dispatchRequested = false;
-                        requestDispatch();
-                    }
-                }
-            }
-        }
-
-        /**
-         * May be overriden by subclass to additional work on dispatcher switch
-         * 
-         * @param oldDispatcher The old dispatcher
-         * @param newDispatcher The new Dispatcher
-         */
-        protected void switchedDispatcher(DispatcherThread oldDispatcher, DispatcherThread newDispatcher) {
-
-        }
-
-        public boolean isClosed() {
-            return closed;
-        }
-
-        public void close(boolean sync) {
-            DispatcherThread callingDispatcher = getCurrentDispatcher();
-            // System.out.println(this + "Closing");
-            synchronized (this) {
-                closed = true;
-                // If the owner of this context is the calling thread, then
-                // delegate to the dispatcher.
-                if (currentOwner == callingDispatcher) {
-                    removeDispatchContext(this);
-                    closeLatch.countDown();
-                    return;
-                }
-            }
-
-            currentOwner.onForeignUpdate(this);
-            if (sync) {
-                boolean interrupted = false;
-                while (true) {
-                    try {
-                        closeLatch.await();
-                        break;
-                    } catch (InterruptedException e) {
-                        interrupted = true;
-                    }
-                }
-
-                if (interrupted) {
-                    Thread.currentThread().interrupt();
-                }
-            }
-        }
-
-        public final String toString() {
-            return getName();
-        }
-
-        public DispatcherThread getTargetQueue() {
-            return currentOwner;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-    }
-
     public String getName() {
         return name;
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/GlobalDispatchQueue.java Fri Dec  4 21:35:23 2009
@@ -85,4 +85,10 @@
     public DispatchQueue getTargetQueue() {
         throw new UnsupportedOperationException();
     }
+
+    public void release() {
+    }
+
+    public void retain() {
+    }
 }

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/LoadBalancer.java (from r887337, activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/LoadBalancer.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/LoadBalancer.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/LoadBalancer.java&amp;p1=activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/LoadBalancer.java&amp;r1=887337&amp;r2=887365&amp;rev=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/LoadBalancer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/LoadBalancer.java Fri Dec  4 21:35:23 2009
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.dispatch;
+package org.apache.activemq.dispatch.internal.advanced;
 
 import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
-import org.apache.activemq.dispatch.internal.advanced.DispatcherThread;
 
 
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/SimpleLoadBalancer.java Fri Dec  4 21:35:23 2009
@@ -22,8 +22,6 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.activemq.dispatch.DispatchObserver;
-import org.apache.activemq.dispatch.LoadBalancer;
 
 
 public class SimpleLoadBalancer implements LoadBalancer {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/advanced/ThreadDispatchQueue.java Fri Dec  4 21:35:23 2009
@@ -86,4 +86,10 @@
         throw new UnsupportedOperationException();
     }
 
+    public void release() {
+    }
+
+    public void retain() {
+    }
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/GlobalDispatchQueue.java Fri Dec  4 21:35:23 2009
@@ -103,4 +103,10 @@
     public DispatchQueuePriority getPriority() {
         return priority;
     }
+
+    public void release() {
+    }
+
+    public void retain() {
+    }
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/main/java/org/apache/activemq/dispatch/internal/simple/ThreadDispatchQueue.java Fri Dec  4 21:35:23 2009
@@ -123,4 +123,10 @@
         return priority;
     }
 
+    public void release() {
+    }
+
+    public void retain() {
+    }
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/DispatchSystemTest.java Fri Dec  4 21:35:23 2009
@@ -18,6 +18,7 @@
 
 import java.util.concurrent.CountDownLatch;
 
+import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.dispatch.internal.simple.SimpleDispatchSPI;
 
@@ -30,15 +31,6 @@
  */
 public class DispatchSystemTest {
 
-    public static class RunnableCountDownLatch extends CountDownLatch implements Runnable {
-        public RunnableCountDownLatch(int count) {
-            super(count);
-        }
-        public void run() {
-            countDown();
-        }
-    }
-    
     public static void main(String[] args) throws Exception {
         DispatchSPI advancedSystem = new AdvancedDispatchSPI(Runtime.getRuntime().availableProcessors(), 3);
         advancedSystem.start();

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dispatcher/src/test/java/org/apache/activemq/dispatch/internal/advanced/DispatcherPoolTest.java Fri Dec  4 21:35:23 2009
@@ -18,6 +18,8 @@
 
 import java.util.concurrent.CountDownLatch;
 
+import org.apache.activemq.dispatch.DispatchQueue;
+
 
 import static java.lang.String.*;
 
@@ -50,24 +52,24 @@
         final CountDownLatch counter = new CountDownLatch(iterations);
         for (int i = 0; i &lt; 1000; i++) {
             Work dispatchable = new Work(counter, pooledDispatcher);
-            dispatchable.context.requestDispatch();
+            dispatchable.dispatchQueue.dispatchAsync(dispatchable);
         }
         counter.await();
     }
     
     private static final class Work implements Runnable {
         private final CountDownLatch counter;
-        private final DispatchContext context;
+        private final DispatchQueue dispatchQueue;
 
         private Work(CountDownLatch counter, AdvancedDispatchSPI spi) {
             this.counter = counter;
-            this.context = spi.register(this , "test");
+            dispatchQueue = spi.createQueue("test");
         }
 
         public void run() {
             counter.countDown();
             if( counter.getCount()&gt;0 ) {
-                context.requestDispatch();
+                dispatchQueue.dispatchAsync(this);
             }
         }
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-openwire/src/test/java/org/apache/activemq/perf/broker/SharedQueuePerfTest.java Fri Dec  4 21:35:23 2009
@@ -39,8 +39,8 @@
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerId;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
-import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
 import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
@@ -288,7 +288,8 @@
         private String name;
         protected final MetricCounter sendRate = new MetricCounter();
 		AtomicBoolean waitingForAck = new AtomicBoolean();
-        private final DispatchContext dispatchContext;
+        private final DispatchQueue dispatchQueue;
+        private final Runnable dispatchTask;
 
         protected IFlowController&lt;OpenWireMessageDelivery&gt; outboundController;
         protected final AbstractFlowRelay&lt;OpenWireMessageDelivery&gt; outboundQueue;
@@ -306,11 +307,14 @@
             this.name = name;
             sendRate.name("Producer " + name + " Rate");
             totalProducerRate.add(sendRate);
-            dispatchContext = dispatcher.register(new Runnable(){
+            
+            dispatchQueue = dispatcher.createQueue(name);
+            dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();
                 }
-            }, name);
+            };
+ 
             // create a 1024 byte payload (2 bytes per char):
             payload = new String(new byte[512]);
             producerId = new ProducerId(name);
@@ -353,7 +357,7 @@
         }
 
         public void start() {
-            dispatchContext.requestDispatch();
+            dispatchQueue.dispatchAsync(dispatchTask);
         }
 
         public void stop() {
@@ -383,7 +387,7 @@
 						next.setPersistListener(new PersistListener() {
 							public void onMessagePersisted(OpenWireMessageDelivery delivery) {
 								waitingForAck.set(false);
-								dispatchContext.requestDispatch();
+					            dispatchQueue.dispatchAsync(dispatchTask);
 							}
 						});
 					}
@@ -398,7 +402,7 @@
             outboundQueue.add(next, null);
             next = null;
             if ( !stopped.get() ) {
-                dispatchContext.requestDispatch();
+                dispatchQueue.dispatchAsync(dispatchTask);
             }
         }
 
@@ -416,7 +420,7 @@
         }
 
         public void onFlowUnblocked(ISinkController&lt;OpenWireMessageDelivery&gt; controller) {
-            dispatchContext.requestDispatch();
+            dispatchQueue.dispatchAsync(dispatchTask);
         }
 
         public String toString() {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/AbstractFlowQueue.java Fri Dec  4 21:35:23 2009
@@ -19,7 +19,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.flow.ISinkController.FlowControllable;
 
@@ -32,7 +32,6 @@
 public abstract class AbstractFlowQueue&lt;E&gt; extends AbstractFlowRelay&lt;E&gt; implements FlowControllable&lt;E&gt;, IFlowQueue&lt;E&gt; {
 
     protected AdvancedDispatchSPI dispatcher;
-    protected DispatchContext dispatchContext;
     protected Collection&lt;IPollableFlowSource.FlowReadyListener&lt;E&gt;&gt; readyListeners;
     private boolean notifyReady = false;
     protected int dispatchPriority = 0;
@@ -44,6 +43,8 @@
     };
     protected boolean started;
     protected Subscription&lt;E&gt; sub;
+    protected DispatchQueue dispatchQueue;
+    protected Runnable dispatchTask;
 
     AbstractFlowQueue() {
         super();
@@ -78,19 +79,17 @@
      * Calls stop and cleans up resources associated with the queue.
      * 
      * @param sync
+     * @throws InterruptedException 
      */
-    public void shutdown(boolean sync) {
-        stop();
-        DispatchContext dc = null;
-        synchronized (this) {
-            dc = dispatchContext;
-            dispatchContext = null;
-
-        }
-
-        if (dc != null) {
-            dc.close(sync);
+    public void shutdown(Runnable onShutdown)  {
+        if( dispatchQueue == null ) {
+            throw new IllegalStateException();
         }
+        
+        stop();
+        dispatchQueue.setFinalizer(onShutdown);
+        dispatchQueue.release();
+        dispatchQueue = null;
     }
 
     /**
@@ -134,21 +133,28 @@
      */
     public synchronized void setDispatcher(AdvancedDispatchSPI dispatcher) {
         this.dispatcher = dispatcher;
-        dispatchContext = dispatcher.register(new Runnable(){
+        
+        dispatchQueue = dispatcher.createQueue(getResourceName());
+        dispatchTask = new Runnable(){
             public void run() {
                 if( pollingDispatch() ) {
-                    dispatchContext.requestDispatch();
+                    dispatchQueue.dispatchAsync(dispatchTask);
                 }
-            }}, getResourceName());
-        dispatchContext.updatePriority(dispatchPriority);
+            }
+        };
+        
+//        TODO:
+//        dispatchContext.updatePriority(dispatchPriority);
+        
         super.setFlowExecutor(dispatcher.createPriorityExecutor(dispatcher.getDispatchPriorities() - 1));
     }
 
     public synchronized void setDispatchPriority(int priority) {
         dispatchPriority = priority;
-        if (dispatchContext != null) {
-            dispatchContext.updatePriority(priority);
-        }
+//        TODO:
+//        if (dispatchContext != null) {
+//            dispatchContext.updatePriority(priority);
+//        }
     }
 
     public synchronized void addFlowReadyListener(IPollableFlowSource.FlowReadyListener&lt;E&gt; watcher) {
@@ -177,8 +183,8 @@
      * Indicates that there are elements ready for dispatch.
      */
     protected void notifyReady() {
-        if (dispatchContext != null) {
-            dispatchContext.requestDispatch();
+        if (dispatchQueue != null) {
+            dispatchQueue.dispatchAsync(dispatchTask);
             return;
         }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/CursoredQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/CursoredQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/CursoredQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/CursoredQueue.java Fri Dec  4 21:35:23 2009
@@ -1651,9 +1651,8 @@
     }
 
     /**
-     * @param sync
      */
-    public void shutdown(boolean sync) {
+    public void shutdown() {
         stop();
         if (!openCursors.isEmpty()) {
             ArrayList&lt;Cursor&lt;V&gt;&gt; cursors = new ArrayList&lt;Cursor&lt;V&gt;&gt;(openCursors.size());

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/ExclusivePersistentQueue.java Fri Dec  4 21:35:23 2009
@@ -259,11 +259,17 @@
         }
     }
 
-    public void shutdown(boolean sync) {
-        super.shutdown(sync);
-        synchronized (this) {
-            queue.shutdown(sync);
-        }
+    public void shutdown(final Runnable onShutdown) {
+        super.shutdown(new Runnable() {
+            public void run() {
+                synchronized (ExclusivePersistentQueue.this) {
+                    queue.shutdown();
+                }
+                if( onShutdown!=null ) {
+                    onShutdown.run();
+                }
+            }
+        });
     }
 
     public FlowController&lt;E&gt; getFlowController(Flow flow) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/IQueue.java Fri Dec  4 21:35:23 2009
@@ -87,12 +87,8 @@
      * the queue is shutdown will thrown an {@link IllegalStateException} unless
      * otherwise documented.
      * 
-     * @param sync
-     *            If true will cause the calling thread to block until all
-     *            resources held by the queue are cleaned up. Otherwise, the
-     *            queue shutdown will proceed asynchronously.
      */
-    public void shutdown(boolean sync);
+    public void shutdown(Runnable onShutdown);
     
     /**
      * Removes the element with the given sequence from this queue

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/PartitionedQueue.java Fri Dec  4 21:35:23 2009
@@ -19,6 +19,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.flow.ISourceController;
@@ -169,7 +170,7 @@
         }
     }
 
-    public void shutdown(boolean sync) {
+    public void shutdown(final Runnable onShutdown) {
         Collection&lt;IQueue&lt;K, V&gt;&gt; partitions = null;
         synchronized (this) {
             if (!shutdown) {
@@ -181,9 +182,22 @@
         }
 
         if (partitions != null) {
+
+            Runnable wrapper=null;
+            if( onShutdown!=null ) {
+                final AtomicInteger  countDown = new AtomicInteger(partitions.size());
+                wrapper = new Runnable() {
+                    public void run() {
+                        if( countDown.decrementAndGet()==0 ) {
+                            onShutdown.run();
+                        }
+                    }
+                };
+            }
+            
             for (IQueue&lt;K, V&gt; partition : partitions) {
                 if (partition != null)
-                    partition.shutdown(sync);
+                    partition.shutdown(wrapper);
             }
         }
     }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedPriorityQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedPriorityQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedPriorityQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedPriorityQueue.java Fri Dec  4 21:35:23 2009
@@ -38,9 +38,9 @@
     }
 
     @Override
-    public void shutdown(boolean sync) {
+    public void shutdown(Runnable onShutdown) {
         try {
-            super.shutdown(sync);
+            super.shutdown(onShutdown);
         } finally {
             partitions.clear();
         }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/main/java/org/apache/activemq/queue/SharedQueue.java Fri Dec  4 21:35:23 2009
@@ -337,11 +337,17 @@
         }
     }
 
-    public void shutdown(boolean sync) {
-        super.shutdown(sync);
-        synchronized (mutex) {
-            queue.shutdown(sync);
-        }
+    public void shutdown(final Runnable onShutdown) {
+        super.shutdown(new Runnable() {
+            public void run() {
+                synchronized (mutex) {
+                    queue.shutdown();
+                }
+                if( onShutdown!=null ) {
+                    onShutdown.run();
+                }
+            }
+        });
     }
 
     public void add(V elem, ISourceController&lt;?&gt; source) {

Modified: activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-queue/src/test/java/org/apache/activemq/queue/perf/RemoteProducer.java Fri Dec  4 21:35:23 2009
@@ -2,7 +2,7 @@
 
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
+import org.apache.activemq.dispatch.DispatchQueue;
 import org.apache.activemq.flow.IFlowController;
 import org.apache.activemq.flow.ISinkController;
 import org.apache.activemq.flow.ISourceController;
@@ -24,12 +24,14 @@
     private String property;
     private MetricAggregator totalProducerRate;
     Message next;
-    private DispatchContext dispatchContext;
 
     private String filler;
     private int payloadSize = 0;
     IFlowController&lt;Message&gt; outboundController;
 
+    private DispatchQueue dispatchQueue;
+    private Runnable dispatchTask;
+
     public void start() throws Exception {
 
         if (payloadSize &gt; 0) {
@@ -45,21 +47,24 @@
 
         super.start();
         outboundController = outputQueue.getFlowController(outboundFlow);
-        dispatchContext = getDispatcher().register(new Runnable() {
+        
+        dispatchQueue = getDispatcher().createQueue(name + "-client");
+        dispatchTask = new Runnable(){
             public void run() {
                 dispatch();
             }
-        }, name + "-client");
-        dispatchContext.requestDispatch();
+        };
+        dispatchQueue.dispatchAsync(dispatchTask);
+        
     }
 
     public void stop() throws Exception {
-        dispatchContext.close(false);
+        dispatchQueue.release();
         super.stop();
     }
 
     public void onFlowUnblocked(ISinkController&lt;Message&gt; controller) {
-        dispatchContext.requestDispatch();
+        dispatchQueue.dispatchAsync(dispatchTask);
     }
 
     public void dispatch() {
@@ -87,7 +92,7 @@
             getSink().add(next, null);
             rate.increment();
             next = null;
-            dispatchContext.requestDispatch();
+            dispatchQueue.dispatchAsync(dispatchTask);
         }
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java?rev=887365&amp;r1=887364&amp;r2=887365&amp;view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-transport/src/main/java/org/apache/activemq/transport/pipe/PipeTransportFactory.java Fri Dec  4 21:35:23 2009
@@ -13,7 +13,8 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.activemq.dispatch.internal.advanced.DispatchContext;
+import org.apache.activemq.dispatch.DispatchQueue;
+import org.apache.activemq.dispatch.internal.RunnableCountDownLatch;
 import org.apache.activemq.dispatch.internal.advanced.AdvancedDispatchSPI;
 import org.apache.activemq.transport.DispatchableTransport;
 import org.apache.activemq.transport.FutureResponse;
@@ -43,20 +44,21 @@
         private String remoteAddress;
         private AtomicBoolean stopping = new AtomicBoolean();
         private Thread thread;
-        private DispatchContext readContext;
         private String name;
         private WireFormat wireFormat;
         private boolean marshal;
         private boolean trace;
+        private DispatchQueue dispatchQueue;
+        private Runnable dispatchTask;
 
         public PipeTransport(Pipe&lt;Object&gt; pipe) {
             this.pipe = pipe;
         }
 
         public void start() throws Exception {
-            if (readContext != null) {
+            if (dispatchQueue != null) {
                 pipe.setMode(Pipe.ASYNC);
-                readContext.requestDispatch();
+                dispatchQueue.dispatchAsync(dispatchTask);
             } else {
                 thread = new Thread(this, getRemoteAddress());
                 thread.start();
@@ -65,8 +67,11 @@
 
         public void stop() throws Exception {
         	pipe.write(EOF_TOKEN);
-            if (readContext != null) {
-                readContext.close(true);
+            if (dispatchQueue != null) {
+                RunnableCountDownLatch done = new RunnableCountDownLatch(1);
+                dispatchQueue.setFinalizer(done);
+                dispatchQueue.release();
+                done.await();
             } else {
                 stopping.set(true);
                 if( thread!=null ) {
@@ -76,16 +81,17 @@
         }
 
         public void setDispatcher(AdvancedDispatchSPI dispatcher) {
-            readContext = dispatcher.register(new Runnable() {
+            dispatchQueue = dispatcher.createQueue(name);
+            dispatchTask = new Runnable(){
                 public void run() {
                     dispatch();
                 }
-            }, name);
+            };
         }
 
         public void onReadReady(Pipe&lt;Object&gt; pipe) {
-            if (readContext != null) {
-                readContext.requestDispatch();
+            if (dispatchQueue != null) {
+                dispatchQueue.dispatchAsync(dispatchTask);
             }
         }
 
@@ -127,7 +133,7 @@
                         } else {
                             listener.onCommand(o);
                         }
-                        readContext.requestDispatch();
+                        dispatchQueue.dispatchAsync(dispatchTask);
                         return;
                     }
                 } catch (IOException e) {
@@ -222,7 +228,8 @@
         }
 
         public void setDispatchPriority(int priority) {
-            readContext.updatePriority(priority);
+//            TODO:
+//            readContext.updatePriority(priority);
         }
 
         public WireFormat getWireformat() {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887354 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/</title>
<author><name>tabish@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/activemq-commits/200912.mbox/%3c20091204205310.D83B82388978@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204205310-D83B82388978@eris-apache-org%3e</id>
<updated>2009-12-04T20:53:10Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: tabish
Date: Fri Dec  4 20:53:10 2009
New Revision: 887354

URL: http://svn.apache.org/viewvc?rev=887354&amp;view=rev
Log:
Update svn:ignore properties

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/   (props changed)

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Dec  4 20:53:10 2009
@@ -6,3 +6,4 @@
 lib
 package
 bin
+vs2008-stomp.pidb




</pre>
</div>
</content>
</entry>
</feed>
