This article outlines how to set a dynamic endpoint in an OSB HTTP Business Service. The endpoint is retrieved from a routing table which resides in an Oracle 12c database.
Components used for this solution:
- Ubuntu Linux 14.04 64bit
- JDeveloper, running the Quick Start Oracle Fusion Middleware suite
- Oracle Service Bus 12c
- Oracle Weblogic 12c
- OSB Project location:
- Oracle Virtualbox Developer Days image for DB 12c, running:
- Oracle Database 12c
- Oracle SQL Developer 4
- JDeveloper, running the Quick Start Oracle Fusion Middleware suite
This picture shows the running solution in the OSB test console:
Database table preparation
We need a routing table in our schema, I’m using this table setup:
CREATE TABLE "C##JORIS"."ROUTINGTABLE" ( "ROUTE" VARCHAR2(50), "ENDPOINT" VARCHAR2(100) );
Where ROUTE stands for the identifier and ENDPOINT is the HTTP endpoint we try to reach.
I’ve inserted two rows:
Insert into ROUTINGTABLE (ROUTE,ENDPOINT) values ('SalesOrder','http://localhost:7101/salesEndpoint'); Insert into ROUTINGTABLE (ROUTE,ENDPOINT) values ('FinanceReceipt','http://localhost:7101/financeEndpoint');
These two endpoints will point to very simple OSB services which we will create in a moment.
Weblogic configuration: JDBC Data Source
We need to configure a JDBC data source in our Weblogic server, this data source is used by the XQuery function to execute SQL.
Start JDEVeloper, select your integrated Weblogic Server and start it up.
When your domain is started, open the WLS Console:
http://127.0.0.1:7101/console/
Login and open the Data Sources summary:
Navigation in Console: DefaultDomain - Services - Data Sources
Create a new datasource, in my example I use the JNDI name “LocalDB“
When you’re done with the configuration, test the datasource to make sure all is well:
The status message will be green and show a check mark if you’ve configured your data source correctly.
JDeveloper: Oracle Service Bus project
If you import the DBRouting project from here, you should have all the necessary services.
I will only discuss the assign steps which are needed in the DBRouting_v1Pipeline.pipeline.
There are three assign actions:
1.) Assign $route: node-name($body/*[1]) This assign determines our routing key. It is the same key as the first column in the routing table. The XPath here is used to select the name of the first node but you can change this to what you want to route on.
2.) Assign $query: fn:concat("select ENDPOINT from ROUTINGTABLE where ROUTE = '", $route, "'") This assign determines the query which will be executed in the next step. We want to select the ENDPOINT which belongs to the ROUTE which was assigned in step 1.
3.) Assign $query: (fn-bea:execute-sql( xs:string("LocalDB"), xs:string("ENDPOINT"), $query )/*:ENDPOINT)[1] This assign actually executes the SQL query to our database, which is the first argument. The second argument names the re-occurring rows, in this case "ENDPOINT". The thirst argument is the query to execute. The XPath after the execute-sql statement is to make sure we only get one endpoint.
4.) After those assigns, we use place a task “Routing Options” in the HTTP Route node:
We only use the “URI” Routing Option:
$endpoint/text()
This ends the article, if you execute the pipeline you will see the endpoint has become dynamic, it is retreived from the routing table:
Reblogged this on Black Hole Of My Memory.
This is a really nice example. Thank you