Figure 2 illustrates this communication when a
bundle sends an event to the MoM. At first, this
event is sent to the EAS. The EAS fulfils its normal
duty by delivering the event to all (registered) event
handler services. One of those services is registered
by the EDS, which thereby receives the event. The
EDS creates a message from the contents of the
event and forwards it to the MoM. Thus, the event
sending bundle communicates with the EAS only; it
has no direct knowledge of the EDS and the MoM.
Figure 2: Asynchronous event delivery. The event sending
bundle has no possibility to determine if the event was
received by the EDS and delivered to the MoM as a
message.
Figure 3 illustrates the communication between
the MoM, the EDS and the EAS when a bundle
receives a message from the MoM. At first, this
message is sent to the EDS. The EDS creates an
event from the contents of the message and forwards
it to the EAS. The EAS delivers the event to all
(registered) event handler services that are listening
for this event. One of those services is registered by
the bundle, which wants to receive the event. Thus,
the event receiving bundle also communicates with
the EAS only; it has no direct knowledge of the EDS
and the MoM.
Figure 3: Asynchronous event reception. The EDS has no
information if the delivery of the event to the destination
was successful. But it needs to acknowledge the successful
reception and processing of the message.
3.2 Guaranteed Delivery
The EDS mediates between the MoM and the EAS.
It receives messages from the MoM and forwards
them as events to the EAS for further delivery to the
(registered) event handler services (see Figure 3). As
soon as, the EDS forwards an event to the EAS, it
cannot know if the event reaches its destination and
if the event is processed successfully. We solved this
problem by connecting the EDS to the event handler
services so that the EDS can forward the event to
them directly (see Figure 1). This way the EDS can
inform the MoM about a successful or failed
delivery.
The EAS completely decouples the event
sending bundle from the EDS and the MoM (see
Figure 2). It only guarantees the delivery of an event
to all (registered) event handler services that are
available at the very moment of this delivery. Since
the event sending bundle cannot know which of the
event handler services are available, it has no
information if the event was successfully delivered
to the EDS. We solved this problem by connecting
the event sending bundle to the EDS (see Figure 1).
Now the event sending bundle knows that the
event was successfully delivered to the EDS as it
sends the event to the EDS directly. However, the
EDS still has no way to inform the event sending
bundle about a failed delivery of the event. This is
because the EAS API does not allow the EDS to
throw an exception from the call of a
postEvent
method.
public interface EventAdmin{
void postEvent(Event event);
...
}
As a result, the event sending bundle has to send the
event blindly without any chance to get information
on the success or failure of the delivery. We solved
this problem by extending the EAS API. In
particular, we defined a new method
postEventReliable, which waits (blocks) until
the event is successfully delivered. In the case of a
failure, it throws an exception. Thereby the event
sending bundle is informed about the failure and can
react appropriately.
public interface ExtendedEventAdmin{
void postEventReliable(Event e) \
throws MessagingException;
...
}
But herein lies another problem. Our previous
solution breaks the compatibility with legacy
bundles. We solved this problem as follows. The
right side of Figure 1 shows that bundles will use the
extended EAS API to guarantee the delivery. The
left side of Figure 1 shows that legacy bundles will
not be aware of the extended EAS API. Rather, they
INTEGRATING ASYNCHRONOUS COMMUNICATION INTO THE OSGI SERVICE PLATFORM
167