skip to main content
OpenEdge Development: AppBuilder
Data-Communication Objects : SmartRouters
The SmartRouter object is designed to distribute incoming documents to the appropriate SmartB2BObject for transformation. It is only required in applications that can handle more than one document type. Figure 42 illustrates where the SmartRouter fits into the document-handling process.
Figure 42: SmartRouter distributing incoming documents
Handling multiple document types
You can create a complete message-handling system using very few SmartObjects, if your needs are uncomplicated. Figure 43 gives a schematic view of such a system.
Figure 43: Basic message-handling blocks
The business object would typically be a SmartDataObject or SmartBusinessObject. The SmartB2BObjects could also be a SmartSender/SmartReceiver pair. Regardless, the basic layout is very straightforward when all inbound or outbound messages are handled alike.
In some business situations, however, you might have to handle several different incoming logical-document types—in Figure 44, purchase order, sales enquiry, and customer support form—all packaged identically as XML messages. Since at present each document type is handled by a dedicated SmartB2BObject instance, you would need a way to route them appropriately.
The SmartRouter object provides exactly that service.
Figure 44 illustrates how the SmartRouter relates to the SmartConsumer and SmartB2B objects.
Figure 44: Message routing using SmartRouter
When a new message comes in, the SmartRouter determines which SmartB2BObject should do the transformation and starts that container, if necessary. It then identifies the SmartB2BObject to the SmartConsumer and hands off the message file to the SmartB2BObject. After that, it has nothing more to do with that message. The SmartConsumer and SmartB2BObject communicate directly from that point onward, as they do when a SmartRouter is not involved.
Callable document-handlers
The major difference between using and not using a SmartRouter is in the packaging. As Figure 44 illustrates, the SmartB2BObject/SmartDataObject pairs that handle a particular document type are packaged separately. Similarly, a SmartRouter and SmartConsumer can be packaged together, if desired.
The package used in each case is the simple SmartContainer.
The simple SmartContainer is a specialized organizer object. It has no run-time representation. You would typically use it only when creating packages such as those illustrated in Figure 44. Being able to package components without a user interface is particularly useful when your message-consuming process is to run in batch mode, without human intervention.
Creating a document-handling package
Creating a unit to handle inbound documents is a straightforward process.
To create a unit to handle inbound documents:
1. Create a SmartB2BObject—the SmartRouter cannot communicate with a SmartReceiver—to transform the object. See the “SmartB2BObjects” section for details. Save the object.
2. Create a data handler—a SmartDataObject or SmartBusinessObject—to process the transformed document. See OpenEdge Development: ADM Reference for information about the SmartDataObject, or the “SmartBusinessObject” section for details about that object. Save the object.
3. Choose FileNew and select the simple SmartContainer. A workspace of that type appears:
4. Place and configure the transformer and data handler objects that you created. No advisor will appear to offer to create SmartLinks between these objects: they do not communicate using the SmartLink mechanism.
5. Save your work. Repeat this process until you have created a handler for each incoming document type.
Creating a document-routing package
If your customer’s business practices allow, you can create a system that processes incoming documents in batch mode, without human intervention.
To do this, you would create separate containers to perform the document routing and the document handling. At run time, you start the routing package in batch mode and allow it to call the document-handling packages as documents arrive for processing. For information about creating document-handling packages, see the “Creating a document-handling package” section.
This example assumes that you will use the invisible simple SmartContainer as the organizer. If you require a user interface, use the SmartWindow instead.
To create a document-routing package:
1. Choose FileNew and select the simple SmartContainer. A workspace of that type appears:
2. Place a SmartConsumer object and configure it to monitor the appropriate inbound queue or topic. See the “Creating and placing a SmartConsumer instance” section and the “Configuring a SmartConsumer instance” section for details.
3. Click the SmartRouter tool icon:
4. Place the instance in the workspace. An Advisor will appear and offer to create a SmartLink of type ROUTER from the SmartConsumer. Accept the offer.
5. Right-click the instance and choose Instance Properties from the context menu. The SmartRouter Properties dialog box appears:
6. Click the Add button. This makes the External Reference field editable. Enter the URL of the schema file for some document type this router link must recognize. Note that the filename of the schema must be the same locally as it appears in the URL, though the paths to them will probably be very different.
7. Click the corresponding Internal Reference field to activate it. Enter the PROPATH-relative path to the corresponding map file. Thus, if the full path is d:\abc\def\mapfile.xmc and PROPATH contains d:\abc, you should enter def\mapfile.xmc here.
8. If you are satisfied with this entry, click the Save button to write the entry out to disk. Otherwise, click Reset to clear the fields, or Cancel to clear the fields and leave edit mode.
9. Repeat Step 6 through Step 8 until you have created entries for each document type this Router instance must recognize. Click OK to close this dialog box. Now, when run, this Router will be able to recognize and appropriately distribute those document types.
10. Save the package using a distinctive filename. Note that filenames for simple SmartContainers conventionally begin with c.