Step1:- We can write Java API to publish event in EDN based on JMS or EDN based on AQ. This java API code need to insert in ADF page on Click button action. By default EDN would be AQ based. For changing it to JMS based need to change one property in SOA server and restart.
Note:- We need to decide if we want to use EDN-AQ or EDN-JMS. The AQ implementation is the default EDN implementation but this requires some datasources to the soa-infra database. This can be Ok in a small server network but it will create dependency to this SOA Suite Server in WebLogic Server.”
Step 2:- I will explain here EDN based on JMS.
Step 2(i):- For using EDN based on JMS we have to do below changes in enterprise manager
1. Open the enterprise manager application | SOA | soa-infra
2. Open the Common Properties Menu item of the SOA-Infrastructure menu
3. Click on More SOA-Infra Advanced Configuration Properties.This will open the System MBean Browser. In this we can change the EdnJmsMode and set this to true. Restart the SOA Server and take a look at the monitoring of the EDN Queue jms/fabric/EDNQueue which by default present on server
SOAJMSModule located at the JMSModules of WebLogic you can see that the module already contains an EDN Queue and an EDN ConnectionFactory.
By default jms/fabric/EDNConnectionFactory, jms/fabric/EDNQueue will be there on server. Create a JMS Connection Factory called xaEDNConnectionFactory with JNDI name jms/fabric/xaEDNConnectionFactory, enable XA and targeted this to your WebLogic server.
Step 2(ii):- Configure a Foreign JNDI Provider to Enable Administration Server Applications to Publish Events to the SOA Server
1.Log in to the Oracle WebLogic Server Administration Console.
2.In the Domain Structure section, expand Services > Data Sources.
You must remove the EDN-DB JNDI sources to use EDN-JMS data sources.
3.Select the following EDN-DB JNDI data sources, and click Remove.
◦jdbc/EDNDataSource
◦jdbc/EDNLocalTxDataSource
If the event publisher is in an application (for example, ADF) running in a different cluster or even in a different domain from the SOA server for EDN, you must configure a foreign JNDI provider with the local JNDI names for the cluster mapping to JNDI names targeted to the SOA Infrastructure. Local and remote JNDI names are the same in the links.
4.In the Domain Structure section, expand Services > Foreign JNDI Providers.
5.Click New.
6.In the Name field, enter a name for the foreign JNDI provider.
7.Select targets for the new JNDI provider, and click Finish.
8.In the Name field, click the new JNDI provider.
9.Specify provider settings (the initial context factory, provider URL, and so on), and click Save.
Initial Context Factory:- weblogic.jndi.WLInitialContextFactory.
Provider URL:- t3://hostname:soa_server_port.
User:- Enter the Oracle WebLogic Server user name.
Password and Confirm Password:- Enter the password for the Oracle WebLogic Server user name.
10.Click the Links tab.
11.Click New to create a foreign JNDI link.
12.Enter a name, then specify the local and remote JNDI name of jms/fabric/EDNConnectionFactory.
13.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/xaEDNConnectionFactory.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/EDNQueue.
Once complete, three links are created.
14.Restart the targeted servers.
15.Confirm the new JNDI provider links in the JNDI tree view.
Step 2(iii):- ADF page will take two input parameter and will pass to xsd in API code and one create Event button .Java API code along with backing bean in ADF page:-
Need to add Libraries in View Controller to avoid any compilation error(i)SOA runtime (ii) Weblogic Remote Client (iii) JSF etc
package viewControler.backing;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.util.Properties;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.transaction.UserTransaction;
import javax.xml.namespace.QName;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.fabric.blocks.event.BusinessEventConnection;
import oracle.fabric.blocks.event.BusinessEventConnectionFactory;
import oracle.integration.platform.blocks.event.BusinessEventBuilder;
import oracle.integration.platform.blocks.event.jms.JmsRemoteBusinessEventConnectionFactory;
import oracle.soa.common.util.XMLUtil;
import org.w3c.dom.Element;
public class CallEventApI {
public String cb1_action() {
// Add event code here...
// My SOA WebLogic variables
// the business Event
//Enter name of business event
String EmployeeEvent = "Event1";
//Enter target namespace of business event
String NameSpace =
"http://xmlns.oracle.com/SubscribedEventProject/EventDefinition1";
String name = getIt1().getValue().toString();
String id = getIt2().getValue().toString();
//Enter the XSD payload
String EmployeeEventBody =
"<Employee xmlns=\"http://www.example.org\">" +
"<Name>"+name+"</Name>" +
"<Id>"+id+"</Id>" +
"</Employee>";
Element eventBody = null;
try {
eventBody =
XMLUtil.parseDocumentFromXMLString(
EmployeeEventBody.toString()).getDocumentElement();
} catch (Exception e) {
e.printStackTrace();
}
// EDN JMS environment
String connFactName = "jms/fabric/EDNConnectionFactory";
String xaConnFactName = "jms/fabric/xaEDNConnectionFactory";
String queueName = "jms/fabric/EDNQueue";
try {
InitialContext context = new InitialContext();
// do a jndi lookup on the Server
UserTransaction userTransaction = (UserTransaction)context.lookup("javax.transaction.UserTransaction");
QueueConnectionFactory queueConnectionFactory = ((QueueConnectionFactory)context.lookup(connFactName));
QueueConnectionFactory xaQueueConnectionFactory = ((QueueConnectionFactory)context.lookup(xaConnFactName));
Queue jmsQueue = ((Queue)context.lookup(queueName));
BusinessEventConnectionFactory factory =
new JmsRemoteBusinessEventConnectionFactory(queueConnectionFactory,
xaQueueConnectionFactory,
jmsQueue,
userTransaction);
BusinessEventConnection conn =
factory.createBusinessEventConnection();
// Create an event
BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
builder.setEventName(new QName(NameSpace, EmployeeEvent));
builder.setBody(eventBody);
System.out.println("here called");
// publish
conn.publishEvent(builder.createEvent(), 4);
conn.close();
} catch (NamingException e) {
e.printStackTrace();
}
return null;
}
}
Step 2(ii):- Configure a Foreign JNDI Provider to Enable Administration Server Applications to Publish Events to the SOA Server
1.Log in to the Oracle WebLogic Server Administration Console.
2.In the Domain Structure section, expand Services > Data Sources.
You must remove the EDN-DB JNDI sources to use EDN-JMS data sources.
3.Select the following EDN-DB JNDI data sources, and click Remove.
◦jdbc/EDNDataSource
◦jdbc/EDNLocalTxDataSource
If the event publisher is in an application (for example, ADF) running in a different cluster or even in a different domain from the SOA server for EDN, you must configure a foreign JNDI provider with the local JNDI names for the cluster mapping to JNDI names targeted to the SOA Infrastructure. Local and remote JNDI names are the same in the links.
4.In the Domain Structure section, expand Services > Foreign JNDI Providers.
5.Click New.
6.In the Name field, enter a name for the foreign JNDI provider.
7.Select targets for the new JNDI provider, and click Finish.
8.In the Name field, click the new JNDI provider.
9.Specify provider settings (the initial context factory, provider URL, and so on), and click Save.
Initial Context Factory:- weblogic.jndi.WLInitialContextFactory.
Provider URL:- t3://hostname:soa_server_port.
User:- Enter the Oracle WebLogic Server user name.
Password and Confirm Password:- Enter the password for the Oracle WebLogic Server user name.
10.Click the Links tab.
11.Click New to create a foreign JNDI link.
12.Enter a name, then specify the local and remote JNDI name of jms/fabric/EDNConnectionFactory.
13.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/xaEDNConnectionFactory.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/EDNQueue.
Once complete, three links are created.
14.Restart the targeted servers.
15.Confirm the new JNDI provider links in the JNDI tree view.
Step 2(iii):- ADF page will take two input parameter and will pass to xsd in API code and one create Event button .Java API code along with backing bean in ADF page:-
Need to add Libraries in View Controller to avoid any compilation error(i)SOA runtime (ii) Weblogic Remote Client (iii) JSF etc
package viewControler.backing;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.util.Properties;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.transaction.UserTransaction;
import javax.xml.namespace.QName;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.fabric.blocks.event.BusinessEventConnection;
import oracle.fabric.blocks.event.BusinessEventConnectionFactory;
import oracle.integration.platform.blocks.event.BusinessEventBuilder;
import oracle.integration.platform.blocks.event.jms.JmsRemoteBusinessEventConnectionFactory;
import oracle.soa.common.util.XMLUtil;
import org.w3c.dom.Element;
public class CallEventApI {
public String cb1_action() {
// Add event code here...
// My SOA WebLogic variables
// the business Event
//Enter name of business event
String EmployeeEvent = "Event1";
//Enter target namespace of business event
String NameSpace =
"http://xmlns.oracle.com/SubscribedEventProject/EventDefinition1";
String name = getIt1().getValue().toString();
String id = getIt2().getValue().toString();
//Enter the XSD payload
String EmployeeEventBody =
"<Employee xmlns=\"http://www.example.org\">" +
"<Name>"+name+"</Name>" +
"<Id>"+id+"</Id>" +
"</Employee>";
Element eventBody = null;
try {
eventBody =
XMLUtil.parseDocumentFromXMLString(
EmployeeEventBody.toString()).getDocumentElement();
} catch (Exception e) {
e.printStackTrace();
}
// EDN JMS environment
String connFactName = "jms/fabric/EDNConnectionFactory";
String xaConnFactName = "jms/fabric/xaEDNConnectionFactory";
String queueName = "jms/fabric/EDNQueue";
try {
InitialContext context = new InitialContext();
// do a jndi lookup on the Server
UserTransaction userTransaction = (UserTransaction)context.lookup("javax.transaction.UserTransaction");
QueueConnectionFactory queueConnectionFactory = ((QueueConnectionFactory)context.lookup(connFactName));
QueueConnectionFactory xaQueueConnectionFactory = ((QueueConnectionFactory)context.lookup(xaConnFactName));
Queue jmsQueue = ((Queue)context.lookup(queueName));
BusinessEventConnectionFactory factory =
new JmsRemoteBusinessEventConnectionFactory(queueConnectionFactory,
xaQueueConnectionFactory,
jmsQueue,
userTransaction);
BusinessEventConnection conn =
factory.createBusinessEventConnection();
// Create an event
BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
builder.setEventName(new QName(NameSpace, EmployeeEvent));
builder.setBody(eventBody);
System.out.println("here called");
// publish
conn.publishEvent(builder.createEvent(), 4);
conn.close();
} catch (NamingException e) {
e.printStackTrace();
}
return null;
}
}
Step 3:- Deploy the ADF page as war file then open the page url and click the button.
Once event will be triggered from ADF page will put the message in jms/fabric/EDNQueue queue. Once message will reached to queue then it will automatically invoke Subscribed mediator as in Java API we are passing the Event name and namespace of EDL file and Input payload.
Hope this would be helpful.