Beruflich Dokumente
Kultur Dokumente
1 JCA
Transport with DB Adapter Tutorial
Oracle Corporation - Proprietary
Use pursuant to
HREF="http://lcsun2/release_center/engprocess/CompanyUsageInstructions.htm
Abstract:
This document describes the steps for using the JCA DB Adapter with OSB
Page 1
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 2 of 48
1.
Introduction............................................................................................................................ 3
2.
Software Requirements.......................................................................................................... 4
3.
Pre-requisites......................................................................................................................... 5
4.
5.
5.2
5.3
5.4
5.4.1
5.4.2
5.5
6.
6.2
6.2.1
6.3
Page 2
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 3 of 48
1. Introduction
This document provides step by step instructions for creating Oracle Service Bus (OSB)
configuration to update and retrieve application data residing in a database.
In the first use case OSB Business Service, with JCA (DB) transport protocol, performs database
operations such as select, insert, update, delete, invoking a stored procedure, or executing any
custom SQL against the database. Hence, OSB acts as a proxy between the client that needs to
perform database operations and the database. Client invokes the proxy service, which uses
Route, Service Callout, or Publish to invoke the JCA business service.
(any) Proxy
Service
Clie
nt
JCA DB
Business
Service
OSB
Select
Insert
Database
Update
Delete
Custom SQL
Stored Procedure
In the second use case OSB Proxy Service, with JCA (DB) transport protocol, polls a database
table for new or changed records. Hence, OSB acts as a proxy between the database and the
backend service that intends to receive changes from the database. Proxy service polls for
database table changes. Proxy service then uses Route, Service Callout, or Publish to propagate
the changes to the backend service.
Database
Poll
New or
Changed
records
in table
JCA DB
Proxy
Service
(any)
Business
Service
Backen
dServic
e
OSB
Page 3
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 4 of 48
2. Software Requirements
JDeveloper 10.1.3.x
Page 4
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 5 of 48
3. Pre-requisites
1. All required software installed
2. Create a backup of JDEV_HOME\integration\lib\DBAdapter.jar
3. Copy OSB_HOME\eclipse\plugins\com.bea.alsb.transports.jca_<version>\DBAdapter.jar
to JDEV_HOME\integration\lib
4. Create a Customer table with following columns in Oracle XE database. This document
assumes the table is created in the system schema and the database username/passwd
is system/welcome1. Use the appropriate database schema and credentials as your
case might be.
Page 5
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 6 of 48
Page 6
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 7 of 48
b. Name: DBContent
Page 7
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 8 of 48
2. Create Project
a. Name: DBProject
Page 8
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 9 of 48
Page 9
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 10 of 48
Page 10
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 11 of 48
i. Step 1 of 4 (Type)
1. Connection Name: DbConnection2
2. Connection Type: Oracle JDBC
Page 11
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 12 of 48
Page 12
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 13 of 48
Page 13
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 14 of 48
Page 14
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 15 of 48
b. Select the connection created in a
c.
Page 15
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 16 of 48
7. Select Table
a. Click Import Tables - Select the appropriate table you want to work with
Page 16
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 17 of 48
i. Provide appropriate Schema and Name filter and click on Query to
query the tables. For e.g. use Customer% as the Name filter and select
the appropriate schema.
ii. Select Customer table that was created earlier using Oracle XE) to
Selected.
10/15/01
Page 18 of 48
8. Step 5 of 7: Relationships
a. Click Next
9. Step 6 of 7: Object Filtering
a. Leave defaults for Object Filtering and Click Next
10. Step 7 of 7: Define Selection Criteria
a. Check Return Single Result Set
b. Click Finish
Page 18
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 19 of 48
5.2 Step 2 - Create OSB Business Service with NonManaged Connection Mode
1. Create OSB configuration project followed by OSB Project
2. Create new business service
a. Select Project->Right click->New->Business Service
d. Specify WSDL location by clicking Browse for WSDL Location and point to the
wsdl file above (DatabaseOutbound.wsdl)
Page 19
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 20 of 48
NOTE: If you did not replace DBAdapter.jar in JDeveloper with the DBAdapter.jar from OSB, the
imported WSDL has an error. You can fix this by deleting the DatabaseOutboundSelect operation
and its corresponding entry under <binding>. See step 3 of Pre-requisites.
If you run into the above error, fix the error as detailed earlier.
e. Next, on the business service select the WSDL port from the WSDL that is
already imported into the workspace.
Page 20
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 21 of 48
f.
You will notice the Transport Protocol defaults to jca and Endpoint URI points to
the JNDI name specified in JDeveloper during Database Adapter configuration
(See figure below).
NOTE: The JNDI name is used by the business service to look up the connection factory if the
Connection mode is Managed.
10/15/01
Page 22 of 48
2. Toplink File property -> Click Browse and select the top link
mappings xml file
(DatabaseOutbound_toplink_mappings.xml).
5. Finish You will see the error message go away and the Non-Managed Connection
Mode.
Page 22
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 23 of 48
5.3 Step 3 - Test OSB Business Service with NonManaged connection mode
1. Start Weblogic server for OSB
2. Create Server connection in Workshop
4. Select Operation as Insert and specify the test data (id must be unique)
Page 23
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 24 of 48
Page 24
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 25 of 48
d. Database Driver: Oracles Driver (Thin XA) versions: 9.0.1, 9.2.0, 10, 11
e. Click Next
NOTE: Remember the JNDI name for the data source. This is required when you create
Connection Factory for the DB adapter.
Page 25
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 26 of 48
Page 26
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 27 of 48
Page 27
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 28 of 48
9. You will see the following message. You are done with configuring the Data Source.
2. Click Customize this table on the right and set number of rows displayed to 100. Click
Apply.
Page 28
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 29 of 48
a. Click on Configuration tab, followed by Outbound Connection Pools tab
b. Select javax.resource.cci.ConnectionFactory and Click New
6. Specify the JNDI Name for outbound connection instance. Next, click Finish
NOTE: The JNDI Name here MUST match the JNDI Name specified in JDeveloper. The JNDI
Name specified in JDeveloper also becomes the Endpoint URI of the business service
(eis/DB/DBConnection2). See Step 5c in Configuring Database Adapter in JDeveloper and Step
3 in Creating business service in OSB.
10/15/01
Page 30 of 48
NOTE: Two important steps: one, update the deployment plan with the changes and two; update
the deployment with the deployment plan (See Step 9 for updating deployment with the
deployment plan).
If you havent yet created a deployment plan for the DB Resource Adapter you will be asked to
create one. In this case, you MUST create the deployment plan and then save the changes to the
deployment plan. If you already created a deployment plan, it is updated with the changes.
b. Click in the Property Value cell for xaDataSourceName, type the JNDI Name of
the Data Source (MyDB) in the text field that appears, and then press ENTER.
NOTE: Hitting ENTER after typing the data source name is critical. Otherwise, the value will
NOT be saved. Tab will NOT work either.
NOTE: The JNDI Name of the Data Source is the JNDI Name specified in Step 3 of the section
on Creating a Data Source.
c.
Select xaDataSourceName (by clicking on the Check box on the left) and click
Save. You will again see the messages to update the deployment with the
content saved in the deployment plan.
Page 30
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 31 of 48
NOTE: In some cases, saving changes to the deployment plan might generate errors. Just
ignore the errors!
Click Update.
d. You will see the following page. Leave the default (Redeploy application using
following deployment plans). Click Next and then Click FINISH
NOTE: If you encounter an error by choosing the second option. Please select the first option
(Update this application in place) and then click Next.
Page 31
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 32 of 48
e. You will see the following message. You are now done with configuring and
updating the DBAdapter connection factory along with the Data Source
Page 32
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 33 of 48
Page 33
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 34 of 48
Page 34
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 35 of 48
Page 35
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 36 of 48
5. Step 2 of 2 Service Connection. If service connection already exists (see Section 5.1)
simply select the service connection (DbConnection2) and skip this step.
a. Click New to create a new connection (or pick a connection if one already exists)
Create Database Connection wizard comes up
i. Step 1 of 4 (Type)
1. Connection Name: DbConnection2
2. Connection Type: Oracle JDBC
ii. Step 2 of 4 (Authentication) provide Database username/passwd
1. Username: system
2. Password: welcome1
iii. Step 3 of 4 (Connection) provide Database connection information
1. Driver: thin
Page 36
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 37 of 48
2. Hostname: localhost
3. JDBC Port: 1521
4. SID: XE
iv. Step 4 of 4 (Testing) - Click Test connection
b. Select the connection created in a
c.
Page 37
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 38 of 48
7. Select Table
a. Click Import Tables - Select the appropriate table you want to work with
i.
Page 38
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 39 of 48
ii.
Select Customer table that was created earlier using Oracle XE) to
Selected.
iii.
Click Next
Page 39
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 40 of 48
8. Step 5 of 9: Relationships
a. Click Next
9. Step 6 of 9: Object Filtering
a. Leave defaults for Object Filtering and Click Next
10. Step 7 of 9: After Read
a. Leave default: Delete the Row(s) that were Read
b. Click Next
Page 40
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 41 of 48
Page 41
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 42 of 48
Page 42
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 43 of 48
Page 43
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 44 of 48
e. Next, on the business service select the WSDL port from the WSDL that is
already imported into the workspace.
f.
You will notice the Transport Protocol defaults to jca and Endpoint URI points to
the JNDI name specified in JDeveloper during Database Adapter configuration
(See figure below).
NOTE: The JNDI name is used by the business service to look up the connection factory if the
Connection mode is Managed.
Page 44
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 45 of 48
b. Specify Toplink file
i. You will notice an error message shown below for the Toplink file
ii. Toplink File property -> Click Browse and select the top link mappings
xml file (DatabaseInbound_toplink_mappings.xml).
5. Finish You will see the error message go away and the Managed Connection Mode.
Page 45
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 46 of 48
NOTE: Make sure logging is turned on at Debug level from the WLS Console. Follow
instructions in the next section (6.2.1.1).
Page 46
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 47 of 48
6.2.1.1 Setting Log level to Debug from WLS Console
From WLS Console
1. Click on Environment->Servers
4. Click Advanced
5. Set Minimum severity to Log, Log File Severity Level and Standard Out - Severity
Level to Debug.
Page 47
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01
Page 48 of 48
3. You must see the following log on the server console. The two records created in the
Customer table by executing the business service (DatabaseOutbound) in earlier
sections will be picked up by the proxy service and logged.
<Apr 25, 2009 12:47:39 PM PDT> <Info> <ALSB Logging> <BEA-000000> <
[PipelinePairNode1, PipelinePairNode1_request, stage1, REQUEST]
<soapenv:Body
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<dat:CustomerCollection xmlns:xsi=http://www.w3.org/2001/XMLSchemainstance
xmlns:dat="http://xmlns.oracle.com/pcbpel/adapter/db/top/DatabaseInboun
d">
<dat:Customer>
<dat:name>Pradeep</dat:name>
<dat:id>1</dat:id>
<dat:address>5470 Great America Pkwy, Santa Clara,
CA</dat:address>
</dat:Customer>
<dat:Customer>
<dat:name>Kiran</dat:name>
<dat:id>2</dat:id>
<dat:address>5470 Great America Pkwy, Santa Clara,
CA</dat:address>
</dat:Customer></dat:CustomerCollection></soapenv:Body>>
4. You can execute the business service (DatabaseOutbound) created earlier multiple
times. This will create multiple records in the Customer table. The proxy service
(DatabaseInbound) will pick up these records at 5 second intervals and log them to the
Page 48
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
Page 49 of 48
server console. Each XML document received by the proxy service will contain
maximum of 5 records as we set the number of rows per XML Document to 5 during
DatabaseInbound adapter configuration in JDeveloper.
NOTE: The db adapter uses one thread (The activation spec property, NumberOfThreads, is
set to 1 by default) to poll the database. This thread is never released to the pool and hence
appears as being stuck to the work manager which can result in stack trace in the system out
and server log like the following:
####<Jun 9, 2009 8:13:08 AM CDT> <Error> <WebLogicServer> <jbayer-lap>
<xbusServer> <[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (selftuning)'> <<WLS Kernel>> <> <> <1244553188484> <BEA-000337> <[STUCK]
ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "610"
seconds working on the request
"weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl@3a11b5c", which is more
than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
Thread-17 "[STUCK] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'"
<alive, in native, suspended, waiting, priority=1, DAEMON> { -- Waiting for notification on:
oracle.tip.adapter.db.InboundWork@3a11a7d[fat lock]
java.lang.Object.wait(Object.java:???)
oracle.tip.adapter.db.InboundWork.run(InboundWork.java:403)
oracle.tip.adapter.db.inbound.InboundWorkWrapper.run(InboundWorkWrapper.java:43)
weblogic.work.ContextWrap.run(ContextWrap.java:39)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerI
mpl.java:516)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:198)
weblogic.work.ExecuteThread.run(ExecuteThread.java:165)
You can ignore this error log. One can configure a new work manager and set Ignore Stuck
Threads to true to not see the stuck thread logged at all. The proxy service can be
configured to use this work manager by setting the Dispatch Policy.
Page 49
Oracle Corporation - PROPRIETARY
Use pursuant to Company Instructions
10/15/01