Dynamic Routing Rules in Oracle Mediator 12c

Dynamic Routing rules has become very simple with 12c. A number of Request properties can be overridden. Let us look at a simple example for overriding the endpoint using DVM and Business Rule. This might be a good way to manage endpoints external to the mediator itself as both DVMs and Business Rules can be changed at runtime.

Use Case: There are two providers viz. Provider1 and Provider2 both of which are based on the same abstract WSDL. The Mediator has to invoke Provider1 or Provider2 based on the input. The logic for this mapping is very simple.

  1. If the input is Provider1 then invoke Provider1
  2. If the input is Provider2, invoke Provider2
  3. For anything else, invoke Provider1 (Implemented only for the Business Rules sample)

Lets begin..

Dynamic Routing using DVM

  1. Create any abstract WSDL of your choice or download from here Abstract WSDL. The WSDL defines a Sync Req Res portType and the schema contains a simple Request with an input and a single result
  2. Now, create two Providers based on the wsdl and call it Provider1 and Provider2. Deploy it and note their endpoints. You can download the providers here if you want Providers. The Providers basically insert a “Hello from Provider” message into the response.
  3. Now, create the composite where we will implement the Dynamic Routing via mediator. The composite contains a mediator(based on the Abstract WSDL we created earlier), a Service client and a Reference which points to the Provider1. DynamicRoutingComposite
  4. Open the mediator and click on Assign Values and map the inputAssignValuesScreen Shot 2015-07-20 at 8.22.54 pm
  5. Now, click on Override. This will allow you to define a DVM that will be used for the routing. Enter the Name and Location of the DVM and then Set the values as shown in the screenshot below Screen Shot 2015-07-20 at 8.30.21 pm
  6. Here we basucally do two things
    1. Set the Value Expression and Key Domain. This allows the request input to be used as a key in the DVM
    2. Set the feature we want to override. For this case, we override only the EndpointURI. For values that are not to be overidden, set it to <<Not Override>>
  7. When we chose DVM for the routing, JDeveloper creates the DVM and auto-populates the rows. For our use case, we require only the Keys and the endpointURIs (which we have mentioned as the value to be overridden) Screen_Shot_2015-07-20_at_8_36_00_pm
  8. This completes the build. You can download the Composite from here DynamicRouting with DVM
  9. Lets test the composite quickly, here are the results.  Screen_Shot_2015-07-20_at_8_45_09_pmScreen_Shot_2015-07-20_at_8_44_53_pm

Dynamic Routing using Business Rules

  1. The Steps for using Business Rules with mediator routing is same except that in instead of choosing Domain Value Maps, choose Decision Service and click on the + button to create one. Screen Shot 2015-07-20 at 8.51.55 pm
  2. JDeveloper will create the Decision Service with a Decision Table. Screen_Shot_2015-07-20_at_8_54_17_pm
  3. Now, edit the Decision Table as the following screenshot. Similar to the DVM routing rule, there are two things we do here
    1. Set the condition which checks the input value i.e. request(The only difference is that here I have added the condition that when the value is nether Provider1 or Provider2, it should be treated as Provider1).
    2. Set values for the EndpointURI(specified by ServiceBindingInfo and everything else we set to null i.e. not override. Screen_Shot_2015-07-20_at_9_02_29_pm
  4. Deploy the Composite. You can download the entire composite from here. DynamicRouting Business Rules
  5. The Test cases are same. I only provide the one additional test case where the input is Provider3.Screen_Shot_2015-07-20_at_9_13_10_pm

Full Source: The full source for the Project can be downloaded from here Full Source Code

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: