Implementing a JMS Service That Writes Attachment to File

This sample reads a GIF file as a binary data on the Consumer (client) and sends the request over JMS transport with attachment configured in Set Context activity. The message format is a RPC-literal element. The SOAP Service receives the message and writes it to the disk. The Service process then reads the file from the disk and sends it back to the SOAP Consumer (client). Finally, the SOAP Consumer (Reference binding) writes the same file to the disk.

Prerequisites

TIBCO Enterprise Message Service must be running.

Copy the ImageInput1.gif file from the TIBCO_HOME\bw\n.n\samples\binding\soap\jms\AttachmentWriteToFile location to the c:\tmp folder on Windows or /tmp on UNIX. This file is used as an input attachment.

In TIBCO EMS administration, create queue.sample before executing the sample.

Procedure

  1. In the samples directory, select binding > soap > jms > AttachmentWriteToFile and double-click tibco.bw.sample.binding.soap.jms.AttachmentWriteToFile. For more information, see Accessing Samples.
  2. In Project Explorer expand the tibco.bw.sample.binding.soap.jms.AttachmentWriteToFile project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. Fully expand the Processes directory and double-click Server.bwp.
  5. Verify your TIBCO Enterprise Message Service connection.
    1. Fully expand the Resources directory.
    2. Double-click JMSConnectionResource.jmsConnResource.
    3. In the Basic Configuration dialog box, click Test Connection to verify the connection.
  6. Click Run > Debug Configurations.
  7. At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  8. Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.binding.soap.jms.AttachmentWriteToFile.application.
  9. Click Debug.
    This runs the sample in Debug mode.
  10. In TIBCO Business Studio™ for BusinessWorks™, click the Terminate icon to stop the process.

Result

The output.log file at C:\tmp\AttachmentWriteToFile location shows the following information:

Sent file size : 2514 bytes. Received file size : 2514 bytes.

You also see two attachments, printServer.gif and printClient.gif at C:\tmp\AttachmentWriteToFile location.

Understanding the Configuration

SOAP Consumer (Client) sends the binary data using context over JMS transport. Service receives the attachment data and writes the attachment to the disk at location specified in SENT_RECV_FILES_WTF property. Threshold size WRITE_THRESHOLD and WriteToFile Directory is set on both Service and Reference binding.

The Consumer (Client) receives the attachment data from the Service using context and writes the content to disk. Both Service Provider and Consumer (Client) write data to the disk based on the Binding Persistence Configuration.

Note: Generated attachment files, that is, printServer.gif and printClient.gif on Service Provider and Consumer (client) must be identical to the provided INPUT_FILE that is specified in the Module Properties.