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.
- If the input is Provider1 then invoke Provider1
- If the input is Provider2, invoke Provider2
- For anything else, invoke Provider1 (Implemented only for the Business Rules sample)
Dynamic Routing using DVM
- 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
- 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.
- 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.
- Open the mediator and click on Assign Values and map the input
- 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
- Here we basucally do two things
- Set the Value Expression and Key Domain. This allows the request input to be used as a key in the DVM
- 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>>
- 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)
- This completes the build. You can download the Composite from here DynamicRouting with DVM
- Lets test the composite quickly, here are the results.
Dynamic Routing using Business Rules
- 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.
- JDeveloper will create the Decision Service with a Decision Table.
- Now, edit the Decision Table as the following screenshot. Similar to the DVM routing rule, there are two things we do here
- 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).
- Set values for the EndpointURI(specified by ServiceBindingInfo and everything else we set to null i.e. not override.
- Deploy the Composite. You can download the entire composite from here. DynamicRouting Business Rules
- The Test cases are same. I only provide the one additional test case where the input is Provider3.
Full Source: The full source for the Project can be downloaded from here Full Source Code