JDev 11.1.1.4
Using a mediator, if you subscribe to an event, and publish the same event, then it creates an infite loop.
For example, consider the following composite:
As you can see, the mediator is both receiving and publishing the event. Here is how mediator looks like:

The event definition is created using the Event Defination creation icon as shown below:

Here is the event definition (.edl file content):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://schemas.oracle.com/events/edl" targetNamespace="http://schemas.oracle.com/events/edl/EmpEvent">
<schema-import namespace="http://model/events/schema/EmpEO" location="xsd/EmpEO.xsd"/>
<event-definition name="Emp">
<content xmlns:ns0="http://model/events/schema/EmpEO" element="ns0:EmpCreateInfo"/>
</event-definition>
</definitions>
And here is the EmpEO schmea:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<xs:schema targetNamespace="http://model/events/schema/EmpEO" xmlns="http://model/events/schema/EmpEO"
elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EmpCreateInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="Empno" type="IntValuePair" minOccurs="1"/>
<xs:element name="Ename" type="StringValuePair" minOccurs="1"/>
<xs:element name="Comm" type="DecimalValuePair" minOccurs="0"/>
<xs:element name="Deptno" type="IntValuePair" minOccurs="0"/>
<xs:element name="Hiredate" type="DateTimeValuePair" minOccurs="0"/>
<xs:element name="Job" type="StringValuePair" minOccurs="0"/>
<xs:element name="Mgr" type="IntValuePair" minOccurs="0"/>
<xs:element name="Sal" type="DecimalValuePair" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ValuePair" abstract="true"/>
<xs:complexType name="StringValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="IntValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:int"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:int"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DateTimeValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:dateTime"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:dateTime"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DecimalValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:decimal"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:decimal"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
After deploying the project on SOA Server, we can see the no record exists as of now for this composite, as shown below:
Now, I am publishing the event as shown below:
The event is published successfully, as shown below:

Now, we need to see how this composite is behaving. As you can see in the figure below, the instance count moves to 1528 in no time:
After refreshing the page, I see that instance count has increased :
When I tried to see the payload received by the mediator, I see that entered values are not received as well:
However, if we remove the publishing of event from the mediator and just subscribe the event:
And deploy the composite, then mediator component works fine, as shown below:
And payload values are visible as well:
So, never subscribe and publish same event from a mediator.
Using a mediator, if you subscribe to an event, and publish the same event, then it creates an infite loop.
For example, consider the following composite:
As you can see, the mediator is both receiving and publishing the event. Here is how mediator looks like:
The event definition is created using the Event Defination creation icon as shown below:
Here is the event definition (.edl file content):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://schemas.oracle.com/events/edl" targetNamespace="http://schemas.oracle.com/events/edl/EmpEvent">
<schema-import namespace="http://model/events/schema/EmpEO" location="xsd/EmpEO.xsd"/>
<event-definition name="Emp">
<content xmlns:ns0="http://model/events/schema/EmpEO" element="ns0:EmpCreateInfo"/>
</event-definition>
</definitions>
And here is the EmpEO schmea:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<xs:schema targetNamespace="http://model/events/schema/EmpEO" xmlns="http://model/events/schema/EmpEO"
elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EmpCreateInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="Empno" type="IntValuePair" minOccurs="1"/>
<xs:element name="Ename" type="StringValuePair" minOccurs="1"/>
<xs:element name="Comm" type="DecimalValuePair" minOccurs="0"/>
<xs:element name="Deptno" type="IntValuePair" minOccurs="0"/>
<xs:element name="Hiredate" type="DateTimeValuePair" minOccurs="0"/>
<xs:element name="Job" type="StringValuePair" minOccurs="0"/>
<xs:element name="Mgr" type="IntValuePair" minOccurs="0"/>
<xs:element name="Sal" type="DecimalValuePair" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ValuePair" abstract="true"/>
<xs:complexType name="StringValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="IntValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:int"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:int"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DateTimeValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:dateTime"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:dateTime"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DecimalValuePair">
<xs:complexContent>
<xs:extension base="ValuePair">
<xs:sequence>
<xs:element name="newValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:decimal"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="oldValue" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="value" type="xs:decimal"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
After deploying the project on SOA Server, we can see the no record exists as of now for this composite, as shown below:
Now, I am publishing the event as shown below:
The event is published successfully, as shown below:
Now, we need to see how this composite is behaving. As you can see in the figure below, the instance count moves to 1528 in no time:
After refreshing the page, I see that instance count has increased :
When I tried to see the payload received by the mediator, I see that entered values are not received as well:
However, if we remove the publishing of event from the mediator and just subscribe the event:
And deploy the composite, then mediator component works fine, as shown below:
And payload values are visible as well:
So, never subscribe and publish same event from a mediator.
No comments:
Post a Comment