skip to main content
OpenEdge Development: AppBuilder
Data-Communication Objects : SmartSender and SmartReceiver objects
SmartSender and SmartReceiver objects
The SmartB2BObject is designed to transform the representation of data between the internal ABL format and industry-standard XML. But what if you need no such transformation? What if you only want to send, for example, some unstructured block of ordinary text?
You can use the SmartSender (or, on the inbound side, the SmartReceiver) in place of the SmartB2BObject if you do not need the SmartB2BObject’s special capabilities. The capabilities of the SmartSender and SmartReceiver are whatever you choose to make them. Figure 41 illustrates where the objects fit in with other SmartObjects.
Figure 41: The SmartSender and SmartReceiver in B2B communication
The SmartSender and SmartReceiver objects are supplied for your use as templates with stubbed handler routines. After writing ABL procedures to complete the handler stubs, you can connect these objects to the Smart message-interface objects in exactly the same way you would connect a SmartB2BObject. The SmartSender will then perform any transformation you have included in the handler routines, package the content, and call the SmartProducer to send it off.
Similarly, the SmartReceiver will accept an inbound message from the SmartConsumer, perform the handling process you define, and pass the result on to some other SmartObject for storage or further handling.
Because you provide the handling logic, you can make these objects as simple or complex in their behavior as you desire.
You could handle plain, unformatted text by making your handler routines mere pass-throughs, their only function being to copy the unaltered text into or out of the message body. Or, you could implement special encryption/decryption procedures, graphics reformatting, or even your own special-purpose XML logic. You can implement any handling you like.
What you do with a SmartSender/SmartReceiver is entirely up to you.
Creating and completing a SmartSender master
Use the Object Palette to place a SmartSender object.
To create a new SmartSender master:
1. Click the SmartSender tool icon on the Object Palette:
2. When the Choose dialog box appears, click New. After a moment, a new SmartSender object appears:
3. Open the Section Editor and add handler code to complete the sendHandler and receiveReplyHandler procedures. Use calls from the ABL-JMS API.
The sendHander procedure deals with your outbound messages. Use it to set properties and create message bodies. See the “Example of sendHandler code” section.
The receiveReplyHandler procedure deals with incoming replies. Use it to extract properties and evaluate message bodies. See the “Example of sendHandler override code” section.
4. Save the completed master using a descriptive filename. Note that SmartSender filenames conventionally begin with sms.
Creating a SmartReceiver master involves comparable steps, though the names of the handler routines are receiveHandler and sendReplyHandler, respectively. See the “Example of receiveHandler code” section and the “Example of sendReplyHandler code” section.
Placing and configuring a SmartSender instance
Once you have created a master object, placing an instance is a straightforward process.
To place an instance:
1. Click the SmartSender tool icon on the Object Palette:
2. When the Choose dialog box opens, select the master object and click OK. Move your mouse cursor over your workspace and click to release the object.
3. Save your work.
You are now ready to configure the instance.
To configure the instance:
1. Right-click the instance and choose Properties from the context menu. When the standard SmartObject Property Sheet opens, change the Object identifier (the instance handle) to more clearly reflect the role of this object in your application.
2. If you wish to use this instance as a placeholder, set the Parameterize as Variable check box. For information about placeholders, see the “Creating a SmartObject placeholder” section and OpenEdge Development: ADM and SmartObjects.
3. Click OK to close the Property Sheet. Right-click the instance and choose Instance Properties from the context menu. The SmartSender Instance Properties dialog box appears:
4. Set the Destination property to the identifier or the SonicMQ Topic (Publish-and-Subscribe) or Queue (Point-to-Point) to which your message is to be sent.
You can choose to set two other properties, if you wish:
*Reply Required — Defaults to cleared. Setting this check box notifies the recipient that you wish a reply to your message. Your receiveReplyHandler routine must deal with any such reply.
*Reply Selector — If you wish to filter incoming replies according to values in reply-header fields or properties, enter the expression here. The SmartConsumer object will perform the test on incoming replies and discard from the inbound queue/topic any messages that fail the test. Example: company_name = "ABC" AND priority >= 4. Any reply received from company ABC with a priority of 3 or less will be discarded without notice. The syntax is a subset of the syntax defined in SQL-92.
5. Click OK to close the dialog box. Save your work.
Placing and configuring a SmartReceiver instance involves comparable steps. The major difference is that the SmartReceiver has no Instance Properties dialog box.