I needed to send EDN Events to a SOA 12c from Java and taking as example the Edwin's Biemond post Publish Event from Java with JMS I decided to update it to version 12c.
In 12c EDN is different, it were rewritten and it's based on Topics.
Now supports WLJMS as default, or you can use AQJMS, and we don't need to specify the Topic, it take it from the default configuration.
Make a new JDeveloper Java Project and create a Java class PublishEvent.
The jars that you must use in the project are:
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/edn.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
$MDW_HOME/soa/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar
$MDW_HOME/oracle_common/modules/com.oracle.webservices.fabric-common-api_12.1.3.jar
$MDW_HOME/oracle_common/modules/oracle.xdk_12.1.3/xmlparserv2.jar
$MDW_HOME/wlserver/server/lib/weblogic.jar
$MDW_HOME/oracle_common/modules/oracle.jrf_12.1.3/jrf-api.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/tracking-core.jar
$MDW_HOME/soa/soa/modules/oracle.soa.adapter_11.1.1jca-binding-api.jar
In 12c EDN is different, it were rewritten and it's based on Topics.
Now supports WLJMS as default, or you can use AQJMS, and we don't need to specify the Topic, it take it from the default configuration.
Make a new JDeveloper Java Project and create a Java class PublishEvent.
package com.vatrox.soa.edn.utils; import java.util.Properties; import javax.naming.Context; import javax.xml.namespace.QName; 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.jms2.EdnJmsConnectionFactory; import oracle.soa.common.util.XMLUtil; import org.w3c.dom.Element; public class PublishEvent { public static void main(String[] args) { // My SOA WebLogic variables Properties props = new Properties(); props.put(Context.PROVIDER_URL, "t3://soaserver.vatrox.com:8001"); props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(Context.SECURITY_PRINCIPAL, "weblogic"); props.put(Context.SECURITY_CREDENTIALS, "welcome1"); // the business Event String DemoEvent = "DemoEvent"; String NameSpace = "http://xmlns.oracle.com/Vatrox_SOA_EDN/DemoEDN/demoEvent"; String DemoEventBody = "<Evento>" + "<dato>DemoEvent</dato>" + "</Evento>"; Element eventBody = null; try { eventBody = XMLUtil.parseDocumentFromXMLString(DemoEventBody.toString()).getDocumentElement(); } catch (Exception e) { e.printStackTrace(); } try { BusinessEventConnectionFactory factory = new EdnJmsConnectionFactory(props); BusinessEventConnection conn = factory.createBusinessEventConnection(); // Create an event BusinessEventBuilder builder = BusinessEventBuilder.newInstance(); builder.setEventName(new QName(NameSpace, DemoEvent)); builder.setBody(eventBody); // publish conn.publishEvent(builder.createEvent(), 4); conn.close(); } catch (Exception e) { e.printStackTrace(); } } }
The jars that you must use in the project are:
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/edn.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
$MDW_HOME/soa/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar
$MDW_HOME/oracle_common/modules/com.oracle.webservices.fabric-common-api_12.1.3.jar
$MDW_HOME/oracle_common/modules/oracle.xdk_12.1.3/xmlparserv2.jar
$MDW_HOME/wlserver/server/lib/weblogic.jar
$MDW_HOME/oracle_common/modules/oracle.jrf_12.1.3/jrf-api.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/tracking-core.jar
$MDW_HOME/soa/soa/modules/oracle.soa.adapter_11.1.1jca-binding-api.jar