In a recent article, I described how StreamExplorer can be configured to consume events by exposing a REST service to which clients can send HTTP POST requests with JSON payloads. StreamExplorer also can make use of an Outbound REST Adapter through which results of explorations can be sent.
This target service can be implemented in a number of ways – that does not concern StreamExplorer. In this case we will use an implementation in a Java Servlet (JAX-RS). Alternatives are a SOA Suite service or even a Stream Explorer application with a REST based input stream. The REST service that is invoked in this example is published from a Java SE application – as described in this article. When you run the class CinemaEventHandlerRestStartup, a REST service is published at http://localhost:9998/movieevent, supporting both GET and a POST operations.
REST services can be a target for StreamExplorer – so we should be able to quickly configure this service as a target. It will not do much with any messages it receives – it will just show in the console output that it did receive them.
The StreamExplorer application that will publish results to the REST target is introduced in this article. The example looks at a movie theater. More specifically, it monitors the visitors entering and leaving the various rooms in the theater so we keep track of the number of people currently present in each room. When rooms are almost full, we may have to stop selling tickets or perhaps open up an additional room showing the same movie. When a room is [almost]empty, perhaps we should cancel the show altogether. When people keep coming and going, there may be a problem we should attend to. In this case, the events are received by Stream Explorer in the form of JSON messages posted to a REST service.
The data shape for events in the stream is defined like this:
From the Catalog, create a new Exploration based on the stream CinemaComingAndGoing.
Run either the SoapUI test case or the PL/SQL script to have some cinema events published. Verify that these events lead to results in the new exploration.
Next, click on Configure a Target. Select REST as the target type
and set the resource URL to http://localhost:9998/movieevent .
Click on Finish. Next, publish the Exploration.
Publish some cinema events to the REST service exposed by the StreamExplorer exploration, as described in this article. The events are processed and forwarded to the REST service (exposed in this case by a Java Class running in a plain Java SE container).