Before we start you should know that we can only make Remote Event Connections because you are running the Java or OSB process in a different JVM then the SOA Suite. And only asynchronous subscriptions will be supported for remote event connections.
First let's create a Java Client which publish the events directly to the SOA Suite Server. I will use the jars of the SOA Suite. This is not necessary. You can just publish a JMS text message and set some JMS Header properties (MessageType and SideCar )
Make a new JDeveloper project which contains the following libraries.
Here is my test class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.whitehorses.adf.edn; | |
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.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 PublishJMSEvent { | |
public static void main(String[] args) { | |
// My SOA WebLogic variables | |
Properties props = new Properties(); | |
props.put(Context.PROVIDER_URL, "t3://localhost:7001"); | |
props.put(Context.INITIAL_CONTEXT_FACTORY, | |
"weblogic.jndi.WLInitialContextFactory"); | |
props.put(Context.SECURITY_PRINCIPAL, "weblogic"); | |
props.put(Context.SECURITY_CREDENTIALS, "weblogic1"); | |
// the business Event | |
String EmployeeEvent = "EmployeeEvent"; | |
String NameSpace = | |
"http://schemas.oracle.com/events/edl/EmployeeEventEDL"; | |
String EmployeeEventBody = | |
"<Employee xmlns=\"http://nl.whitehorses.employee.event\">" + | |
"<Id>110</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(props); | |
// 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); | |
// publish | |
conn.publishEvent(builder.createEvent(), 4); | |
conn.close(); | |
} catch (NamingException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
The second part of this blogpost is how to do this in OSB.
Before we can work on the Proxy or Business Service we need to create a Foreign JNDI Provider on the WebLogic Service. ( You can also use a JNDI Provider of the OSB Configuration project )
Provide the SOA Server details.
Provide the local and remote EDN-JMS JNDI Link names. The Remote JNDI Names are fixed but you can change your local ones.
Restart the OSB Server and open OEPE or the SBConsole.
Create a new Business Service and choose for Messaging Service as Service Type.
Event is an One Way Operation so only need to set the Request Message Type to text.
Use the Local JNDI names of the Foreign JNDI Provider in the Endpoint URI
Select Text as Message Type.
Create a Proxy Service which call this Business Service, where we will replace the Body contents with the event data and set some JMS Headers in the Transport Header.
Replace the body contents in a Replace Action.
My test event, the values of Id and ecid element contains unique UUID values.
And the last part is to set the Messagetype and SideCar JMS Headers
MessageType is always Remote
SideCar in my case
<business-event-sidecar xmlns:ns="http://schemas.oracle.com/events/edl/EmployeeEventEDL"
xmlns="http://oracle.com/fabric/sideCar">
<name xmlns="http://oracle.com/fabric/businessEvent">ns:EmployeeEvent-sidecar</name>
</business-event-sidecar>
You can test the Proxy Service in the SBConsole.