Selectors in WebSphere Integration Developer
A selector is a component that determines which implementation of a component should be invoked at run time based on a set of selection criteria. Every selector will have a default destination. When a selector is invoked it determines which component to invoke based on the date range entries and the selection criteria. A selector can route to any service component at run time.
Creating a Selector
Follow the below steps to create a selector
1. Right click on the module and select New ->Selector.
2. This will open the New Selector window. Enter the name for your selector. I have named it as MySelector. Click on Next.
3. In this page, we need to select the interface for the selector. I have used HelloInterface for this purpose.
4. Click Finish
Configuring the selector
Once we created our selector, we need to configure the selector. Open the selector in selector editor. Follow the below steps to configure the selector.
1. Click on ‘Enter SCA Component’ to configure the Default Component. This will list all the components available. (This will list only components that are having a matching interface). Select the component you want as the default component.
It is very important to provide the default component as an exception will be thrown if no selection criteria matches and no default component present.
2. Click on ‘Add Date selection entry’ icon (the + icon marked in the image).
3. Configure the dates.
My selector is configured to select component2 if the date range is May 01, 2010 to may 04, 2010.
4. Configure the ‘Selection Criteria’. Here we have three options to configure. Current Date, Java, and XPath. This should return a date.
Now add this selector to the assembly diagram and invoke when you want to route a service call dynamically to a component.
For those who want to try this, here is the PI for this example. HelloSelector