diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-09 11:08:13 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-09 11:08:13 +0100 |
commit | 0f344aacc6e311aa581615ad8c1a7b01e41625da (patch) | |
tree | 38b86a91d0d1dc6c42374826ee4220883dbd2266 /src/main/java/io/trygvis/esper/testing/Main.java | |
parent | 906019004f1cd50cdfe4f72c7aff234ea3577b8e (diff) | |
download | esper-testing-0f344aacc6e311aa581615ad8c1a7b01e41625da.tar.gz esper-testing-0f344aacc6e311aa581615ad8c1a7b01e41625da.tar.bz2 esper-testing-0f344aacc6e311aa581615ad8c1a7b01e41625da.tar.xz esper-testing-0f344aacc6e311aa581615ad8c1a7b01e41625da.zip |
o Some more Esper experiments.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/Main.java')
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/Main.java | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Main.java b/src/main/java/io/trygvis/esper/testing/Main.java deleted file mode 100755 index 323e44f..0000000 --- a/src/main/java/io/trygvis/esper/testing/Main.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.trygvis.esper.testing; - -import com.espertech.esper.client.*; - -public class Main { -// private static final String JDBC_URL = "jdbc:h2:mem:esper;DB_CLOSE_DELAY=-1"; - private static final String JDBC_URL = "jdbc:h2:tcp://127.0.0.1/esper;DB_CLOSE_DELAY=-1"; - - public static void main(String[] args) throws Exception { - Config.loadFromDisk(); - Main main = new Main(); - main.work(); - } - - private void work() throws Exception { - Configuration config = new Configuration(); - - ConfigurationDBRef configurationDBRef = new ConfigurationDBRef(); - configurationDBRef.setDriverManagerConnection("org.h2.Driver", JDBC_URL, "", ""); - configurationDBRef.setConnectionAutoCommit(false); - config.addDatabaseReference("db1", configurationDBRef); - config.addEventTypeAutoName(getClass().getPackage().getName()); - EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config); - -// String expression = "select avg(price) from OrderEvent.win:time(30 sec)"; - - String expression = "select price, SUBSCRIBER from OrderEvent.win:time(30 sec)," + - "sql:db1 ['select subscriber from subscription where itemName=${itemName}']"; - - EPStatement statement = epService.getEPAdministrator().createEPL(expression); - - MyListener listener = new MyListener(); - statement.addListener(listener); - - System.out.println("Inserting events"); - epService.getEPRuntime().sendEvent(new OrderEvent("shirt", 72)); - epService.getEPRuntime().sendEvent(new OrderEvent("shirt", 73)); - epService.getEPRuntime().sendEvent(new OrderEvent("shirt", 74)); - - System.out.println("Sleeping"); - Thread.sleep(1000); - System.out.println("Done.."); - } -} - -class OrderEvent { - private String itemName; - private double price; - - public OrderEvent(String itemName, double price) { - this.itemName = itemName; - this.price = price; - } - - public String getItemName() { - return itemName; - } - - public double getPrice() { - return price; - } -} - -class MyListener implements UpdateListener { - public void update(EventBean[] newEvents, EventBean[] oldEvents) { - for (EventBean event : newEvents) { - System.out.println("event.getEventType() = " + event.getEventType()); - System.out.println("event.getUnderlying() = " + event.getUnderlying()); - System.out.println("avg=" + event.get("price")); - } - } -} |