Showing posts with label DynamicRouting. Show all posts
Showing posts with label DynamicRouting. Show all posts

Wednesday, July 29, 2020

12c OSB - Dynamic routing part1 with Proxy services

Here, we are going to showcase a simple way of how can we do dynamic routing from your OSB pipeline flow to other proxy services.

We will mock the response from those proxy services just to showcase that how the control comes into a particular proxy based on dynamic routing.

Implementation steps:
Step1: Create a New OSB project (New ⇾ Project ⇾ Service Bus Project ⇾ Give project Name DynamicRoutingSBProject)

Step2: On project ⇾ New ⇾ From galary ⇾ XML Schema ⇾ File name Employee.xsd. and target namespace if you can change.

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org/Employee"
            targetNamespace="http://www.example.org/Employee" elementFormDefault="qualified">
  <xsd:element name="Employee">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="name" type="xsd:string"/>
        <xsd:element name="department" type="xsd:string"/>
        <xsd:element name="URL" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
    <xsd:element name="EmployeeResp">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="output" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Step 3 : Create Main proxy service. Go to the servicebus.sboverview and In proxy services lane, Insert Transports ⇾ HTTP ⇾ Provide Proxy service name as ProxyServiceMain and pipeline as ProxyServiceMainPipeline ⇾ Next ⇾ Select ⇾ Messaging and Request as XML and choose the created XSD for request and Response ⇾ Next ⇾ Finish. Main Proxy and pipeline done.

Step4 : Now create 2 proxy services ProxyService1 and ProxyService2. In proxy services lane, Insert Transports ⇾ HTTP ⇾ Provide Proxy service name as ProxyService1 and ProxyService1 and pipeline as ProxyService1Pipeline and ProxyService2Pipeline⇾ Next ⇾ Select ⇾Any XML⇾ Next ⇾ Finish. 

Step5: Go to the ProxyService1pipeline  and ProxyService2pipeline and drag and drop pipeline pair node and in the response stage, insert a replace activity and sending a response as below snaps.






step6 : Go to the main proxy pipeline and take a pipeline pair node and take 1st assign and add the routing rules xml into varURLMap variable.
<routing>
<row>
<department>IT</department>
<endpoint>DynamicRoutingSBProject/ProxyService1</endpoint>
</row>
<row>
<department>Sales</department>
<endpoint>DynamicRoutingSBProject/ProxyService2</endpoint>
</row>
</routing>

step7: Take another variable varDept and store the department from the proxy requst.

Step8 : Take another variable varRoute and store the following:
<ctx:route>
<ctx:service isProxy="true">{$varURLMap/*:row[department=$varDept]/*:endpoint}</ctx:service>
</ctx:route>

Note: 'isProxy' will be true only and only if we are routing to some or the other proxy service only.
In case you want to route to business service(s), 'isProxy' will be false.

Step9: Drag and drop Dynamic routing activity and provide Service =$varRoute.


Now test it. If you give department as IT. then it will route to ProxyService1 an provide the response what we configured in proxyservice1pipeline.


Featured Post

OIC - Enrichment Service in Oracle Integration Cloud (OIC)

Enrichment Service in Oracle Integration Cloud (OIC) The Enrichment Service in Oracle Integration Cloud (OIC) allows you to enhance the data...