Upload
shiva-mca
View
222
Download
0
Embed Size (px)
Citation preview
7/31/2019 11-5 DbToJms
1/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com
With every training session, the presentation used and a
practice document that contains step-by step instructions for
developing the sample is provided.
This document is a demo of those practice documents. Every
document starts with an Aim and then goes on to develop a
project around that. It ends after showing the project in action.
This document comes along with the code that was developed
so that the student can see the final code as well.
Aim
To poll a database and insert the data into a JMS Queue.
Create a new table called Orders in the soademo schema
create table orders (
order_id varchar2(10),
amount number,
description varchar2(100),
processed_flag char(1));
Create a composite DbToJmsDemo with an empty BPEL process (choose Define
Interface later), BPEL
7/31/2019 11-5 DbToJms
2/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com
Open the BPEL component.
Drag a DB adapter on the left Partnerlink swimlane. Click Next on the welcome page.
Give name of the adapter service as PollDB
Click Next. Here you need to select the connection that represents the DB you want to
connect to from JDeveloper. We assume the soademo connection is already created.
Check out 11-2 DBAdapter Demo.docin case you need steps to create it.
7/31/2019 11-5 DbToJms
3/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comFor the JNDI name, Jdev suggests eis/DB/soademo, but as our JNDI is
eis/DB/soademoDatabase (created in 11-1 Setting up Connections for DB Adapter.doc),
modify the JNDI to the above value.
Click Next.
Select the polling option.
7/31/2019 11-5 DbToJms
4/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comSelect the orders table.
Select Order_ID as the primary key.
Reach Step 9 to choose what to do once a row is picked up. Lets say our business
requirement does not want to delete the row, merely indicate that the row has been
7/31/2019 11-5 DbToJms
5/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comprocessed, by setting the PROCESSED_FLAG to Y. In such a case, we make use of what is
called the Logical Delete.
In a Logical delete, after picking a row, the adapter sets a value in the field which it
considers as a filterso next time when the adapter comes looking for new rows, it can
identify this row as it has that flag set.
Select the column as PROCESSED_FLAG,
Read Value as Y, (indicator that this row has been processed)
and Unread Value as N (indicator that this row has not been processed)
Reserved Value
(Optional) Enter a value to indicate that the row is reserved. This setting is useful for environments in which you have multipleadapter instances polling the same table. Each adapter instance must have its own unique reserved value. This enables contention
issues caused by two instances polling the same table to be avoided. During polling, this row is skipped.
Click next. Specify polling frequency as 20
7/31/2019 11-5 DbToJms
6/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com
Click Next till you reach the finish page. Click Finish.
Drag a receive activity and connect it to the PollDBservice we just created.
The Edit Receive dialog opens up that helps to configure the Receive activity.
Name: Receive
Operation: Read (already selected)
Variable: Click the wand and create a new variable
Create Instance: Check this. This indicates that when this Receive receives an input, a
new instance of the BPEL variable is to be created (In all our previous examples, where
7/31/2019 11-5 DbToJms
7/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comwe created Synchronous and Asynchronous processes, we got receive activity by
default. You can see that all those receives had this flag set.)
Click Ok.
Add a JMS Adapter and drop it in the partnerlink swimlane on the right side.
The JMS adapter wizard shall open up. Click Next on the welcome page
1. Give name as EnqJms2. For JMS provider, select Weblogic JMS
7/31/2019 11-5 DbToJms
8/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com3. Select the application server connection that you may have created earlier. This
is required at this point because JDev will try to connect to it and get details
about available queues and topics.
4. On Adapter interface page, select Define From operation and schema (specifiedlater)
5. Select the operation as Produce message, as this JMS Adapter will producemessages
7/31/2019 11-5 DbToJms
9/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com6. Here we select the queue to which we want to send the message. Click on
Browse and select the demoTrainingQueue we created in 11-4 Setting up
Connections for JMS Adapter.doc
7/31/2019 11-5 DbToJms
10/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com
7. Accept other default. Note JDeveloper has filled in the connection factory nameas eis/wls/Queue, which is perfectly fine for us. This is the default connection
factory in Weblogic, which would work for us.
8. Next we need to select the message structure. In this demo, to keep thingsimple, we just want that whatever data is coming from the db should be
enqueued in the queue. So we select the same xsd as being used by the DB
Adapter
9. Click Next and Finish.
7/31/2019 11-5 DbToJms
11/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com
The BPEL shows the adapter now. Add a invoke activity and connect it to the JMS
adapter.
JMS invocation is a one way interaction. Hence there is no output variable.
7/31/2019 11-5 DbToJms
12/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comAdd an Assign activity to copy the OrderCollection from input to input of jms adapter.
As we dont need to iterate over the variable, we are using the assign activity (no need
to use transform).
The BPEL process looks as follows
7/31/2019 11-5 DbToJms
13/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comDeploy it. Test it by inserting a row in the db using a database client.
insert into orders values (1, 100,'First Order', 'N');
Commit the data.
After around 20 seconds, the row will be picked by the DB adapter, and the flag would
be set to Y.
Open the EM to find an instance. Open its trace log
7/31/2019 11-5 DbToJms
14/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comYou can see that the Db adapter PollDB called BPEL which called the JMS Adapter.
Open the BPEL process to see what is the message that has been recd from the DB
adapter
And what is the message sent to the JMS Adapter
7/31/2019 11-5 DbToJms
15/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.comNow we want to confirm that this message is indeed present in the queue.
For that,
1. Open the weblogic console http://localhost:7001/console/2. In the WLS console, on the left navigation bar, expand Services | Messaging and
click on JMS Modules.
3. Click on SOAJMSModule (click on the name, not the checkbox).4. Select demoTrainingQueue5. Select Monitoring Tab6. Select checkbox next to SOAJMSModule!demoTrainingQueue and click Show
messages button
7. Click on link under ID column
7/31/2019 11-5 DbToJms
16/16
Sample Practice Document for Training Evaluation http://soatraining.hpage.com8. You should see the same message as we saw in the BPEL audit trail
9. That confirms that the message is indeed sitting in the queue.