Oracle CEP and Twitter
By seth.white on Jul 08, 2009
Upon returning from vacation this week, I noticed that an interesting discussion had taken place on The Server Side about the use of Twitter as a source (and sink) of events for CEP engines/platforms. A lot of the discussion focused on the merits (and morality) of using Twitter as a source of news for algorithmic trading applications. The level of interest in querying Twitter data streams using CEP technology made me think that it would be worth mentioning how this can be done using the Oracle CEP product.
As you may know if you are reading this blog, Oracle CEP is an all-Java platform for creating event-driven applications. One of Oracle CEP's major strengths is that it provides a straightforward set of API's for writing the Java components that make up an event processing application. In this case, we are interested in a particular type of component called an "adapter". Adapters are responsible for connecting to external event sources and feeding events to the rest of the application and also for sending events generated by the application to external clients. Twitter is an example of both an external event source and an external client that can receive events, so creating an Oracle CEP application that works with Twitter basically requires writing a "Twitter adapter".
I actually wrote a sample adapter several months ago using the Twitter4j open source library to simplify the adapter implementation. For example, when using Twitter4j the adapter can retrieve data from Twitter using a single line of code:
List<Status> statuses = twitter.getPublicTimeline(lastTweet);
It doesn't get much easier than that! Once the adapter has retrieved the data from Twitter it converts the data to an Oracle CEP event and then sends the event to any of its event listeners in the usual way:
Hopefully, this short example has provided a flavor for the simplicity with which Twitter can be accessed from an Oracle CEP application. I welcome any comments that people have on this topic, especially suggestions for new features that would enhance Oracle CEP's support for Twitter.