Tuesday, December 20, 2011

WPS: Websphere Integration Developer Component : Selector

Selector Introduction :
A selector is a dispatch pattern you use to dynamically determine which implementation of a component to invoke at runtime. Like a rule group, a selector has date range entries, selection criteria, and a default destination. You select a destination in a selector the same as your would for a rule group. That is, when a selector is invoked, it selects a destination using the selection criteria and date range entries. A destination could be any service-oriented component.

You can call a selector from any of your service-oriented components. The selector job is to use dynamic information to determine which component should be called to do the work. The set of destination components is also configurable, allowing you to provide additional destinations at runtime. For example, imagine that at the start of the new year you want to switch your application over to a new subsystem for inventory management. A selector allows you to provide two destinations and indicate that the new one takes effect on January 1. 


Difference between "Rule Group" and "Selector" :

One major difference between a selector and a rule group is that the destination of a selector can be any service component, while a destination in a rule group can be only a rule set or decision table. In other words, a selector can dynamically re-route a service call to any other component at runtime.



Important point need to concentrate on selectors:

The interface operations of the selector must match all of the interface operations of the destinations. In other words, you may not select a destination that has an interface with a different operation name, input, or output than the selector itself. If you try to use a selector where the operation name does not match, then you get a ServiceRuntimeException saying the operation name cannot be resolved. If the input or output does not match (for example, if the destination interface has a different input name or a different input type), then you get a SelectorException saying the component does not support the operation.


For matching the operation of interface we need to use interface maps. To convert from one interface to another by using the interface map as a destination in the selector. Then the selector can invoke the interface map that, in turn, calls the actual service implementation.


Altering existing destinations or adding new destinations:

We can update or modify the destinations of a selector and their corresponding date ranges at runtime without redeploying the original application. Using the WebSphere Process Server administrative console, you can replace an existing service implementation with another one, add a new destination with complete date range information, or remove a destination.

We have three selection criteria to use:
  • Current date
  • XPath expression
  • Visual snippet or Java expression.
If you choose the current date criteria, then the selector selects a destination when the current date falls within the start date and end date of the destination. If you choose the XPath criteria, then you need to further specify the XPath expression that returns a date from the input variable. If you choose the Java expression criteria, you need to provide the Java code, which can be a visual snippet, that returns a Date object from the input variable.

Altering and adding destinations in Admin console:
Suppose that your business environment has evolved and you need to change the default destination for Selector. You use the administrative console to alter the default destination of the selector. After you commit the change, you test the Process again.
Modify the existing destination
  1. You can change selector criteria using the administrative console. In the Servers view, right-click the server and select Run administrative console.
  2. In the Log in page, you have to specify a user name to change anything in the selector, even if you have not enabled security. Type any user name and log in.
  3. In the navigation section, expand Servers, click Application servers, and then click server1.
  4. In the server1 editor page, scroll down to the Business Integration section and click the Selectors link
  5. In the Selectors page, you see all the selectors currently in the system. Click  your <Selector>, which is the one that you created earlier: 
  6. Click the <your selector> link. You see the date entry for this selector. 
  7. To modify the selector, click<need to change selector> the  link. 
  8. To commit the change, select the check box next to the default selector, and then click Commit. You see a message at the top of the administrative console reminding you to select commit to make the changes take effect. 
We are also able to add new destination. After adding new destination we need to deploy that application (contained the target service component) into the server.