Sunday, 25 September 2011

How to publish and subscribe using mediator

This project illustrate the example of publishing and subscribing through mediator. where publish project will invoke the subscribed project and will do the entry in database.
Step1:- Create a new Generic Application with any name
Step 2:- Then create one SOA project with empty Composite for publishing the event.

Step 3:- Drag mediator in component section of composite.xml and select the input customer.xsd
Create one customer.xsd using following entry:-
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://xmlns.oracle.com/ns/Customer"
        xmlns:cust="http://xmlns.oracle.com/ns/Customer"
        attributeFormDefault="qualified" elementFormDefault="qualified">

 <element name="Customer" type="cust:CustomerType"/>
 <complexType name="CustomerType">
    <sequence>
        <element name="customerId" type="string" />
        <element name="Name" type="string" />
        <element name="Age" type="integer" />
<element name="Address" type="string" />
<element name="State" type="string" />
<element name="Country" type="string" />
<element name="City" type="string" />
    </sequence>
</complexType>
</schema>
Step 4:-  Create one event using the same customer.xsd. Click on the create event flash icon

Step 5:- Click on the plus icon to select the customer.xsd


Step 6:- Now right click on the mediator and click the Add Publish Events and then select the .edl file of the created event  in the Event Chooser box.

Step 7:- Open mediator and click on the Transform icon and select the create new mapper radio button. Now  perform one to one mapping as shown below.
Step 8:- Now Create a new SOA project  inside same application with empty composite selected.
Step 9:- Drag n drop the mediator component and select  the subscribed to events template.Then click on the plus icon and select the same .edl  file inside the Event Chooser box.
Here we can notice Run as publisher whether to set it "no" or "yes". If we will set it as yes then all the security policies which are there in the publisher will be applicale to subscriber service as well.

Step 10:- Open mediator and click on the Transform icon and select the create new mapper radio button. Now  perform one to one mapping as shown below.
 
Step 11:- Then drag one BPEL process and choose the template as one way and select the input as customer.xsd.
Step 12:- Then drag one database adapter in Reference section of composite.xml

Step 13:- Enter the JNDI name as same created in my previous blog
Step 14:- select the operation insert as shown below then in next page click on the “Import Table” and then in the Query section dialogue search for the Customer table and Select it.


Step 15:- Then select one primary key as while creating table I didn’t define any primary key so this step will come for the tables where no primary key is defined.
Step 16:- Now drag the wire from mediator to bpel and from BPEL to Database Adapter.
Step 17:- Now open the Mediator Component and drag the transform and then invoke activity.
Step  18:- From invoke activity drag a wire for database adapter to define the partner link. Inside the partner link dialogue Click on the plus icon to create one input variable and select the default value and click ok.

Step 19:- Open the transformation activity and in the source section click the Plus icon and select the input variable and then in the target variable section select the input variable as of invoke activity. Then click on the plus icon in the Mapper File section to create one new xslt file.

Step 20:- Inside xslt file map the sections as below.
Step 21:- After deployment of both the Project. Now select the published one project and click on the test button. Fill all the mandatory field and click on the test web service button below.Now in the response section click on the Launch Flow Trace link and see the flow.
Then After testing the service check whether the data is updated in database table.

Wednesday, 21 September 2011

How to create DB DataSource and JNDI Name

Why to Create DataSource and JNDI Name:- JNDI name is the referenece to the repository or registry where the database connection detail and physical server address is present.

How to Create DataSource and JNDI Name:- To create a data source:
1. Navigate to http://servername:portnumber/console.
2. Use the required credentials to open the Home page.

3. Under Domain Structure, select Services then click Data Sources.
The Summary of JDBC Data Sources page is displayed.


4. Click New and then Generic Data Store. The Create a New JDBC Data Source page is displayed.


5. Enter the following values for the properties to be used to identify your new JDBC
data source: Name: demoDatabase JNDI Name: jdbc/demoDatabase Database Type: Oracle   

            
6. Retain the default value for Database driver in next  page
7. Click Next. The Create a New JDBC Data Source Transaction Options page is
displayed.
8. Click Next. The Create a New JDBC Data Source Connection Properties page is
displayed. Enter the database  connection properties in the Connection Properties page, and then click
Next.
The Create a New JDBC Data Source Test Database Connection page is displayed.



9. Click Test Configuration to test the database availability and the connection
properties you provided. A message stating that the Connection test succeeded is
displayed at the top of the Create a New JDBC Data Source Test Database
Connection page.
10. Click Next. The Create a New JDBC Data Source Select Targets page is displayed.
11. Select a target, and then click Finish. You have created a data source.



The Summary of JDBC Data Sources page is displayed. This page summarizes the
All changes have been activated. No restarted required for the changes to take effect

Creating a Connection Pool:-
1. Under Domain Structure, click Deployments.The Summary of Deployments page is displayed.
2. Click the DbAdapter name from the Deployments list.
The Settings for DbAdapter  page is displayed.
3. Click Configuration tab, and then click Outbound Connection Pools tab.
The Outbound Connection Pool Configuration Table is displayed.


4. Click New.
5. Select javax.resource.cci.ConnectionFactory, and then click Next.
The Create a New Outbound Connection page is displayed.
6. In the JNDI Name: field, enter eis/DB/demoDatabase. Then click Finish.
The JNDI name specified in this step must match the value with database connection that need to create in jDeveloper.
7. Click on the newly created OutboundConnection.In the Properties field, enter the value for xADataSourceName as jdbc/demoDatabase which was created previously. press Enter in the
keyboard to save the changes.
8 Under Domain Structure, click Deployments.The Summary of Deployments is displayed.
9 Do either of the following steps:
a. Select the DbAdapter check box, and then click Update.The Update Application Assistant page is displayed.
b. Select Redeploy this application, and then click Finish.
Adding  a new value for the outbound connection pool, then no re-start required for the Managed server or the Admin server. However, editing is done on any property of an existing connection pool, then re-start of the server  is required