Location-based Information Processing with WebLogic Event Server and Web 2.0by Paco Gómez AbstractLocation-based information systems generate continuous streams of data—for example, the current position of each truck in a logistics company fleet. WebLogic Event Server (WLEvS) can efficiently process location data in real time and detect significant patterns like proximity to a certain place or deviation from a predefined route. Position information can be correlated with other type of data thanks to the powerful capabilities of WLEvS to handle high-volume data feeds and capture complex business rules with its Event Processing Language (EPL). This article describes a location-based use case and how it can be implemented with WLEvS and Web 2.0 techniques. The use case is relevant in logistics, transportation and distribution companies, and public sector organizations. Editor's note: See Paco's blog post which shows a video demo of the application, and source code. A Trip to San JoseA truck is traveling from Santa Rosa to San Jose. I want to display its location in a map and get an alert when it is within 15 miles of the destination. The scenario is captured in Figure 1.
This simple use case will help demonstrate how WLEvS can be used to detect useful conditions in location-based information systems, like proximity to a position. A second objective of this example is to illustrate how WLEvS can be integrated with existing infrastructure to build sophisticated applications. The position of the truck is displayed in real time on a map along with the proximity alerts generated by WLEvS. I will review the integration with databases, JMS servers and the Web 2.0 techniques used. To summarize, the solution implemented has two main components:
GPS Data Processing with WLEvSIn a production environment the truck would carry a GPS unit and transmit its location to a centralized server running WLEvS. In this sample implementation, I will be simulating the GPS data feed with the loadgen utility that is part of WLEvS. I send prerecorded location coordinates (latitude and longitude) to WLEvS at predefined time intervals. The Event Processing Network (EPN) implemented in WLEvS is depicted in Figure 2.
The Location events enter the EPN and get processed by two parallel branches:
Let's take a closer look at the EPN. The loadgen utility reads comma-separated values from a file and sends them to WLEvS through a TCP socket. The csvAdapter, which is distributed with WLEvS, uses a TCP server socket to receive the values and send them as events to the stream component attached to it. The stream distributes the event to all the processors linked to it. The processor applies Event Processing Language rules to the incoming events. If the event matches the rule, the processor will send another event to the stream attached to it. I will show the rules defined in the processors later in this article. At the end of each branch there are two POJO components receiving the events and sending data to external servers. The distance checking branch produces proximity alerts that are sent as messages to a JMS topic on an external WebLogic JMS server. The event recording branch uses JDBC to connect to an Oracle database and insert all the GPS events. Event Processing Language RulesEPL rules are executed on the processors of the EPN. The event recording branch processor contains a simple rule to let all the events pass through: select * from GPSInputEvent retain 1 event In the rule, A more complex rule is found in the distance calculator branch processor: select * from ( This rule filters GPS events based on the distance to the target destination. The inner select statement calculates the distance between the position of the current location and the target. The calculation is made using a user-defined function, The reason for using nested select statements is that the distance function is evaluated just one time. This provides better execution times, especially when the function is CPU or I/O intensive. Business Logic ComponentsStandard JDBC and JMS APIs are used in the business components that receive the events filtered through the processors. In the case of JDBC, a data source is defined in the WLEvS domain configuration file ( <data-source> The business logic component can have this data source injected by using the @Service(filter = "(Name=oracle.xe)") For accessing the remote WLS JMS Topic, a JNDI template is defined in the EPN assembly file as follows: <bean id="wlsjndiTemplate" class="org.springframework.jndi.JndiTemplate"> The bean is injected by the Spring framework into the component where it is used to get the connection factory and the JNDI name of the topic. By using these two JNDI objects, the component can send messages to the JMS topic. The Big PictureThe user interface of the application was developed using Web 2.0 techniques. Figure 3 shows how the information and alerts produced by WLEvS are retrieved from JMS and DB servers to be displayed on the user's browser.
The web application is a mashup of Yahoo! Maps JavaScript - Flash API with a custom Beehive application running on WebLogic Server 10. Using Ajax, the browser polls WebLogic for new location information and alerts since the last request. The application queries the database and sends the new data using the JSON format. The JavaScript in the page adds new markers on the map in the background, without any user intervention or page refresh. The final result is that the map displays the current position of the vehicle right after it is processed in real time by WLEvS. Some details of the user interface are provided in the next figures.
ApplicationsWLEvS provides the infrastructure to detect relevant patterns from location-based data in real time as the data gets produced. This capability opens many opportunities for new and exciting applications. Here are some categories and examples:
ConclusionWebLogic Event Server is well suited for detecting relevant patterns in location-based information systems. Since the processing is designed to occur in real time with low latency, it allows you to design monitoring and alerting applications for significant events in categories like proximity, requirements compliance, grouping, and complex correlations. The use case described in the article utilizes WebLogic Event Server to detect the proximity of a vehicle in a certain location, using Web 2.0 techniques to display the information in a dynamic graphical interface. I want to thank Alexandre Alves, David Read, James Taylor, and Mark dos Santos for their help in this use case. References
Paco Gómez is senior principal systems engineer at BEA Systems where he has been helping customers architecting solutions since 1999. Return to Dev2Dev. Showing messages 1 through 1 of 1.
|
Article Tools Related Products Check out the products mentioned in this article:Bookmark Article
|