Wednesday, October 13, 2010

Split join in Oracle Service Bus

In this exercise we will see how to use split join in Oracle service bus.The example i will show will not be a fun to watch but it surely will give you enough idea on how to create a split join and what is its use case.

First of all i will create a bpel process.This will be a simple synchronous bpel process which will take two input variable empid and empname and will produce the same.
I have tried to make it as simple as possible.

Open you jdeveloper and create a simple synchronous bpel process. I have called it as split.

NOw it will generate an xsd by default we will make some changes in the xsd to make it suitable for our use case.

So my xsd will look something like this.


<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/Split"
xmlns:arpit="http://xmlns.oracle.com/Split"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="SplitProcessRequest" type="arpit:empDetail"/>
<element name="SplitProcessResponse" type="arpit:empDetail"/>
<complexType name="empDetail">
<sequence>
<element name="empInfo" type="arpit:empInformation"/>
</sequence>
</complexType>
<complexType name="empInformation">
<sequence>
<element name="empid" type="string"/>
<element name="empname" type="string"/>
</sequence>
</complexType>
</schema>

NOw i just added a transform activity and copied the input variable to output variable as shown below



So just in case if you will like to see my process i have uploaded it here

Now your bpel process is completed now deploy this process to application server and get the wsdl of the web service thus generated.


NOw go to oracle workshop for weblogic and create a new osb project and give it some logical name ,i have used splitjoin





NOw once the project is created select that project and do a import resources from url



Provide the wsdl of the split web service ,give resource name as some logical name and don't forge to choose wsdl as resource type as shown below



Just say next it will import the xsd and the wsdl then say finish,now create a service account also as i have done in previous post


Now you have a service account a wsdl and a xsd in your project.Now select your project and create a split joint as shown below



Let the default name be there and say next



Expand the Split web service
and choose the process as shown below




As soon as you will say finish it will come up with a new gui something like this.





NOw we will start our design process, go to oracle workshop for weblogic go to help and search split join you will get all the details on how to design it.

It says something like this

"The first Assign, Prepare Output Message, contains an Assign operation that prepares the Response Variable in a form such that the later nodes can work on the data within it (that is, Copy/Insert/Assign/Replace/Delete/Java Callout/Log the data). This output message is relayed to the final Reply node in the Split-Join and, in turn, returned to the original client. "

So first of all i will put an assing activity in between to prepare my response variable.

I just put a assign activity as shown below after receive






NOw i have just assigned the input payload to output payload as shown below





Now drag and drop a parallel activity after assign as shown ,it will automatically come up with two branches as shown below



NOw drag and drop two assign activity in the two scopes as shown below now on left assign activity

i am just using the following scenario

$request.payload/bind:empInfo/bind:empid="1234"




Similarly in the right assign activity i am assinging

$request.payload/bind:empInfo/bind:empname="arpit"




I already have mentioned that this is probably not a great example ,i just want to depict how split join works,here as soon as the flow will enter the parallel process it will check both the flow and if both the flow are correct then only it will produce an output true.

If any of the input is wrong it will result as false.
Split join is mainly used when you have multiple orders and you want to handle them in parallel flow.


Now select your split flow and generate a business service out of it as shown in the following diagram




Business service got created for me but with the following error message "requested array is larger than heap"




The exact error message was something like this

Error message
An internal error occurred during: "Updating status for Oracle WebLogic Server v10.3 at localhost...".
Exception stack trace
java.lang.OutOfMemoryError: requested array is larger than heap
at org.eclipse.wst.server.core.internal.ModulePublishInfo.loadResource(ModulePublishInfo.java:189)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.load(ModulePublishInfo.java:184)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.(ModulePublishInfo.java:84)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.load(ServerPublishInfo.java:274)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.(ServerPublishInfo.java:56)
at org.eclipse.wst.server.core.internal.PublishInfo.getServerPublishInfo(PublishInfo.java:75)
at org.eclipse.wst.server.core.internal.Server.getServerPublishInfo(Server.java:843)
at org.eclipse.wst.server.core.internal.Server.hasPublishedResourceDelta(Server.java:1069)
at org.eclipse.wst.server.core.internal.Server$2.visit(Server.java:179)
at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2446)
at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2457)
at org.eclipse.wst.server.core.internal.Server.visit(Server.java:2430)
at org.eclipse.wst.server.core.internal.Server$ResourceChangeJob.run(Server.java:188)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


This is essentially an out of memory exception
Go to your oracle workshop for weblogic and go to help and click on help contents

In the search icon now click "Allocating enough memory and solving OutOfMemoryErrors"

YOu will come up with following section

Allocating enough memory and solving OutOfMemoryErrors

By default, Eclipse will allocate up to 256 megabytes of Java heap memory. This should be ample for all typical development tasks. However, depending on the JRE that you are running, the number of additional plug-ins you are using, and the number of files you will be working with, you could conceivably have to increase this amount. Eclipse allows you to pass arguments directly to the Java VM using the -vmargs command line argument, which must follow all other Eclipse specific arguments. Thus, to increase the available heap memory, you would typically use:

eclipse -vmargs -Xmx<memory size>

with the <memory size> value set to greater than "256M" (256 megabytes -- the default).

When using a Sun VM, you may also need to increase the size of the permanent generation memory. The default maximum is 64 megabytes, but more may be needed depending on your plug-in configuration and use. When the VM runs out of permanent generation memory, it may crash or hang during class loading. This failure is less common when using Sun JRE version 1.5.0_07 or greater. The maximum permanent generation size is increased using the -XX:MaxPermSize=<memory size> argument:

eclipse -vmargs -XX:MaxPermSize=<memory size>

This argument may not be available for all VM versions and platforms; consult your VM documentation for more details.

Note that setting memory sizes to be larger than the amount of available physical memory on your machine will cause Java to "thrash" as it copies objects back and forth to virtual memory, which will severely degrade your performance.

=============================================

You need to fine tune your jvm parameters as per your environment

When did a search in internet i got the following post in forum


threadID=847409


I just followed that and deleted the publish0.dat file from following location

C:\OSB\user_projects\workspaces\default\.metadata\.plugins\org.eclipse.wst.server.core\publish

After that i was not getting this issue.


Now choose the business service created and run it on server as shown below



NOw you can test the service

If you will provide the correct input it will fetch u result as true

No comments: