Author: asanka
Date: Fri Apr 10 09:20:36 2009
New Revision: 763891

URL: http://svn.apache.org/viewvc?rev=763891&view=rev
Log:
Move the subscription manager read to the dispatching-init thread.

Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java?rev=763891&r1=763890&r2=763891&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java
 Fri Apr 10 09:20:36 2009
@@ -170,17 +170,12 @@
      * @param msgCtx message context
      */
     public void dispatchEvents(org.apache.synapse.MessageContext msgCtx) {
-        Event<org.apache.synapse.MessageContext> event = new Event(msgCtx);
+
         List<Subscription> subscribers = null;
-        try {
-            subscribers = subscriptionManager.getMatchingSubscriptions(event);
-        } catch (EventException e) {
-            handleException("Matching subscriptions fetching error", e);
-        }
 
         // Call event dispatcher
         msgCtx.getEnvironment().getExecutorService()
-                .execute(new EventDispatcher(msgCtx, subscribers));
+                .execute(new EventDispatcher(msgCtx));
     }
 
     /**
@@ -188,16 +183,21 @@
      */
     class EventDispatcher implements Runnable {
         private org.apache.synapse.MessageContext synCtx;
-        private List<Subscription> subscribers;
+        private List<Subscription> subscriptions;
 
-        EventDispatcher(org.apache.synapse.MessageContext synCtx,
-                        List<Subscription> subscribers) {
+        EventDispatcher(org.apache.synapse.MessageContext synCtx) {
             this.synCtx = synCtx;
-            this.subscribers = subscribers;
         }
 
         public void run() {
-            for (Subscription subscription : subscribers) {
+            try {
+                Event<org.apache.synapse.MessageContext> event = new 
Event(synCtx);
+                subscriptions = 
subscriptionManager.getMatchingSubscriptions(event);
+            } catch (EventException e) {
+                handleException("Matching subscriptions fetching error", e);
+            }
+
+            for (Subscription subscription : subscriptions) {
                 synCtx.setProperty(SynapseConstants.OUT_ONLY,
                         "true");    // Set one way message for events
                 try {
@@ -434,7 +434,7 @@
         unsubscribeOperation.setMessageReceiver(this);
         renewOperation.setMessageReceiver(this);
         getStatusOperation.setMessageReceiver(this);
-        subscriptionEndOperation.setMessageReceiver(this);
+        subscriptionEndOperation.setMessageReceiver(this);        
         // Set Soap Action
         subscribeOperation.setSoapAction(EventingConstants.WSE_SUBSCRIBE);
         unsubscribeOperation.setSoapAction(EventingConstants.WSE_UNSUBSCRIBE);
@@ -447,6 +447,7 @@
         eventSourceService.addOperation(renewOperation);
         eventSourceService.addOperation(getStatusOperation);
         eventSourceService.addOperation(subscriptionEndOperation);
+        
     }
 
     private void handleException(String message, Exception e) {


Reply via email to