Skip to content

Instantly share code, notes, and snippets.

@johndemic
johndemic / mule-config.xml
Created February 6, 2012 22:04
Mule Esper Example: Rate Limiting a Flow
<flow name="Event Rate Limit Flow">
<vm:inbound-endpoint path="filtered.in"/>
<esper:filter eventPayload-ref="#[payload:]"
statement="select case when count(*) > 1000 then false else true end from TestEvent.win:time(5 min)"
key="case when count(*)>1000 then false else true end"/>
<vm:outbound-endpoint path="filtered.out"/>
</flow>
@johndemic
johndemic / broker.drl
Created February 6, 2012 21:52
Mule Drools CEP Example
package org.drools.examples.broker
import org.mule.MessageExchangePattern;
import org.mule.example.cep.Company
import org.mule.example.cep.StockTick
global org.mule.module.bpm.MessageService mule;
# default dialect for the semantic code will be MVEL
dialect "mvel"
@johndemic
johndemic / mule-config.xml
Created February 6, 2012 21:11
Mule Esper Example: Comparing to Drools
<flow name="processStockTicks">
<composite-source>
<inbound-endpoint ref="stockTick"/>
<ajax:inbound-endpoint channel="/services/cepExample/thresholdChange"/>
</composite-source>
<all>
<ajax:outbound-endpoint channel="/services/cepExample/stockTick"/>
<esper:send eventPayload-ref="#[payload:]"/>
</all>
</flow>
@johndemic
johndemic / mule-config.xml
Created February 6, 2012 21:09
Mule Esper Example: Mule Configuration
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
xmlns:esper="http://www.mulesoft.org/schema/mule/esper"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
@johndemic
johndemic / esper-config.xml
Created February 6, 2012 21:04
Mule Esper Example: Esper Configuration
<esper-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.espertech.com/schema/esper"
xsi:schemaLocation="
http://www.espertech.com/schema/esper
http://www.espertech.com/schema/esper/esper-configuration-2.0.xsd">
<event-type name="Tweets" class="twitter4j.StatusJSONImpl"/>
</esper-configuration>
@johndemic
johndemic / gist:1732188
Created February 3, 2012 20:15
Mule Configuration for HornetQ
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
@johndemic
johndemic / LatchFunctionalTestCase.java
Created January 30, 2012 14:51
Using a CountdownLatch to Test Flows
import org.mule.api.client.MuleClient;
import org.mule.api.context.notification.EndpointMessageNotificationListener;
import org.mule.api.context.notification.ServerNotification;
import org.mule.context.notification.EndpointMessageNotification;
import org.mule.tck.FunctionalTestCase;
import org.mule.util.FileUtils;
import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@johndemic
johndemic / mule-config.xml
Created January 10, 2012 14:28
Mule configuration that generates an event-stream from the Twitter timeline and performs analysis of the hashtags
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:esper="http://www.mulesoft.org/schema/mule/esper"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
<flow name="testFlow">
<vm:inbound-endpoint path="in"/>
<esper:send eventPayload-ref="#[payload:]"/>
<vm:outbound-endpoint path="out"/>
</flow>
<flow name="Event Listener Flow">
<esper:listen statement="select count(*) from TestEvent
.win:time_batch(5, 'FORCE_UPDATE, START_EAGER') having count(*) &gt; 0"/>
<esper:get-event-property key="count(*)"/>
<flow name="testFlow">
<vm:inbound-endpoint path="in"/>
<esper:send eventPayload-ref="#[payload:]"/>
<vm:outbound-endpoint path="out"/>
</flow>
<flow name="Event Listener Flow">
<esper:listen statement="select count(*) from TestEvent
.win:time_batch(5, 'FORCE_UPDATE, START_EAGER') having count(*) &gt; 0"/>
<esper:get-event-property key="count(*)"/>