Building your first WebLogic Event Server Application
Pages: 1, 2

My HelloWorld Application

Figure 5 highlights the components that make up the HelloWorld event processing network (application).

HelloWorld Explained

Figure 5. The HelloWorld event processing network

The application includes the following components:

  • HelloWorldAdapter—This component simply generates Hello World messages every second. In a real-world scenario, this component would typically read a stream of data from a source, such as a data feed from a financial institution, and convert it into a stream of events that the complex event processor can understand. The HelloWorld application also includes a HelloWorldAdapterFactory that creates instances of HelloWorldAdapter.
  • HelloWorldInstream—This component streams the events generated by the adapter (in this case Hello World messages) to the complex event processor.
  • HelloWorldProcessor—This component simply forwards the messages from the HelloworldAdapter component to the POJO that contains the business logic. In a real-world scenario, this component would typically execute additional and possibly much more complex processing of the events from the stream, such as selecting a subset of events based on a property value or grouping events (see the code listing above).
  • HelloWorldOutstream—This component streams the events processed by the complex event processor to the POJO that contains the user-defined business logic.
  • HelloWorldBean—This is a POJO component that simply prints out a message every time it receives a batch of messages from the processor via the output stream. In a real-world scenario, this component would contain the business logic of the application, such as running reports on the set of events from the processor, or sending appropriate emails or alerts.

Here's the code for the HelloWorldBean:

public class HelloWorldBean implements EventSink {

  public void onEvent(List newEvents) throws RejectEventException {

      for (Object event: newEvents) {

          HelloWorldEvent helloWorldEvent = (HelloWorldEvent) event;

          System.out.println("Message Robin: " + helloWorldEvent.getMessage());




Listing 2. The HelloWorldBean class

As Listing 2 shows, any event handler simply needs to implement the EventSink interface. The onEvent() method will then be called. Note that it takes a List of an event as an argument. This is because EPL statements can generate more that one associated event object. However, in the case of our HelloWorld example, we will only receive one event in the list.

HelloWorldAdapter, which generates events, is pretty simple. It just calls a method every 300 milliseconds which generates the event:


public class HelloWorldAdapter extends ActiveAdapter {


    /* ... */

    private void generateHelloMessage() {

      List<helloworldevent> eventCollection = new ArrayList<helloworldevent>();

      String message = this.message + dateFormat.format(new Date());

      HelloWorldEvent event = new HelloWorldEvent();



      fireEvent(eventCollection, null);



Listing 3. An excerpt from the HelloWorldAdapter class

As you can see, sending a message is just a matter of subclassing ActiveAdapter, creating an Event instance, populating it, and then calling fireEvent().

The Fun Begins?

Once the software has been successfully installed, you can start by selecting File->New -> Project in Eclipse, and selecting Event Server Application Project (see Figure 6).

Eclipse HelloWorld IDE File New Project Describe

Figure 6. Getting started with a WebLogic Event Server project

The rest of the processing provided by the wizard is now rather intuitive but is described in more detail in the EventServerToolingPreview.Getting.Started.Guide.pdf provided with the BEA software.

Follow the few wizard steps, providing a new application name and the Target WebLogic Event Server runtime, and most importantly selecting the "include the HelloWorld source code" selection box. In a matter of a few seconds, a new project will be dynamically created with all of the artifacts that you will need to deploy (publish) a fully functional solution.

Putting It All Together

Before I leave you to the excitement of exploring this new world of complex event processing networks, let me highlight some of the resulting artifacts when using the Eclipse IDE Event Server Plug-in, and a few recommendations (see Figure 7).

Eclipse HelloWorld IDE Artifacts Description

Figure 7. Rapid application development with the Eclipse IDE

In the "src" section you can find your Java code for your Event Server project. (If you do not see any HelloWorld source, then you forgot to select the option for the "helloworld" templates to be added to this project in the wizard.) To start implementing your own, the is a good place to jump in and perhaps modify the message output associated with the events.

In the META-INF section (under Spring), you can locate the Application Spring Assembly file that wires up all of the various nodes (stages) encompassed in the solution. This is where the powerful code completion IDE capabilities can be used to create additions to your complex event processing network.

Finally, again under the META-INF section (under wlevs), you can find the EPL definition file where you can specify the wealth of statements and related clauses to query the data arriving to this application (via the adapter or adapters).

Final Words

It can be challenging to construct applications (especially as you investigate more of the capabilities of the WebLogic Event Server) because EDA requires navigating around OSGi bundles, Spring Assembly Files, EPNs, and several other components in the mix. However, with this first plug-in, with its evolving set of new IDE features arriving soon, we are providing developers with capabilities to simplify the dynamic creation and deployment (publishing) of our new WebLogic Event Server applications.

With this new Java application server and tooling, BEA is arming architects and developers with the capabilities to ensure that event-driven SOA solutions work effectively and can be delivered within cost and infrastructure parameters. We enable IT to introduce new types of services and SLAs, which can lead to higher revenues. The Java Application Server also helps IT provide better customer satisfaction and retention, which again can boost revenues. EDSOA promotes more agility with proactive operations, and this can make your organization more competitive and reduce operational costs. This unique new runtime and infrastructure can help drive rapid development for a tremendous time-to-market advantage.


  • The new WebLogic Event Server product center contains a number of related articles, blogs, and screencasts
  • The author has his own blog: Robin Smith's blog
  • Arch2Arch has two interviews on the subject of event-driven SOA: Building an Event-Driven SOA and Event-Driven SOA">Event-driven SOA

Robin Smith is the Senior Engineering Product Manager at BEA Systems for the WebLogic Time and Event Driven (TED) Product Family.