What is ?

This is a framework written to handle complex asynchronous business logics.

Its not indended to use with GUIs, but may be someone can find it interesting.

It is event-based, multi-threaded, and use a publish/subscribe logic, to handle business events.

An event can be persistent (actually uses Oracle AQ) or volatile. If persistent, once it is published, it is enforced that

all subscibers must execute correctly, even if a system failure occurs. If volatile there is no


A subscriber can be stateless or statefull. A stateless subscriber instance, will handle only one

event. A statefull subscriber instance will handle all events.

A subscriber can be also Synchronous, Asynchornous, or OrderedAsynchornous. This means that

when an event is dispatched to its subscribers, those are diveded into Synchronous+OrderedAsynchornous,

and Asynchronous. For each Asynchronous subscriber the framework starts a thread.

All the Synchronous subscribers will run in the same thread, at some point in this execution,

if the framework find an OrderedAsynchornous it will start a thread for it, and will continue with

the other Synchronous subscribrers. Those "threads" are called Notifiers: notifiers

are divided in Synchronous and Asynchronous. One Synchronous Notifier will run all Synchronous subscribers

of an event, and eventually will start "n" Asynchronous Notifiers for "n" OrderedAsynchornous subscribers.

"m" Asynchronous Notifiers, will run "m" Asynchornous subscribers. Notifiers are started by the

EventDispatcher. Subscribers are started by subscription order.

A subscriber can subscribe an event by the event class or by an anchestor class.

So if EventA extends EventB, SubscriberN can subscribe EventA by subscribing EventB.

The framework is transactional. This means that each persistent event is linked to a javax.transaction.Transaction,

and each Subscriber will use a branch of this transaction (1 branch x Notifier, so that Synchronous Subscribers will use the same);

to commit the event dequeue each branch must be correctly commited.

The use of XA transactions permits the use of multiple database connections to run subscribers in parallel.

Actually the implementation of persistent events is made by Xstream+Oracle AQ text message.

Probably i miss something but i will write a detailed doc.

Why ?

Enables developers to code event driven systems.

Enables developers to plug new business logic smoothly, even at runtime.

Enables architects/developers to tune business logic execution.

Enables developers to retry failed transactions once the wrong code is fixed without

user interaction.

Enables easy software integration: publish/subscribe of XML events may be eventually

the backend of a WebService.

Have you ever looked at the first implementation of a complex business logic method ?

Probably you noted that was too long and difficult to read and understand by someone else.

If you are a good programmer, and if you are a good analyst may be you have teared down

this method to n classes and sub-methods. But the business logic is still there all sequential.

Yes there are BPEL engines, and workflow tools, but those are generally made to design

business processes. eforcebes is a lower level api, to easly schedule “business logic” at runtime

and have it to run faster... or slower; probably it can be used to build a BPEL engine,

but the firts objective is to enable the developer to parallelize and decide priorities of

business logic execution, in a robust, event driven, transaction envirorment.


User feedback will drive development, submit your requests:



Source/Doc or Binary package (initial release):


or CVS (updated frequently):


Use it

This is an example to show how it looks:

package eforce.bes.samples;

import org.apache.log4j.Logger;

import eforce.bes.BusinessEventSystem;
import eforce.bes.Event;
import eforce.bes.EventNotifierContext;
import eforce.bes.PersistentEvent;
import eforce.bes.StatefullEventSubscriber;
import eforce.bes.StatelessEventSubscriber;
import eforce.bes.impl.SingleDispatcherHandler;
import eforce.bes.impl.UnsafeSubscriberHandler;

 * This class shows basic functions.
public class SimpleEventSystem extends BusinessEventSystem
	public static void main(String[] args)
	throws Exception
	        BusinessEventSystem bes= new SimpleEventSystem();
                   bes.setDispatcherHandler(new SingleDispatcherHandler());
                   bes.setEventQueueHandler(new UselessEventQueueHandler());
        bes.setSubscriberHandler(new UnsafeSubscriberHandler());
        bes.subscribeToEvent(new SubscriberB(),EventA.class); // (subscribe all events because EventA is anchestor of all events)
        Event a= new EventA();
        Event b= new EventB();

        bes.waitForEvent(a); // sleeps until EventA is complete (STOPPED) 
        EventC c= new EventC();
        c.setTransaction(new FakeTransaction());
        bes.publishEvent(c); // fake queue and dequeue 
        bes.waitForEvent(c); // once dequeued a persistent event can be waited for..

	static class EventA extends Event

	static class EventB extends EventA

	static class EventC extends EventA implements PersistentEvent
                String fname= "andrea";
                String lname= "gariboldi";
	static class SubscriberA implements StatelessEventSubscriber
	    private static final Logger logger= Logger.getLogger(SubscriberA.class);

	    public void notifyEvent(Event e, EventNotifierContext ctx)
	    throws Exception
	    	logger.debug("notified event: "+e);

	static class SubscriberB implements StatefullEventSubscriber
	    private static final Logger logger= Logger.getLogger(SubscriberB.class);
		private int counter= 0;
		public void notifyEvent(Event e, EventNotifierContext ctx)
	    throws Exception
	    	logger.debug("notified event: "+e);
			logger.debug((++counter)+" events notified");

To see all features look at samples in the source package.


to do

If you get any other problem please subimt a support request:



eforcebes is developed by Andrea A.A. Gariboldi