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;
}
}