0

As the headers says, we have problems building a project with Esper in combination with RabbitMQ. Therefore we need to use the amqp adapters of Esperio (version 4.10).

We’ve started from the basics in the manual, but for some reason our queries aren’t being evaluated like they should. We’ve already found out that “EventBusSink” and EventBusSource” needed to be switched in the declaration of the amqp adapters (building errors like “no outputstream defined”)

We’re set up 2 queues in Rabbitmq using Spring AMQP like this:

   <rabbit:connection-factory id="connectionFactory" />

   <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />

   <rabbit:admin connection-factory="connectionFactory" />

   <rabbit:queue name="myQueue" durable="false">
         <rabbit:queue-arguments value-type="java.lang.Long">
                <entry key="x-message-ttl" value="50000" />
         </rabbit:queue-arguments>
   </rabbit:queue>

   <rabbit:queue name="myOutputQueue" durable="false">
         <rabbit:queue-arguments value-type="java.lang.Long">
                <entry key="x-message-ttl" value="50000" />
         </rabbit:queue-arguments>
   </rabbit:queue>

   <rabbit:listener-container
         connection-factory="connectionFactory">
         <rabbit:listener ref="foo" method="listen"
                queue-names="myOutputQueue" />
   </rabbit:listener-container>

   <bean id="foo" class=" messagebroker.Foo" />

And configured Esper and the amqp adapters like this:

         Configuration config = new Configuration();
         config.addEventType("InputEvent", Event.class);
         config.addEventType("OutputEvent", OutputEvent.class);
         config.getEngineDefaults().getLogging().setEnableTimerDebug(false);
         config.getEngineDefaults().getLogging().setEnableExecutionDebug(true);
         config.getEngineDefaults().getLogging().setEnableQueryPlan(true);
         epService = EPServiceProviderManager.getDefaultProvider(config);
         EPRuntime cepRT = epService.getEPRuntime();
         EPAdministrator cepAdm = epService.getEPAdministrator();
         cepAdm.getConfiguration().addImport(AMQPSource.class.getPackage().getName() + ".*");

         String epl = "Create Dataflow AMQPIncomingDataFlow \n"
                       // + "Create schema test as (id string), \n"
                       + "AMQPSource -> instream<InputEvent> \n"
                       + "{host: 'localhost'," + "port: 5672," + "username:'guest',"
                       + "password:'guest'," + "queueName: 'myQueue',"
                       + "declareDurable: false," + "declareExclusive: false,"
                       + "declareAutoDelete: false," + "prefetchCount : 100,"
                       + "waitMSecNextMsg: 0," + "consumeAutoAck: true,"
                       + "collector: {class: 'AMQPToObjectCollectorSerializable'},"
                       + "logMessages: true } \n" + "EventBusSink(instream){}";

         cepAdm.createEPL(epl);
         EPDataFlowInstance instance = cepRT.getDataFlowRuntime().instantiate(
                       "AMQPIncomingDataFlow");
         instance.start();

         cepAdm.getConfiguration().addImport(
                       AMQPSink.class.getPackage().getName() + ".*");
         String epl2 = "Create Dataflow AMQPOutgoingDataFlow \n"
                       + "EventBusSource -> outstream<OutputEvent>{} \n"
                       + "AMQPSink(outstream)"
                       + "{host: 'localhost',"
                       + "port: 5672,"
                       + "username:'guest',"
                       + "password:'guest',"
                       + "queueName: 'myOutputQueue',"
                       + "declareDurable: false,"
                       + "declareExclusive: false,"
                       + "declareAutoDelete: false,"
                       + "waitMSecNextMsg: 0,"
                       + "collector: {class: 'ObjectToAMQPCollectorSerializable'}, logMessages: true }";

         cepAdm.createEPL(epl2);
         EPDataFlowInstance instance2 = cepRT.getDataFlowRuntime().instantiate(
                       "AMQPOutgoingDataFlow");
         instance2.start();

When we set the configuration and the publishing of several statements in one method (constructor or init method), everything works fine. But when we first start esper with our custom configuration (with the adapters) and publish the statements in a later phase (and send events to match those statements afterwards), nothing was matched with our statements. Nevertheless we use the same esperProvider (epService in our code). When we duplicate the configuration part in the method where we publish our statements, we get an exception that says that the adapters already exist.

An example of a query is:

           EPStatement statement = epService.getEPAdministrator().createEPL("insert into OutputEvent select e.id as id, e.id as id, e.sourceRef as sourceRef, 'Start' as eventType from pattern[every e = InputEvent((sourceRef = '28853a2b6a88477197d88ee9f89d2ab7' or sourceRef =      '39b648697f654b2891e79077d3a18fe6' or sourceRef = 'ea0db5e30d244d4fa6e922bf21c89e6f') and standardEvent = 'create')]");

And the events sent:

 epService.getEPRuntime().sendEvent(new InputEvent (50, 51, "28853a2b6a88477197d88ee9f89d2ab7", "item", 50, false, null,  "create"));
 epService.getEPRuntime().sendEvent(new InputEvent (50, 52, "f77537e468c84adfa117d6aab48f929c", " item ", 50, false, null,  "create"));
 epService.getEPRuntime().sendEvent(new InputEvent (50, 53, "1ea4c8af03354a1da134e33783b22b24", " item ",50, false, null,  "create"));
 epService.getEPRuntime().sendEvent(new InputEvent (50, 50, "ab1ead380b6b48bdb3872de4277195a0", " item ",-1, false, null,  "create"));

ARe there any restrictions in Esper to publish statements at runtime?

Thanx!

Jana

user1919031
  • 85
  • 1
  • 7

2 Answers2

0

There are no restrictions publishing EPL at runtime. Are you running in a J2EE server?

user650839
  • 2,594
  • 1
  • 13
  • 9
0

We're running on a tomcat server, but after a bit of try and error, we solved the problem without knowing what exactly went wrong. Either way, there are indeed no restrictions..

user1919031
  • 85
  • 1
  • 7