wid lecture

Upload: venkata-narasimha-akella

Post on 08-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 WID Lecture

    1/22

    Page 1 of 22

    WebSphere Integration Developer Version 6.0.2

    Lecture 1,2

    Lecture 1 - Interface mapping, business object mapping, and human

    tasks

    Introduction

    In this article, well look at more of the supporting features in WebSphere Integration Developer.

    One challenge is sure to arise in a service-oriented application: what happens when two services need to workwell together, but they dont understand how to communicate? Early on in this series, we explained that acomponent implementation calls another component using a reference. We pointed out that the interface of a

    reference must match the interface of the component to which it is wired. However, what if the interfaces dontmatch?

    For example, suppose a references interface has a retrieveCustomerData operation and the component towhich you want to wire that reference has an interface with a getCustomerData operation. Looking a bit deeper,the problem compounds if one of the business objects that the getCustomerData operation returns has a fieldcalled custId, but the retrieveCustomerData operation expects the return parameter name to be just id.

    In a small, localized application, the solution is quick: just change the interfaces so that everything matches.In practice though, your business partners often provide interfaces for services that you use, for example WebService Definition Language (WSDL) files, so changing them is out of your control. Even if you could changethe interface, it might break existing consumers of the service. On the client side, changing the interface of thereference might also be out of the question because you would have to change the implementation to usedifferent names. WebSphere Integration Developer makes it very easy to get around this obstacle: it lets youcreate interface and business object maps.

    If youve ever tried to wire a reference to a component where there was a mismatch between the interfaces, adialog box would have opened asking if you wish to create an interface map. This article will show you howeasy it is to create different types of maps.

    In addition to mapping, we will also explore human tasks. Automating business processes is essential to acompanys efficiency and effectiveness. However, quite often, a business process still requires humanintervention. For example, a bank loan approval process might require an experienced loan specialist toevaluate borderline loan applications. A retail store process that automatically re-orders inventory when theinventory level falls below a certain limit might require the store manager to approve all the orders with a largedollar value. Human intervention might also be required in dealing with exceptional cases during a businessprocess. In situations similar to these, you can use a human task component when designing integrationapplications

    A human task, as the name suggests, is a task that involves a human. It is a component in a module just like

    the others we have seen, such as a business process, business state machine or business rules. You mightwonder what the difference is between the staff activity in WebSphere Studio Application Developer IntegrationEdition, Version 5.1 and a human task component. You could only use a staff activity from within a businessprocess, and its functionality was limited. For example, a staff activity did not allow escalations (an automaticreassigning of a task that has not been claimed or completed). In Version 6, a human task is a first-classcomponent and is no longer restricted to being an internal activity in a business process. Furthermore, ahuman task component not only allows the computer to interact with a human, but it also allows human-to-computer and human-to-human interactions.

    After we explain human tasks, interface maps, and business object maps, we will let you get your hands dirtyagain, this time by creating a human task with a mapping that enables two components with differentinterfaces to communicate with each other.

  • 8/7/2019 WID Lecture

    2/22

    Page 2 of 22

    In the following sections, you will learn how to perform more tasks using WebSphere Integration Developer:

    Mapping interfaces and parameters

    Mapping business objects

    Implementing components as human tasks

    Creating your own human tasks

    Creating your own interface and business object maps

    Interface maps

    An interface map sits between two components with different interfaces and lets you say, "When I callOperationX of InterfaceA, send the request to OperationY of InterfaceB." Of course, the parameters of bothoperations might not match either. So, an interface map also lets you say, "Pass the value of Parameter1 ofOperationX to Parameter2 of OperationY." If the parameters of both operations are of the same type, thenthats all there is to an interface map. Often, however, the parameter types are different. In the ParameterMapping section, we'll show you the various mapping tools that help you when parameter types are different.

    For example, suppose an order-processing component needs to call the shipOrder operation of a shippingcomponent. However, the interface for the shipping component has an operation called ship, and bothoperations have different names for their parameters. Figure 1 shows two interfaces: one containing theshipOrder operation and the other containing the ship operation. Notice that the parameter names of eachoperation are different. Figure 2 shows you an interface map that resolves these differences.

    Figure 1. Two operations that require a map

  • 8/7/2019 WID Lecture

    3/22

    Page 3 of 22

    Figure 2. An interface map

    At the top of the interface mapping editor, you connect operations of the interface on the left to operations ofthe interface on the right. For the operation parameters, the bottom of the editor shows mappings that youcreate by connecting the respective parameters (inputs and outputs) of each operation. A move mapping typeis created by default when you connect parameters. We'll discuss the different types of parameter mappingsshortly.

    The map type is pointed at one end to indicate the direction of the mapping. For example, the upper moveindicates that the orderInfo input value gets passed to the order parameter, while the lower move indicatesthat the value of the output parameter ok gets passed to the shipped parameter.

    There are two ways to create an interface map. The first way is to use the interface map wizard ( File -NewInterfaceMap), as Figure 3 shows. With this method, you select or create the source and targetinterfaces. The source interface is the interface that belongs to a reference of a component and the targetinterface belongs to the component being called from the reference.

    Figure 3. New Interface Map wizard

    The other way to create an interface map is to wire a reference of one component to another component. Youuse this method when the reference and component have different interfaces. The assembly editor asks you ifyou want to create an interface mapping between the source and target nodes (the nodes being the referenceand the component, respectively).

  • 8/7/2019 WID Lecture

    4/22

    Page 4 of 22

    Operation mapping

    After you have created an interface map, you need to define the mapping between the interface operations, asyou can see at the top of Figure 4. You create a mapping by clicking next to an operation on the left anddragging the end of the connection to the corresponding interface on the right. When you select the connectionbetween two operations, the parameter mappings display in the lower half of the editor. The next step is to

    draw connections between equivalent parameters.

    Figure 4. Creating an interface map

    Parameter mapping

    After you have specified which operation of one interface corresponds to which operation of another interface,you need to map the operation parameters. As with an operation map, you connect inputs and outputs of oneoperation to the corresponding inputs and outputs of another operation. However, mapping correspondingoperations requires only a line between them, while mapping data can be more complex. If the parametertypes match, then you just connect the corresponding inputs or outputs as Figure 4 shows. Often, the typeswill not match, but the business object map editor helps you to map the data as we'll show you in the Businessobject maps section.

    First, let's look at how you create a parameter mapping. For input parameter mappings, you drag a connectionfrom an input parameter on the left to the corresponding input parameter on the right. For output parametermappings, you drag the connection from right to left. After creating the mapping, the next step is to specifythe type of map. You can select from a list of mapping types in the Description tab of the Properties view. Inthe sections that follow, we will explain the five types of mappings:

    Move

    Extract

    Map

    Assign

    Java

  • 8/7/2019 WID Lecture

    5/22

    Page 5 of 22

    Move

    By default, when you connect two parameters, the type of map that is created is called a move parametermapping. In the earlier example, we showed a move parameter mapping. With a move parameter mapping,the exact value of a source parameter will pass as-is to a target parameter. The type of each parameter,whether it is a string or a business object, must be the same. Move mapping types are 1-to-many, whichmeans you can map a source parameter to one or more target parameters.

    Extract

    Sometimes, a target parameter requires only some of the data from the source parameter. In this case, youcan use an extract. An extract parameter mapping takes the value of a business object's attribute, which couldbe a simple type or a nested business object, and puts it into the target. Figure 5 shows a variation on theearlier example where the ship operation has two input parameters whose types are Item and Address. TheOrder business object used in the shipOrder operation contains attributes with the same Item and Address typesas you see in the XPath tree in the bottom of the figure. The Properties view shows an XPath expression thatselects the item attribute from orderInfo. When you use the mapping, the values for orderInfo.item are passedto the item parameter. We use a second extract with orderInfo as the source to transfer the orderInfo.addressvalue to the address parameter.

    Figure 5. An extract parameter mapping

    Map

    If the parameter types don't match, you use a map instead of a move. A map parameter mapping lets youreconcile different business object parameters. There are numerous mismatches that can exist between twobusiness objects, even though each one contains information that the other needs. A mismatch could occurbecause the attributes of one business object are in a different order and have different names than theattributes of the other business object. Or a mismatch could get quite complex: one business object mightrepresent a name with three attributes (salutation, firstName, and lastName), while another might represent aname using just one attribute that is meant to hold a comma delimited string. You might even have multiplebusiness objects whose individual parts need to be mapped to or from one business object. When you use amap, you specify a business object map that maps the attributes of one business object to another. Thesection on business object maps describes this mapping type in detail.

  • 8/7/2019 WID Lecture

    6/22

    Page 6 of 22

    Assign

    You can also map a constant value to a target parameter. An assign parameter mapping lets you specify aconstant value to put in a target parameter. This type of mapping has only a target. Therefore, to create anassign mapping, you can't create a connection between two parameters and change the type to assign(because a double-ended connection can't be an assign mapping). So, to create an assign mapping, right-clicka target parameter (an input on the right or an output on the left) and select Create Transform - Assign. In

    the Properties view, you can enter the constant value.

    You should use an assign mapping when a target operation contains a parameter that is not present in thesource operation. The extra parameter might no longer be in use. Because a map requires all targets to have amapping, you can assign some default value to the extra parameter. The extra parameter could also alwayshave the same value when called from your module. For example, Figure 6 shows a ship operation with anorderType parameter that is not present in the shipOrder operation. The assign mapping passes a value ofexpress each time the map is used.

    Figure 6. An assign parameter mapping

    Java parameter mapping

    For maps that require custom logic, you can use a Java parameter mapping. A Java parameter mapping letsyou write arbitrary Java code to transform one object to another. In the Details section of the Properties view,you specify the name of the class, which must extend the Java classcom.ibm.wbiserverspi.mediation.JavaMediation . The JavaMediation class contains a mediate method that takesan object as input, which is the value that is to be mapped, and returns an object that is the transformedvalue.

    Business object mapsIn the parameter mapping examples, you saw how to map the parameters between operations using mappingtypes such as move and extract. In this section, we'll look at what happens when the parameter types are notthe same and you can't use a parameter map. As we noted earlier, the map parameter mapping type requiresyou to specify a business object map that handles the mapping between the attributes of two business objects.In this section, we show you what business object maps are and how to use them.

  • 8/7/2019 WID Lecture

    7/22

    Page 7 of 22

    Transform types

    Mapping business object attributes is similar to mapping parameters: you connect source attributes to targetattributes. Mapping attributes is also called transforming attributes. Because transforming attributes generallyrequires more flexibility than mapping parameters, there are more transform types. The next sections willcover the following transform types:

    Move

    Submap

    Extract

    Assign

    Custom

    Join

    Relationship

    Move

    A move transform is analogous to the move parameter mapping type. It assigns the value of a primitive-typeattribute in the source business object to a primitive-type attribute in a target business object. You can mapone primitive-type attribute, such as a string, to another, such as an integer. Keep in mind that if the datacannot be converted at runtime, you get an exception. For example, if the string "123a" is mapped to aninteger, you will see a NumberFormatException in the server log. Furthermore, unlike a move parametermapping, you cannot map complex types using a move transform. For mapping between business objects, youneed a submap, as we will describe shortly.

    Figure 7. A move transform

    Submap

    A submap is another business object map that you use to transform one business object to another. Forexample, in Figure 8, the PO business object contains an Address business object. On the right, in Order, thereis also an Address in the Customer business object. The Details tab shows that the Address business object mapmaps Order/customer/address to PO/shipTo. Because the source and target have the same type, Address, thesubmap consists only of move transforms between parameters with Address attributes. This might remind youof the extract parameter mapping earlier. If the interface containing PO had two parameters, invoiceNum andshipTo, instead of just one PO parameter, we could have used an extract parameter mapping here.

  • 8/7/2019 WID Lecture

    8/22

    Page 8 of 22

    Figure 8. A submap transform

    Extract

    An extract transform is a bit different than its parameter mapping counterpart because its source attributemust be a string. You use the extract transform to extract parts of a string and assign those parts to another

    string, or to any other primitive type, with the caveat we mentioned in the move transform section.

    For example, Figure 9 shows two extracts that separate the first name and last name from a string with theformat lastname, firstname. The details for the second extract show that the part of the name string up to thefirst comma gets copied to the lastName attribute of the Person object. The substring index determines whichsection of the string, starting from 0, to use. Therefore, the firstName extract contains the same details as thelastName extract, except that the substring index is 1 (It uses the second part of the string: the charactersbetween the first comma and the second). If the value of the name attribute is "Smith, Joe", then firstName willget a value of "Joe" and lastName will get "Smith".

  • 8/7/2019 WID Lecture

    9/22

    Page 9 of 22

    Figure 9: An extract transform

    Join

    Ajoin transform combines the values of two or more source attributes and copies them to a target attribute.The target of a join transform must be a string. You can think of a join transform as the inverse of the extracttransform because it takes a set of string inputs (or any other primitive type, which will be converted to astring), and joins them into one string, optionally separated by delimiter.

    In the extract transform example, we showed mapping a comma-delimited string to separate first and lastname attributes. Often you need to map both ways. Figure 10 shows you how to map back from the Personbusiness object to the emp business object. IffirstName contains the value "Joe" and lastName contains "Smith",then the name attribute gets the value "Joe,Smith" because firstName has a delimiter set to a comma.

    You can check how the join concatenates the values by looking at the example at the bottom of the Detailstab. Keep in mind that the delimeter can consist of multiple characters. The Prefix and Postfix fields let youadd strings to add a prefix to and append the resulting joined string. You can also use the Reorder icons tochange the order in which the attributes are concatenated.

  • 8/7/2019 WID Lecture

    10/22

    Page 10 of 22

    Figure 10: A join transform

    Assign

    An assign transform sets a constant value to a target attribute. Figure 11 shows an assign transform that setsthe prefix attribute ofPerson to null.

    Figure 11: An assign transform

    Custom, custom assign, and custom callout

    To write Java code to specify the mapping logic between a source and a target attribute, you use a customtransform. If there is no source attribute, then you use a custom assign transform, which is similar to an

  • 8/7/2019 WID Lecture

    11/22

    Page 11 of 22

    assign transform, except that you use Java code to compute the assigned value. If there is no target attribute,then you use a custom callout transform, to initialize values.

    Relationship

    You use a relationship transform when the same data has different names or different identities. Therelationship transform is different than other mappings because with other mappings we are interested inconnecting different attribute names or business objects that refer to the same data. A relationship transformgoes one step further by also handling cases where the data is different but has the same meaning or refers tothe same thing.

    There are two types of relationship transforms: dynamic and static. A static relationship correlates differentvalues that refer to the same thing. These types of values never, or rarely, change. A typical example is astate or province name: one system might use 2-letter designations such as ON, while another might uselonger abbreviations such as Ont., and still another, full names such as Ontario.

    When you map data from one attribute to another with a static relationship, you can also transform the dataaccording to the table you create with the relationship editor. For example when the province attribute of onebusiness object that has a value of "ON" is mapped to another business object attribute, the value assignedcould be "Ontario."

    You use a dynamic relationship to correlate data based on primary keys. For example, a product in a storemight have one identifier on the inventory tracking system and another on the suppliers system. Your systemmight have an identifier in a generic business object that not only contains the same data as identifiers inother business objects, but something needs to keep track of which data is actually the same. For example,when itemNumber, which has a value of "123", is mapped to productCode (in a business object used in thesupplier's interface), the value of "a234" might need to be inserted so that the correct item will be orderedfrom the suppliers system. The relationship manager on WebSphere Process Server takes care of this.

    The two relationship articles, WebSphere Process Server relationship service, Parts 1 and 2, listed in thereferences section, take you through exercises that clarify how you would use both types of relationshiptransforms.

    Variables

    To store data that you want to reuse, you create variables. A variable can be a source and a target for each ofthe transform types described earlier. For example, if you have a value that you want to assign to manytargets, you can use an assign to set a value to the variable, then use a move transform from that variable tomultiple attributes.

    As an example, Figure 12 shows a map with a variable named code that is populated with the value oforderInfo.code. This value is used in orderItems.code and shipTo.code. Note that for this to work, the executionorder (indicated by the number on the left of the transform type) of the assign to the variable must be lowerthan the targets to which the variable is mapped. Otherwise, the variable will be uninitialized when it is used.

  • 8/7/2019 WID Lecture

    12/22

    Page 12 of 22

    Figure 12: Using variables

    Human tasks

    WebSphere Integration Developer helps you develop solutions that allow different computer applications towork with each other. However, developing an integrated information system often involves supportinginteractions with humans.

    Human involvement takes several forms. For example, a person might be required to initiate a processinstance that can then proceed on its own. A person might be required to deal with exceptional cases that thelogic built into the application cannot handle, perhaps because the case is considered too complex or special. Acase might also require human intervention because the normal processing has failed for some reason.

    Having decided that a process should involve a human, developers are faced with the decision of how to

    implement this functionality. WebSphere Integration Developer provides a human task component, whichgreatly simplifies the work required to support human interaction with an SCA application.

    A scenario for the involvement of a human in a service-oriented application is a process that requires adecision from a person to approve an order before proceeding, as shown in Figure 13.

    Figure 13: A decision made by a human within a process

    Consider some of the requirements for the scenario:

    A mechanism to get data to and from the user

  • 8/7/2019 WID Lecture

    13/22

    Page 13 of 22

    To be asynchronous and long running (because the human might not be able to respond immediately)

    An interface to enable the interaction. Since more than one process instance might require humaninvolvement at any one time, the user interface needs to show the processes waiting for input and it needsto provide the details of a selected task

    A way to verify that the user has the right to perform the task

    A human task satisfies these requirements, and provides a stand-alone component just like business processesand business state machines. It communicates with other components using interfaces and business objects.Figure 14 shows a human task component called ApprovalHumanTask, that the process shown in Figure 13 calls.

    Figure 14: A human task component

    However, human task components are unique because they support only a single interface that might haveonly a single operation. This reflects the fact that a human task defines only a single interaction, multipleinteractions require multiple human tasks. Let's consider a file folder analogy. The folder contains information

    required to identify and complete the task. The user adds any required comments or data to the contents ofthe folder and returns it.

    Human tasks are inherently asynchronous and long running. It would not be realistic to assume that a humancan process all requests immediately. Rather, tasks requiring human intervention must be managed on aqueue for completion when a human is available. Using our file folder analogy, imagine an inbox with a stackof file folders waiting to be processed. Each will remain in the inbox until it can be processed and re-filed.

    Types of human tasks

    There are three types of human tasks, which we will look at in the next sections:

    Participating

    Originating

    Pure

    Participating human tasks

    In a participating human task, a component, such as the OrderProcessing component in Figure 14, calls ahuman task component. In other words, the human task participates in getting work done.

    Figure 15: A participating human task

    Originating human tasks

    An originating human taskcalls another component. Instead of being assigned work, it begins the process ofgetting work done. An originating human task represents a human requesting something rather than fulfilling arequest.

  • 8/7/2019 WID Lecture

    14/22

    Page 14 of 22

    Figure 16: An originating human task

    Pure human tasks

    Apure human taskis similar to an originating human task because a human requests it. However, with a purehuman task, another human rather than a computer application fulfills the service request. In this case, theapplication mediates interaction between humans.

    Figure 17: A pure human task

    Creating a human task

    To add a human task to a module, select File - New - Human Task. The New Human Task wizard lets youspecify a name and container for the task. The second and third pages of the wizard let you indicate the kindof task you want to create and specify its interface. The human task editor then opens for the newly createdtask.

    Now let's look at how you can configure human tasks.

    Staff settings roles

    As you can imagine, you need a way to associate a human task with a specific person or any member of agroup of people who is qualified and permitted to complete the task. You can also assign roles (for example,Potential Owner, Reader) to a human task so that specific access rights can be granted.

  • 8/7/2019 WID Lecture

    15/22

    Page 15 of 22

    Figure 18: Staff settings

    Client settings

    WebSphere Process Server includes a built-in Web-based user interface, the Business Process Choreographer(BPC) Explorer, for human tasks. This interface is suitable for testing and administration purposes, but it is notmeant to be used as a user interface for human tasks in a real-world application. The developer should developa custom user interface to display the contents of the task and allow the user to work on it.

    WebSphere Integration Developer includes built-in support for two kinds of user interface implementations, butyou can add others via extensions. The supported user interface types are JSPs and portlets. In the clientsettings area of the editor, you can select the kind of interface to supply and, in the details area, specify wherethe interface implementation is located. References at the end of the article offer specific details aboutimplementing a custom interface.

    Figure 19: Client settings

    Escalation settings

    When a user claims a task, the intention is to complete it within a reasonable period of time. However, thereare often circumstances that prevent timely completion. For example, the user might be waiting for additionalmaterial before making a decision. What happens if the process that is calling the task might require aresponse within a certain period? In response to such cases, a human task allows the developer to specify anescalation to occur if a task is not claimed or completed within a certain period.

    When a human task is invoked, it is either in the ready(not yet claimed) or the claimedstate. Escalations arelike timers in a business state machine. When a task has entered a state, the escalation will trigger and carry

  • 8/7/2019 WID Lecture

    16/22

    Page 16 of 22

    out its specified action if the task does not leave the state by the time specified in the escalation. You canspecify a series of escalations where each one is triggered as soon as a duration expires and while the taskremains in the particular state.

    Another state for a human task is the subtaskstate. When a user claims a task, the user can delegate aportion of task to another user, which puts the human task in the subtask state. You can add escalations to thesubtask state to ensure that this portion of the task is completed so that the overall task can proceed.

    Figure 20 shows a human task that will send a notification if the task is not finished within two hours. The

    Verb tab contains the name of the person who will be notified if the escalation occurs. In the following sectionswe will explore escalations in the application you will build. The references at the end of the article also offermore information on using the Human Task manager and developing your own client to assign subtasks andrespond to escalations.

    Figure 20: Escalation settings

    Inline human tasks

    Rather than existing as an individual component, an inline human task, which is another form of a participatinghuman task, is defined inside a business process. It is only accessible from within the process. One advantageof this human task is that it can access the context of the process (for example, processes variables), allowingmultiple human tasks within the process to share information.

    Figure 21: An inline human task

  • 8/7/2019 WID Lecture

    17/22

    Page 17 of 22

    Lecture 2 - Selector

    Introduction

    In the previous articles we looked at each of the service-oriented component types that you can build withWebSphere Integration Developer, including business state machines, business processes, and human tasks.

    We toured the overall programming model and various supporting tools, such as visual snippets and mapping.We also explored the on-demand capabilities that WebSphere Integration Developer provides, such as howusing business rules helps you make your running application dynamic and flexible so that you can handlechanging business conditions without having to redeploy the application.

    Simply put, you identify your key business decisions, create a business rule for the decision, and ultimatelymake it configurable at runtime. For example, if the client is one of your best, perhaps you want to give him orher a 20% discount. Maybe, on a particularly grumpy day, you want to lower that discount to 10%. Businessrules in WebSphere Integration Developer make it easy to be grumpy, or adjust other, more pressing businessneeds.

    The next piece of the on-demand puzzle is the selector.

    What is a selector?

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

    One major difference between a selector and a rule group is that the destination of a selector can be anyservice 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.

    You can call a selector from any of your service-oriented components. The selectors job is to use dynamicinformation to determine which component should be called to do the work. The set of destination componentsis also configurable, allowing you to provide additional destinations at runtime. For example, imagine that atthe start of the new year (after all the confetti has been cleaned up) you want to switch your application over

    to a new subsystem for inventory management. A selector allows you to provide two destinations and indicatethat the new one takes effect on January 1.

    Lets take the following business process shown in Figure 1 as an example. This business process is forapproving a loan application and has only two steps:

    Step 1: Invoke a service to check for the credit rating.

    Step 2: Invoke another service to determine if the loan should be approved.

  • 8/7/2019 WID Lecture

    18/22

    Page 18 of 22

    Figure 1: Business process calling a partner service

    The two invoke activities are hard-wired to target implementations in the assembly diagram. Lets say thebusiness process invokes the low cost credit-checking service that Company A provides. What happens if theservice that Company A provides becomes unavailable during a certain period?

    Such a situation is where selectors can help. As mentioned, selectors can decide which implementation to

    invoke. In the next section, you will see how using selectors can let you change the destination of the servicecall from Company A to another company's service which costs more, but is available 24x7.

    Using a selector for simple dispatch

    A basic use of a selector is for simple dispatch, which means you can dynamically reroute the destination of aservice call from one component or import to another. Lets make the Invoke Credit Checking Service activityin the business process now call a selector instead of being statically wired to the Company A service. It wouldlook like the following:

    Figure 2: Using a selector for simple dispatch

    The Invoke Credit Checking Service activity calls a selector that will decide at runtime which implementation

    to invoke. The selector uses a selection criterion to choose a destination that is the desired serviceimplementation to invoke. The selection criterion could either be a current date, an XPath expression that getsa date from a business object, or a Java snippet that returns a date. Just like rule groups, each destination hasan entry that specifies a range of dates in which this destination would be applicable. If the date returned fromthe selection criterion is within the boundary of the date range entry, then the selector will use thecorresponding destination.

    The date range entries are optional. If, in fact, no date range entry is supplied or if no date matches theselection criterion, the default destination will be invoked. Keep in mind that if you do not specify a defaultdestination and no date range entry matches the selection criterion, then an exception will be thrown.Therefore, it is best to provide a default destination.

  • 8/7/2019 WID Lecture

    19/22

    Page 19 of 22

    In Figure 2, the selector chooses the service implementation that Company B provides if the selection criterionis a date in October 2006. The selector will run the service that Company C provides if the selection criterion isa date in November 2006. For all other situations, the selector runs the service that Company A provides.

    Figure 3: Using a selector to call a component in the same module or an export in a differentmodule

    The destination of a selector can be a component inside the assembly diagram of the same module or anexport of another module. For example, Figure 3 shows the LoanProcess component wired to theCreditCheckSelector. The selector can route service calls to either the CreditCheck component in Module A orthe Module_B_Export in Module B.

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

    If you cannot match the interface of the selector with the interfaces of the destinations, you can use a selectorwith an interface map, which we described in the seventh article in this series, to convert from one interface to

    another by using the interface map as a destination in the selector. Then the selector can invoke the interfacemap that, in turn, calls the actual service implementation.

    For example, Figure 4 shows a selector that can choose from two Web service imports, each having a differentinterface. To reconcile the differences between each interface, the selector sets the corresponding interfacemaps as destinations, rather than setting the imports as destinations. Then the LoanApplicationProcesscomponent can make credit-check service calls using the CreditCheck interface without worrying about whichimport will be used, or the interface of the import.

    Figure 4: Using interface maps with selectors

    We have covered how you can use a selector in a simple dispatch scenario. What if your company were toterminate the contract with Company A and replace it with a contract with Company B? Selectors can also helpin this situation.

  • 8/7/2019 WID Lecture

    20/22

    Page 20 of 22

    Altering existing destinations or adding new destinations

    You can update or modify the destinations of a selector and their corresponding date ranges at runtime withoutredeploying the original application. This means that in the previous example, you would not have to redeploythe business process to modify the components you want to dispatch to through the selector.

    Using the WebSphere Process Server administrative console, you can replace an existing serviceimplementation with another one, add a new destination with complete date range information, or remove adestination.

    Figure 5 shows an example of the actions that you can perform through the administrative console at runtime,including

    Replace an existing component (Company Z as the new default)

    Change the date range (Company B moves to December)

    Add a new component (Company X in October)

    Figure 5: Using a selector to dynamically alter destinations

    After updating the selector in the runtime, you can optionally export the changes back to the developmentworkbench using the export function in the administrative console. The export function exports the moduleproject that contains the selector into a project interchange file, which you can then import into theWebSphere Integration Developer workbench.

    Later in the article, you will try this out by creating a selector that performs a simple dispatch. Then you willupdate the destination of the selector using the administrative console. After that, you will deploy a newmodule project and use the selector to invoke a service in the new module.

    Creating a selector

    This section describes the high-level steps involved in creating a selector. In the next section, you will get achance to actually build one yourself.

    Creating a selector is similar to creating any other component in WebSphere Integration Developer. You startby choosing the interface that your selector will support. Often, you choose the interface based on thedestinations that the selector dispatches to. Remember, the interface operations of your selector must matchexactly the interface operations of the destinations. This includes the parameters, whose types must matchexactly.

  • 8/7/2019 WID Lecture

    21/22

  • 8/7/2019 WID Lecture

    22/22

    Figure 8: Adding additional destinations

    Unlike other components on the assembly diagram, you dont wire selectors to other components or imports.Because the destinations in the selector are not statically bound, and because they might have destinations inother modules, there is no need to wire the selector to any component.