Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Oracle SOA Suite 11g R1 Developer's Guide

You're reading from   Oracle SOA Suite 11g R1 Developer's Guide Service-Oriented Architecture (SOA) is made easily accessible thanks to this comprehensive guide. With a logically structured approach, it gives you the expertise to start using the Oracle SOA suite in real-world applications.

Arrow left icon
Product type Paperback
Published in Jul 2010
Publisher Packt
ISBN-13 9781849680189
Length 720 pages
Edition 1st Edition
Arrow right icon
Toc

Chapter 8. Using Business Events

In the previous chapters, we focused on routing messages to the correct destination and managing process flow. All of this requires knowledge of the dependencies, and for most business processes and service integrations, this is required to ensure that everything works reliably. However, even with transformation and service abstraction, there are still dependencies between services. In this chapter, we will look at the tools available in SOA Suite for completely decoupling providers of messages from consumers of messages. This is useful if we wish to add new attributes that do not require responses to be returned, for example, adding fraud detection services or usage auditing services. In these cases, we just want message producers to publish events, and allow new services to receive these events by subscribing to them without impacting the publisher. This is the function of the Event Delivery Network (EDN) in the SOA Suite and is the focus of this chapter.

How EDN differs from traditional messaging

Message Oriented Middleware (MOM) uses queuing technologies to isolate producers from consumers. The classic MOM product was IBM MQ Series , but other products in this space include Tibco Rendezvous and Oracle AQ . Messages may be delivered point to point (a single service consumes the message) or one-to-many (multiple services may consume the same message). The Java Messaging Service (JMS) provides an abstraction over messaging systems and supports both one-to-one interactions through queues and one-to-many interactions through topics. When using JMS to subscribe to an event, a developer must know the format of data associated with the event and the message channel (topic or queue) on which to listen to receive the event. This message channel must be configured for each event and filters might be added to restrict the messages delivered. The Event Delivery Network (EDN) takes the view that the publishers and subscribers of a message, known as an event, only need to know the subject matter, the event name, and the event data format. All the delivery details can be hidden under the covers. EDN uses JMS to deliver events from subscribers to publishers, but the configuration of JMS queues and topics and any associated filters is hidden from users of the EDN service.

The following table highlights the differences between traditional MOM and EDN. As can be seen, the focus of EDN is to make it very easy for event producers to publish an event that can then be received by an arbitrary number of event subscribers. EDN developers only need to be aware of the events themselves, as all the underlying delivery mechanisms are taken care of within the EDN.

Interaction Pattern

Messaging Support

Configuration

EDN Notes

Request/Reply

Separate JMS queues are used for Request and Response messages. JMS Message Headers are used to correlate requests with responses.

Request and response queues must be configured with appropriate connection factories and message store.

EDN does not support request/reply. It is not possible to target the receiver of an event. Event subscribers are not visible to event producers and so cannot be directly targeted. Similarly, event producers are not visible to event subscribers and so it is not possible to send direct replies just to the originator of the event.

One way guaranteed delivery

Single JMS queue with a single subscriber

Queue must be configured with appropriate connection factory and message store

EDN does not support guaranteed one way delivery of events. An event producer has no way of knowing how many subscribers will receive the message or if any subscribers will receive the message.

One-to-many message delivery

Single JMS topic with zero or more subscribers

Topic must be configured with appropriate connection factory and message store.

EDN supports exactly this message interaction pattern without the need to configure any JMS artifacts. EDN uses JMS but this is hidden from the developer.

A sample use case

Consider an auction process. The basic auction process accepts new items for auction from a seller service, accepts bids from a bidder service, and identifies the winning bid in an auction service. All these operations require co-ordination between the services involved.

There may be concerns about the proprietary of some bids, but the time taken to validate the bid and ensure that it is legitimate may be viewed as too lengthy and instead it may be desired to have a background process to validate bids, so we do not slow down the normal bid taking process.

This is an extension to the business functionality that does not require a conversation between the bid process and the validation service. In fact, a conversation may slow down the auction process and increase the time taken to accept and confirm bids and winners. This is an excellent use case for the EDN because of the following features:

  • No conversation is required between the event consumer (bid legitimacy process) and the event producer (auction process).
  • The event consumer can be added to the system without any changes to the event producer. As long as the auction process is publishing bid events, adding the bid validator will not impact the auction process.
  • Additional producers may be added to the system without impacting existing producers and/or consumers. For example, different auction systems may raise the same event.
  • Additional consumers may also be added independently of either existing producers and/or consumers. For example, an automated bidding service may make use of this event later without impacting the existing services.

Event Delivery Network essentials

The EDN is a very simple but very powerful concept, and we will now explain the basic principles associated with it.

Events

An event is the message that will be published and consumed on the Event Delivery Network. Events consist of three parts:

  1. A namespace that identifies the general area that the event is associated with and helps to avoid clashes between event names
  2. A name that identifies the type of event within a namespace
  3. A data type that defines the data associated with the event

Namespaces of events behave in the same way as namespaces in XML and identify the solution area of the events and avoid clashes between events with the same name that belong to different solution areas. For example, a namespace would differentiate an event called NewOrder in a military command and control system from an event called NewOrder in a logistics system.

Events are defined using an XML-based language called the Event Description Language (EDL).

We can model business events from within JDeveloper by clicking on the event icon Events on the top-left-hand corner of the composite editor as shown in the following screenshot.

Events

This brings up the Create Event Definition File dialog to allow us to create a new EDL file to contain our event definitions.

Events

After defining the EDL File Name, the Directory it resides in, and the Namespace of the EDL file, we can add events to it by clicking on the green plus symbol Events. This takes us to the Add an Event dialog, where we can choose the XML Element that represents the data content of the event and give the event a Name.

Event elements and data types should always be defined in an XML schema file, which is separate from other SOA XML artifacts such as message schemas. This is because the events may be used across many areas, and they should not have dependencies on other SOA artifacts.

Events

After completing the definition of our EDL file, it is displayed in JDeveloper, where we can continue to add or remove events.

Events

The EDL file itself is a very simple format, shown as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns=http://schemas.oracle.com/events/edltargetNamespace="AuctionEventDefinitions">
    <schema-import namespace="auction.events"location="xsd/AuctionEvents.xsd"/>
        <event-definition name="NewAuctionEvent">
        <content xmlns:ns0=" auction.events"element="ns0:NewAuction"/>
        </event-definition>
        <event-definition name="NewBidEvent">
          <content xmlns:ns0=" auction.events" element="ns0:NewBid"/>
        </event-definition>
</definitions>

The targetNamespace attribute of the <definitions> element defines the namespace for the events. XML-type definitions are imported using <schema-import>, and <event-definition> is used to define events and their associated element.

Event publishers

Events are created by event publishers. An event publisher may be a Mediator or BPEL component in an SCA Assembly or it may be a custom Java application. The event publisher raises the event by creating an XML element and passing it to the Event Delivery Network. Once passed to the EDN, the publisher is unaware of how many subscribers consume the event or even if the event is consumed by any subscriber. This provides a degree of isolation between the publisher and subscribers. The EDN is responsible for keeping track of who is subscribing and ensuring that they receive the new event.

Publishing an event using the Mediator component

When using a Mediator to publish an event, we usually want to publish the event in parallel with other processing that the Mediator is doing. Typically, we want the Mediator to take the request from some service call and publish the event.

In the following example, we have a Mediator NewAuctionMediator that routes to a dummy service implemented by a Mediator ServiceMediator that uses Echo functionality to provide a synchronous response to its caller. We will raise a NewAuction event as part of the inbound processing in the Mediator. Note that although the Mediator will route a reply to the specific caller of the composite, the event will be routed to all subscribers of that event type.

Publishing an event using the Mediator component

We can raise an event based on the input request in the following fashion.

We open the routing Mediator component, in this case, NewAuctionMediator, and add a new sequential static routing rule. When the Target Type dialog comes up, select the Event button to generate an event.

Publishing an event using the Mediator component

In the Event Chooser dialog, we can choose the Event Definition File that contains our event. We can either browse for an existing EDL file using the magnifying glass icon or we can create a new EDL file by using the thunderbolt icon. Once an EDL file has been chosen, we can then select the specific event that we wish to produce.

Publishing an event using the Mediator component

If we choose an existing EDL file that is not in our project, JDeveloper will assume that we want to copy the EDL file and its associated XML schemas into the project. On the Localize Files dialog, we have the choice of keeping existing directory relationships between files or flattening any existing directory structure.

Publishing an event using the Mediator component

Once the event is selected, we then just need to add a transformation to transform the input of the request to the event format.

Publishing an event using BPEL

We can also publish events using BPEL. Using the previous example, we may decide that rather than just publishing a NewAuction event that contains the input data used to create the auction, we also wish to include the auction identifier generated by the response to the new auction request. This is best achieved using the BPEL event publisher.

Using the previous example, we insert a BPEL process between the service requestor, in this case, NewAuctionMediator, and the service provider, in this case ServiceProvider. We use the Base on a WSDL template to create the process and select the WSDL of the target service as our WSDL, in this case the WSDL for ServiceMediator. We then rewire the composite so that the target service is now invoked by our new BPEL process, and the original client of the service is now a client of the BPEL process, as shown in the following diagram:

Publishing an event using BPEL

We then edit the BPEL process to invoke the original target service. Because we have used the target service WSDL for the WSDL of the BPEL process, we can use the input and output variables of the process as parameters to invoke the target service. With this done, we are ready to publish the event as part of our BPEL process.

Publishing an event using BPEL

We publish an event from within BPEL by using an invoke and setting the Interaction Type to be Event rather than the more usual Partner Link.

Publishing an event using BPEL

This allows us to select an event and a variable to hold the data for that event. The event itself is chosen from the Event Chooser dialog, which was introduced in the previous section. We then need to add an assign statement to initialize the variable used to populate the event. The fact that this invoke is actually raising an event is identified by the lightning symbol on the Invoke.

Publishing an event using BPEL

Note that when we raise an event, there is no indication provided as to how to route or deliver the event. In the next section, we will look at how events are consumed.

Publishing an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Events

An event is the message that will be published and consumed on the Event Delivery Network. Events consist of three parts:

  1. A namespace that identifies the general area that the event is associated with and helps to avoid clashes between event names
  2. A name that identifies the type of event within a namespace
  3. A data type that defines the data associated with the event

Namespaces of events behave in the same way as namespaces in XML and identify the solution area of the events and avoid clashes between events with the same name that belong to different solution areas. For example, a namespace would differentiate an event called NewOrder in a military command and control system from an event called NewOrder in a logistics system.

Events are defined using an XML-based language called the Event Description Language (EDL).

We can model business events from within JDeveloper by clicking on the event icon Events on the top-left-hand corner of the composite editor as shown in the following screenshot.

Events

This brings up the Create Event Definition File dialog to allow us to create a new EDL file to contain our event definitions.

Events

After defining the EDL File Name, the Directory it resides in, and the Namespace of the EDL file, we can add events to it by clicking on the green plus symbol Events. This takes us to the Add an Event dialog, where we can choose the XML Element that represents the data content of the event and give the event a Name.

Event elements and data types should always be defined in an XML schema file, which is separate from other SOA XML artifacts such as message schemas. This is because the events may be used across many areas, and they should not have dependencies on other SOA artifacts.

Events

After completing the definition of our EDL file, it is displayed in JDeveloper, where we can continue to add or remove events.

Events

The EDL file itself is a very simple format, shown as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns=http://schemas.oracle.com/events/edltargetNamespace="AuctionEventDefinitions">
    <schema-import namespace="auction.events"location="xsd/AuctionEvents.xsd"/>
        <event-definition name="NewAuctionEvent">
        <content xmlns:ns0=" auction.events"element="ns0:NewAuction"/>
        </event-definition>
        <event-definition name="NewBidEvent">
          <content xmlns:ns0=" auction.events" element="ns0:NewBid"/>
        </event-definition>
</definitions>

The targetNamespace attribute of the <definitions> element defines the namespace for the events. XML-type definitions are imported using <schema-import>, and <event-definition> is used to define events and their associated element.

Event publishers

Events are created by event publishers. An event publisher may be a Mediator or BPEL component in an SCA Assembly or it may be a custom Java application. The event publisher raises the event by creating an XML element and passing it to the Event Delivery Network. Once passed to the EDN, the publisher is unaware of how many subscribers consume the event or even if the event is consumed by any subscriber. This provides a degree of isolation between the publisher and subscribers. The EDN is responsible for keeping track of who is subscribing and ensuring that they receive the new event.

Publishing an event using the Mediator component

When using a Mediator to publish an event, we usually want to publish the event in parallel with other processing that the Mediator is doing. Typically, we want the Mediator to take the request from some service call and publish the event.

In the following example, we have a Mediator NewAuctionMediator that routes to a dummy service implemented by a Mediator ServiceMediator that uses Echo functionality to provide a synchronous response to its caller. We will raise a NewAuction event as part of the inbound processing in the Mediator. Note that although the Mediator will route a reply to the specific caller of the composite, the event will be routed to all subscribers of that event type.

Publishing an event using the Mediator component

We can raise an event based on the input request in the following fashion.

We open the routing Mediator component, in this case, NewAuctionMediator, and add a new sequential static routing rule. When the Target Type dialog comes up, select the Event button to generate an event.

Publishing an event using the Mediator component

In the Event Chooser dialog, we can choose the Event Definition File that contains our event. We can either browse for an existing EDL file using the magnifying glass icon or we can create a new EDL file by using the thunderbolt icon. Once an EDL file has been chosen, we can then select the specific event that we wish to produce.

Publishing an event using the Mediator component

If we choose an existing EDL file that is not in our project, JDeveloper will assume that we want to copy the EDL file and its associated XML schemas into the project. On the Localize Files dialog, we have the choice of keeping existing directory relationships between files or flattening any existing directory structure.

Publishing an event using the Mediator component

Once the event is selected, we then just need to add a transformation to transform the input of the request to the event format.

Publishing an event using BPEL

We can also publish events using BPEL. Using the previous example, we may decide that rather than just publishing a NewAuction event that contains the input data used to create the auction, we also wish to include the auction identifier generated by the response to the new auction request. This is best achieved using the BPEL event publisher.

Using the previous example, we insert a BPEL process between the service requestor, in this case, NewAuctionMediator, and the service provider, in this case ServiceProvider. We use the Base on a WSDL template to create the process and select the WSDL of the target service as our WSDL, in this case the WSDL for ServiceMediator. We then rewire the composite so that the target service is now invoked by our new BPEL process, and the original client of the service is now a client of the BPEL process, as shown in the following diagram:

Publishing an event using BPEL

We then edit the BPEL process to invoke the original target service. Because we have used the target service WSDL for the WSDL of the BPEL process, we can use the input and output variables of the process as parameters to invoke the target service. With this done, we are ready to publish the event as part of our BPEL process.

Publishing an event using BPEL

We publish an event from within BPEL by using an invoke and setting the Interaction Type to be Event rather than the more usual Partner Link.

Publishing an event using BPEL

This allows us to select an event and a variable to hold the data for that event. The event itself is chosen from the Event Chooser dialog, which was introduced in the previous section. We then need to add an assign statement to initialize the variable used to populate the event. The fact that this invoke is actually raising an event is identified by the lightning symbol on the Invoke.

Publishing an event using BPEL

Note that when we raise an event, there is no indication provided as to how to route or deliver the event. In the next section, we will look at how events are consumed.

Publishing an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Event publishers

Events are created by event publishers. An event publisher may be a Mediator or BPEL component in an SCA Assembly or it may be a custom Java application. The event publisher raises the event by creating an XML element and passing it to the Event Delivery Network. Once passed to the EDN, the publisher is unaware of how many subscribers consume the event or even if the event is consumed by any subscriber. This provides a degree of isolation between the publisher and subscribers. The EDN is responsible for keeping track of who is subscribing and ensuring that they receive the new event.

Publishing an event using the Mediator component

When using a Mediator to publish an event, we usually want to publish the event in parallel with other processing that the Mediator is doing. Typically, we want the Mediator to take the request from some service call and publish the event.

In the following example, we have a Mediator NewAuctionMediator that routes to a dummy service implemented by a Mediator ServiceMediator that uses Echo functionality to provide a synchronous response to its caller. We will raise a NewAuction event as part of the inbound processing in the Mediator. Note that although the Mediator will route a reply to the specific caller of the composite, the event will be routed to all subscribers of that event type.

Publishing an event using the Mediator component

We can raise an event based on the input request in the following fashion.

We open the routing Mediator component, in this case, NewAuctionMediator, and add a new sequential static routing rule. When the Target Type dialog comes up, select the Event button to generate an event.

Publishing an event using the Mediator component

In the Event Chooser dialog, we can choose the Event Definition File that contains our event. We can either browse for an existing EDL file using the magnifying glass icon or we can create a new EDL file by using the thunderbolt icon. Once an EDL file has been chosen, we can then select the specific event that we wish to produce.

Publishing an event using the Mediator component

If we choose an existing EDL file that is not in our project, JDeveloper will assume that we want to copy the EDL file and its associated XML schemas into the project. On the Localize Files dialog, we have the choice of keeping existing directory relationships between files or flattening any existing directory structure.

Publishing an event using the Mediator component

Once the event is selected, we then just need to add a transformation to transform the input of the request to the event format.

Publishing an event using BPEL

We can also publish events using BPEL. Using the previous example, we may decide that rather than just publishing a NewAuction event that contains the input data used to create the auction, we also wish to include the auction identifier generated by the response to the new auction request. This is best achieved using the BPEL event publisher.

Using the previous example, we insert a BPEL process between the service requestor, in this case, NewAuctionMediator, and the service provider, in this case ServiceProvider. We use the Base on a WSDL template to create the process and select the WSDL of the target service as our WSDL, in this case the WSDL for ServiceMediator. We then rewire the composite so that the target service is now invoked by our new BPEL process, and the original client of the service is now a client of the BPEL process, as shown in the following diagram:

Publishing an event using BPEL

We then edit the BPEL process to invoke the original target service. Because we have used the target service WSDL for the WSDL of the BPEL process, we can use the input and output variables of the process as parameters to invoke the target service. With this done, we are ready to publish the event as part of our BPEL process.

Publishing an event using BPEL

We publish an event from within BPEL by using an invoke and setting the Interaction Type to be Event rather than the more usual Partner Link.

Publishing an event using BPEL

This allows us to select an event and a variable to hold the data for that event. The event itself is chosen from the Event Chooser dialog, which was introduced in the previous section. We then need to add an assign statement to initialize the variable used to populate the event. The fact that this invoke is actually raising an event is identified by the lightning symbol on the Invoke.

Publishing an event using BPEL

Note that when we raise an event, there is no indication provided as to how to route or deliver the event. In the next section, we will look at how events are consumed.

Publishing an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Publishing an event using the Mediator component

When using a Mediator to publish an event, we usually want to publish the event in parallel with other processing that the Mediator is doing. Typically, we want the Mediator to take the request from some service call and publish the event.

In the following example, we have a Mediator NewAuctionMediator that routes to a dummy service implemented by a Mediator ServiceMediator that uses Echo functionality to provide a synchronous response to its caller. We will raise a NewAuction event as part of the inbound processing in the Mediator. Note that although the Mediator will route a reply to the specific caller of the composite, the event will be routed to all subscribers of that event type.

Publishing an event using the Mediator component

We can raise an event based on the input request in the following fashion.

We open the routing Mediator component, in this case, NewAuctionMediator, and add a new sequential static routing rule. When the Target Type dialog comes up, select the Event button to generate an event.

Publishing an event using the Mediator component

In the Event Chooser dialog, we can choose the Event Definition File that contains our event. We can either browse for an existing EDL file using the magnifying glass icon or we can create a new EDL file by using the thunderbolt icon. Once an EDL file has been chosen, we can then select the specific event that we wish to produce.

Publishing an event using the Mediator component

If we choose an existing EDL file that is not in our project, JDeveloper will assume that we want to copy the EDL file and its associated XML schemas into the project. On the Localize Files dialog, we have the choice of keeping existing directory relationships between files or flattening any existing directory structure.

Publishing an event using the Mediator component

Once the event is selected, we then just need to add a transformation to transform the input of the request to the event format.

Publishing an event using BPEL

We can also publish events using BPEL. Using the previous example, we may decide that rather than just publishing a NewAuction event that contains the input data used to create the auction, we also wish to include the auction identifier generated by the response to the new auction request. This is best achieved using the BPEL event publisher.

Using the previous example, we insert a BPEL process between the service requestor, in this case, NewAuctionMediator, and the service provider, in this case ServiceProvider. We use the Base on a WSDL template to create the process and select the WSDL of the target service as our WSDL, in this case the WSDL for ServiceMediator. We then rewire the composite so that the target service is now invoked by our new BPEL process, and the original client of the service is now a client of the BPEL process, as shown in the following diagram:

Publishing an event using BPEL

We then edit the BPEL process to invoke the original target service. Because we have used the target service WSDL for the WSDL of the BPEL process, we can use the input and output variables of the process as parameters to invoke the target service. With this done, we are ready to publish the event as part of our BPEL process.

Publishing an event using BPEL

We publish an event from within BPEL by using an invoke and setting the Interaction Type to be Event rather than the more usual Partner Link.

Publishing an event using BPEL

This allows us to select an event and a variable to hold the data for that event. The event itself is chosen from the Event Chooser dialog, which was introduced in the previous section. We then need to add an assign statement to initialize the variable used to populate the event. The fact that this invoke is actually raising an event is identified by the lightning symbol on the Invoke.

Publishing an event using BPEL

Note that when we raise an event, there is no indication provided as to how to route or deliver the event. In the next section, we will look at how events are consumed.

Publishing an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Publishing an event using BPEL

We can also publish events using BPEL. Using the previous example, we may decide that rather than just publishing a NewAuction event that contains the input data used to create the auction, we also wish to include the auction identifier generated by the response to the new auction request. This is best achieved using the BPEL event publisher.

Using the previous example, we insert a BPEL process between the service requestor, in this case, NewAuctionMediator, and the service provider, in this case ServiceProvider. We use the Base on a WSDL template to create the process and select the WSDL of the target service as our WSDL, in this case the WSDL for ServiceMediator. We then rewire the composite so that the target service is now invoked by our new BPEL process, and the original client of the service is now a client of the BPEL process, as shown in the following diagram:

Publishing an event using BPEL

We then edit the BPEL process to invoke the original target service. Because we have used the target service WSDL for the WSDL of the BPEL process, we can use the input and output variables of the process as parameters to invoke the target service. With this done, we are ready to publish the event as part of our BPEL process.

Publishing an event using BPEL

We publish an event from within BPEL by using an invoke and setting the Interaction Type to be Event rather than the more usual Partner Link.

Publishing an event using BPEL

This allows us to select an event and a variable to hold the data for that event. The event itself is chosen from the Event Chooser dialog, which was introduced in the previous section. We then need to add an assign statement to initialize the variable used to populate the event. The fact that this invoke is actually raising an event is identified by the lightning symbol on the Invoke.

Publishing an event using BPEL

Note that when we raise an event, there is no indication provided as to how to route or deliver the event. In the next section, we will look at how events are consumed.

Publishing an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Publishing an event using Java

We can also publish and consume events using Java. In this section, we will look at how Java code can be used to publish an event.

To publish an event, we need to go through the following steps:

  1. Create the event
  2. Connect to the Event Delivery Network
  3. Publish the event on the connection

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Creating the event

We create the event in Java by using the oracle.integration.platform.blocks.event.BusinessEventBuilder class. An instance of this class is created by a static factory method called newInstance. We need to provide a qualified name (QName that includes the namespace and the entity name) and a body for the event through setter methods on the builder class. Once these have been set, we can call createEvent to generate an instance of a BusinessEvent.

BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
QName name = new QName("http://schemas.oracle.com/events/edl/AuctionEventDefinitions","NewAuctionEvent");
builder.setEventName(name);
XMLElement content = …
builder.setBody(content);
BusinessEvent event = builder.createEvent();

The event name is a combination of the event schema, acting as an XML namespace, and the event name. The content is the XML element containing the event content.

Once we have a BusinessEvent, we need a connection to the Event Delivery Network in order to publish the event.

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.
    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator
Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Creating the event connection

The event connection can be created using either a JMS queue connection to the Event Delivery Network or an Oracle AQ connection. The latter requires the use of a data source and is the approach we will show. We obtain an oracle.fabric.blocks.event.BusinessEventConnection from a BusinessEventConnectionFactory. We will use the AQ version of this connection factory, which is provided by the oracle.integration.platform.blocks.event.saq. SAQRemoteBusinessEventConnectionFactory class.

DataSource ds = …
  BusinessEventConnectionFactory factory = new
    SAQRemoteBusinessEventConnectionFactory(ds, ds, null);
  BusinessEventConnection conn =
    factory.createBusinessEventConnection();

We use the connection factory to create a connection to Event Delivery Network. The data source we provide must be configured to connect to the SOA infrastructure schema in the database, which by default is called <PREFIX>_SOAInfra.

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.
    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator
Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Publishing the event

Now that we have an EDN connection, we can publish our event on it by calling publishEvent:

conn.publishEvent(event, EVENT_PRIORITY);

This publishes our event on our previously created connection. The event priority is usually set to 3, but it is not used in this release.

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.
    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator
Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Event subscribers

Events are consumed by event subscribers. In a similar fashion to event publishers, event subscribers may be BPEL processes or Mediators. When subscribing to an event, the subscriber can filter the events. Subscribers subscribe to a specific event within an event namespace. They can limit the instances of an event that they receive by applying a filter. Only events for which the filter evaluates to true are delivered to the event subscriber. Event filters are XPath expressions.

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Consuming an event using Mediator

To consume an event, we can add an event subscriber to a Mediator. We do this by clicking on the green plus sign next to the Event Subscriptions label under Routing Rules.

Consuming an event using Mediator

This brings us to the Subscribed Events dialog where, by clicking on the green plus sign, we add a new event subscription using the Event Chooser dialog introduced in the section on publishing an event.

Consuming an event using Mediator

Having chosen an event, we can determine how the event is to be delivered using the Consistency option. Transactions are discussed later in Chapter 15, Advanced SOA Suite Architecture. The consistency options are:

  • Exactly once by selecting the one and only one option. This makes the event delivery transaction part of the Mediator transaction. If the Mediator transaction completes successfully, then the event will also be marked as read, otherwise it will be rolled back and thus appear not to have been delivered. Transaction boundaries are explained in more detail in Chapter 15, Advanced SOA Suite Architecture
  • At least once by selecting guaranteed. This keeps the Mediator transaction separate from the delivery transaction. The event will be delivered to the subscriber, but any errors in the Mediator may cause that event to be lost to that subscriber.
  • immediate makes the delivery transaction part of the event publishing transaction. This option should be avoided as it couples the subscriber and the publisher.

    Tip

    Avoid using the immediate delivery option as it tightly couples the publisher to a subscriber that it should be unaware of. The Java API for this is marked as deprecated, and it is likely that this option will disappear in the future.

The Run as publisher option allows the Mediator to run in the same security context as the event publisher. This allows the subscriber component to perform any actions that the publisher could perform.

The Filter option brings up the Expression Builder dialog when clicked on. This allows us to construct an XPath expression to limit the delivered event to only those for which the XPath expression resolves to true.

Consuming an event using Mediator

A component in a composite that has subscribed to an event has a lightning bolt Consuming an event using Mediator on its service side to identify it within a composite.

Consuming an event using Mediator

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

Consuming an event using BPEL

To subscribe to an event using BPEL, we can create a BPEL process using the Subscribe to Events template. This allows us to add the events to which we wish to subscribe to in a similar fashion to having the Mediator subscribe to events by using the Event Chooser dialog and adding quality of service options and filters.

Consuming an event using BPEL

This creates a BPEL process with a single receive activity that identifies itself as subscribing to an event by the lightening icon Consuming an event using BPEL on the receive.

Consuming an event using BPEL

Events may also be subscribed to by adding a BPEL Receive activity to the process and choosing an Interaction Type of Event.

Consuming an event using BPEL

EDN publishing patterns with SOA Suite

The table in this section summarizes the different ways in which events may be published within the SOA Suite depending on the requirement.

Requirement

Pattern

Publish an event on receipt of a message

A Mediator can achieve this by implementing the target service interface and passing the message through the target while adding a publish event item in sequence.

Publish an event on a synchronous message response

A BPEL process can achieve this by implementing the target service interface and passing the message through the target and passing the response back to the caller. Either before or after the return to the caller, the process can publish an event item using data from the response.

Publish an event on a synchronous message request and reply

A BPEL process can achieve this by implementing the target service interface and passing the message through the target and passing the response back to the caller. Either before or after the return to the caller, the process can publish an event item using data from the request and the response.

Publish an event on an asynchronous response

A BPEL process can achieve this by implementing the async interface, and before or after passing the message from the target back to the caller, it can publish an event item using data from the response.

Publish an event on an asynchronous message request and reply

A BPEL process can achieve this by implementing the target service interface and the callback interface and passing the message through the target and passing the callback back to the caller. Either before or after the callback to the caller, the process can publish an event item using data from the request and the response.

Publish an event on an event

A Mediator can achieve this by subscribing to an event and then publishing an event.

We will now look at how each of these patterns may be implemented.

Publishing an event on receipt of a message

If we receive a message, either a one way or a request/reply interaction, we can use the Mediator to publish an event based on the content of the inbound message by using a static routing rule to raise the event before or after forwarding the request to a target service, as shown in the following screenshot:

Publishing an event on receipt of a message

Publishing an event on a synchronous message response

If we wish to raise an event based on the response to a request/reply interaction, then we need to use a BPEL process to invoke the target service and then raise the event based on the content of the response, as shown in the following screenshot:

Publishing an event on a synchronous message response

Publishing an event on a synchronous message request and reply

When an event needs to be raised, based on the content of both the request and reply parts of a synchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an asynchronous response

When an event needs to be raised based on the content of an asynchronous response, we can use a BPEL process to do this. We invoke the target service and get the reply. Then, either before or after sending the reply back to the initiator of the service interaction, we can raise the event, as shown in the following screenshot:

Publishing an event on an asynchronous response

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on receipt of a message

If we receive a message, either a one way or a request/reply interaction, we can use the Mediator to publish an event based on the content of the inbound message by using a static routing rule to raise the event before or after forwarding the request to a target service, as shown in the following screenshot:

Publishing an event on receipt of a message

Publishing an event on a synchronous message response

If we wish to raise an event based on the response to a request/reply interaction, then we need to use a BPEL process to invoke the target service and then raise the event based on the content of the response, as shown in the following screenshot:

Publishing an event on a synchronous message response

Publishing an event on a synchronous message request and reply

When an event needs to be raised, based on the content of both the request and reply parts of a synchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an asynchronous response

When an event needs to be raised based on the content of an asynchronous response, we can use a BPEL process to do this. We invoke the target service and get the reply. Then, either before or after sending the reply back to the initiator of the service interaction, we can raise the event, as shown in the following screenshot:

Publishing an event on an asynchronous response

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on a synchronous message response

If we wish to raise an event based on the response to a request/reply interaction, then we need to use a BPEL process to invoke the target service and then raise the event based on the content of the response, as shown in the following screenshot:

Publishing an event on a synchronous message response

Publishing an event on a synchronous message request and reply

When an event needs to be raised, based on the content of both the request and reply parts of a synchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an asynchronous response

When an event needs to be raised based on the content of an asynchronous response, we can use a BPEL process to do this. We invoke the target service and get the reply. Then, either before or after sending the reply back to the initiator of the service interaction, we can raise the event, as shown in the following screenshot:

Publishing an event on an asynchronous response

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on a synchronous message request and reply

When an event needs to be raised, based on the content of both the request and reply parts of a synchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an asynchronous response

When an event needs to be raised based on the content of an asynchronous response, we can use a BPEL process to do this. We invoke the target service and get the reply. Then, either before or after sending the reply back to the initiator of the service interaction, we can raise the event, as shown in the following screenshot:

Publishing an event on an asynchronous response

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on an asynchronous response

When an event needs to be raised based on the content of an asynchronous response, we can use a BPEL process to do this. We invoke the target service and get the reply. Then, either before or after sending the reply back to the initiator of the service interaction, we can raise the event, as shown in the following screenshot:

Publishing an event on an asynchronous response

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on an asynchronous message request and reply

When an event needs to be raised based on the content of both the request and reply parts of an asynchronous interaction, a BPEL process can be used to do this. The pattern is essentially the same as the previous pattern, except that in the <assign> to the event variable, we include data from both the request message and the reply message.

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Publishing an event on an event

We can use a Mediator to raise an event based on an incoming event. We may want to do this to map events from one namespace to another or to manage backwards compatibility between different versions of an event without having to change subscribers or publishers. The Mediator can simply raise the outgoing event based on the incoming event by using a sequential routing rule, as shown in the following screenshot:

Publishing an event on an event

Monitoring event processing in Enterprise Manager

We can monitor what is happening with events from within Enterprise Manager. We can also create new events from the EM console.

We can track what is happening with events by using the Business Events menu item of the soa_infra tree node. This brings up the Business Events screen.

Monitoring event processing in Enterprise Manager

On the Events tab of this screen, we can see the list of events registered with the server and the number of subscriptions and failed deliveries for each event. We can also create database event subscriptions from this screen by selecting an event and clicking on the Subscribe… link.

Monitoring event processing in Enterprise Manager

Selecting an event and clicking the Test… button allows us to publish a new event. No assistance is provided with the format of the event, which should be laid out as shown in the following example:

<business-event
  xmlns:ns1=http://soa.suite.book/events/edl/AuctionEvents
  xmlns="http://oracle.com/fabric/businessEvent">
    <name>ns1:NewAuction</name>
      <id>e4196227-806c-4680-a6b4-6f8df931b3f3</id>
        <content>
          <NewAuction xmlns="http://soa.suite.book/AuctionEvents">
            <seller>Antony</seller>
              <item>Used Running Shoes</item>
                <id>12345</id>
          </NewAuction>
        </content>
</business-event>

Note that the event content inside the <content> tab is the data associated with our new event. The <business-event> identifies the namespace of the event, and under this, the <name> element identifies the specific event.

Monitoring event processing in Enterprise Manager

The Subscriptions tab gives us more information about subscriptions, identifying the composite and component within the composite that are subscribing to a particular event. We can also see the transaction consistency level and any filter that is being applied.

Subscriptions can either be linked to a stored procedure in the database, database subscriptions, or they can be subscriptions within components in a composite.

Monitoring event processing in Enterprise Manager

The Faults tab allows us to see the details of any faults generated by subscriptions when trying to receive an event.

Summary

In this chapter, we have explored how EDN differs from traditional MOM systems and also how it is used to allow seamless extension of business functionality without requiring any modification of business processes and services. We have looked at the different ways in which Mediator and BPEL may be used to publish events and taken a brief overview of the event monitoring abilities of Enterprise Manager.

You have been reading a chapter from
Oracle SOA Suite 11g R1 Developer's Guide
Published in: Jul 2010
Publisher: Packt
ISBN-13: 9781849680189
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime