Author: asankaa
Date: Wed Dec 10 20:10:58 2008
New Revision: 26674
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=26674

Log:
Publish events using the EventpublishMediator


Modified:
   
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java

Modified: 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java?rev=26674&r1=26673&r2=26674&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
    (original)
+++ 
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
    Wed Dec 10 20:10:58 2008
@@ -19,12 +19,40 @@
 */
 import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.synapse.MessageContext;
+import org.apache.synapse.util.MessageHelper;
+import org.apache.synapse.eventing.SynapseEventSource;
+import org.apache.synapse.eventing.SynapseSubscriptionManager;
+import org.apache.synapse.eventing.SynapseSubscription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.AxisFault;
+
+import java.util.List;
 
 public class EventPublisherMediator extends AbstractMediator {
+    private static final Log log = 
LogFactory.getLog(EventPublisherMediator.class);
     private String eventSourceName=null;
-    public boolean mediate(MessageContext synCtx) {
-        System.out.println("Eventing mediator on action");
-        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    public boolean mediate(MessageContext synCtx){
+        if (log.isDebugEnabled()) {
+             log.debug("Mediation for Event Publisher started");
+         }
+        SynapseEventSource eventSource = 
synCtx.getConfiguration().getEventSource(eventSourceName);
+        SynapseSubscriptionManager subscriptionManager = 
eventSource.getSubscriptionManager();
+            List<SynapseSubscription> subscribers = 
subscriptionManager.getMatchingSubscribers(synCtx);
+            for (SynapseSubscription subscription : subscribers) {
+                //TODO: send a 202 responce to the client, client wait and 
time outs
+                synCtx.setProperty("OUT_ONLY", "true");    // Set one way 
message for events
+                try {
+                    
subscription.getEndpoint().send(MessageHelper.cloneMessageContext(synCtx));
+                } catch (AxisFault axisFault) {
+                    log.error("Event sending failure "+axisFault.toString());
+                    return false;
+                }
+                if (log.isDebugEnabled()) {
+                    log.debug("Event push to  : " + 
subscription.getEndpointUrl());
+                }
+            }
+        return true;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     public String getEventSourceName() {

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to