Skip to main content

Send a simple JMS message inside a BPEL process without using Java code

Donato Marrazzo (d.marrazzo@it.ibm.com), IT Specialist, WebSphere Technical Sales, IBM Italy
Donato Marrazzo photo
Donato Marrazzo has worked for IBM Italy since 1999 and currently works as a WebSphere Technical Sales IT Specialist. He helps IBM clients and business partners design and implement solutions based on WebSphere products. Donato's areas of specialization include J2EE, Process Choreographer, and Web Services. Before joining the IBM Software Group, he spent three years consulting in J2EE and Portal solutions development. He is co-author of a forthcoming IBM redbook on SOA and J2EE. He earned a Masters degree in Computer Engineering from the Politecnico di Milano.

Summary:  This article shows you how to model a process within WebSphere® Business Integration Server Foundation, in order to send a Java™ Message Service (JMS) message to a queue without writing a single line of Java code.

Date:  17 Nov 2004
Level:  Intermediate
Activity:  229 views

Introduction

WebSphere Business Integration Server Foundation Process Choreographer leverages the Web Services Invocation Framework (WSIF) capability to invoke services. This article focuses on how you can define simple services with a Java Message Service binding and get a useful side effect -- the ability to send a simple message to a queue. In other words, you can send a message to a queue without developing any Java code.


Getting started

This article presumes that WebSphere Studio Application Developer Integration Edition V5.1.1 is installed in your workstation and you are familiar with process development using Business Process Execution Language for Web Services (BPEL4WS) or (hereafter known as BPEL).

You also need to download the JMSReader.jar file included in the Download section later in this article.

In this article, you will work within an existing Service project that contains a basic process (see Figure 1):


Figure 1. The basic process
The basic process

Keep in mind that you need to change the process interface to obtain a one-way operation. In other words, delete the output parameter from the default "InputOperation".


Creating the Web Service Definition Language

In this section, we'll define a service that defines our interface against the messaging middleware. In general, sending a message on queue is an asynchronous activity. In a service view, it corresponds to a one-way operation (with only an input or output message).

To create a new Web Service Definition Language (WSDL), you need to launch the wizard and Create an empty service by following these steps:

  1. Select File => New => Empty Service.
  2. In the dialog: insert these values:
    1. Package: service (You can use another name for the value, but it is better if it is different from the process package)
    2. File name: JMSService (Again, you can use another name for the value.)
  3. Click Finish.
    The WSDL editor is opened on the previously created empty service.

Create a port type, an operation, and an input message as in Figure 2. The message is really simple -- it just contains one part defined as a String.

In the WSDL editor, follow these steps:

  1. In the Port Type pane, right-click and select Add Child => Port Type.
  2. In the dialog, insert JMSService as port type name.
  3. Right-click the JMSService port type and select Add Child => Operation.
  4. In the dialog, insert send as operation name.
  5. Right-click the send operation and select Add Child => Input.
  6. Right-click the input and select Set Message
  7. In the dialog, insert SimpleMessage as message name.
  8. In the Message pane, right-click SimpleMessage and select Add Child => Part.
  9. In the dialog, insert Part as part name. By default the part type is xsd:string.

Figure 2. The interface against the messaging middleware
The interface against the messaging middleware

To add the JMS binding:

  1. In the Binding pane, right-click and select Add Child => Binding.
  2. In the dialog box, add the the following values:
    1. Name: JMSBinding
    2. Port Type: tns:JMSPortType
    3. Protocol: JMS
    4. Message type: TextMessage
  3. Click Finish.

Figure 3. The binding wizard
The binding wizard

Create a new service called JMSService:

  1. In the services pane, right-click and select Add Child => Service.
  2. Right-click and select Add Child => Port to add a Port to the JMSService.
  3. Populate the wizard with the following values:
    1. Name: JMSPort
    2. Binding: tns:JMSBinding
    3. Protocol: JMS
    4. JNDI connection factory name: jms/QCF
    5. JNDI destination name: jms/Queue
    6. JNDI provider URL: iiop://localhost:2809

      Figure 4. The port wizard
      The port wizard
  4. Click Finish.
  5. Click Save to save the file.

The WSDL should display as in Figure 5:


Figure 5. The final WSDL
The final WSDL

Using JMS service in the process

Before using this service in the process, you need to generate the helper classes. This is required for two reasons:

  1. To create Java Beans for all XML Schema Definitions found in .wsdl and .xsd files, referred to as data-type beans.
  2. To create Java Beans to handle the serialization and deserialization of a data-type bean's wire format, referred to as format handler.

To invoke the wizard that generates the helper classes:

  1. From the Services view, select the JMSService.wsdl.
  2. From the toolbar, click the Generate helper classes button.
  3. Click Ok in the information dialog box.

Figure 6. The Generate helper classes button
The Generate helper classes button

Now, you can drag and drop the WSDL file inside your BPEL process to add a partner link that describes the process interface toward the messaging middleware. A simple dialog box displays that requires you to click OK.

In the process, you need to add an invoke activity to send the JMS message. From the BPEL editor, perform the following steps:

  1. Add an invoke activity.
  2. Select the Implementation tab.
  3. For Partner Link, select JMSPortType.
  4. For Operation, select send.
  5. Click New beside the Request property and enter SimpleMessage as the name of this process variable.

Now, you can use an assign activity to pass the value of InputVariable to SimpleMessage. Set the activity links to make the process appear as in Figure 7.


Figure 7. The final process
The final process

Deploying the process

Before deploying the process, you have to change the server configuration.

  1. From the server configuration editor, switch to the JMS tab and create a new queue named Queue (see Figure 8).
    Figure 8. JMS Server Properties
     JMS Server Properties
  2. Make sure that JNDI connection factory named jms/QCF is defined (see Figure 9).
    Figure 9. The JMS Connection Factories section
    The JMS Connection Factories section
  3. From the JMS Destination section, click Add to create a JNDI destination.
  4. Fill in the following values for Name JNDI Name: Queue and jms/Queue.
    Figure 10. The JMS Destinations section
    The JMS Destinations section
  5. Save and close the server configuration.
  6. Perform the usual steps to generate the deploy code for the process.

The JMSReader servlet

To simplify the test, a simple servlet (JMSReader) that receives a message from the queue is available with this article. To use it, import the jar in the Web project and declare it inside the Web deployment descriptor.

A servlet is a Java object that is called by an HTTP request. This implies that to run a servlet you need to write the related URL in a browser. In WebSphere Studio Application Developer Integration Edition, a servlet can be hosted only by a Web project.

For the purpose of testing, it is possible use the Web project that was generated by the process deployment (the Web project name is composed by the service project name plus the "quotWeb"suffix).

  1. From the File menu, select Import.
  2. In the dialog box select Zip file.
  3. Click Next.
  4. Click Browse and select the JMSReader.jar file included with this article to populate the From zip file field.
  5. Click Browse, find the Web project, and select the JavaSource folder to fill the Into folder field.
  6. Click Finish
  7. From J2EE Hierarchy view, double-click the Web project, the deployment descriptor displays in a new window.
  8. Select the Servlets tab and click Add.
  9. In the Add Servlet or JSP dialog box, select JMSReader.
  10. Click OK.
  11. In the URL Mapping section, click Add.

The Web deployment Descriptor should appear as in Figure 11:


Figure 11. The Web Deployment Descriptor editor
 Web Deployment Descriptor editor

The URL to invoke the servlet is so comprised of the following:

  • Protocol, server, port: http://localhost:9080/
  • Web project context root (by default the project name)
  • The mapped URL for the servlet: /JMSReader

You should enter: http://localhost:9080/ProcessWeb/JMSReader.


Conclusion

Now you can send a simple JMS messages inside a BPEL process using an elegant and quite simple approach. Under this pretext, this article reveals the power of WSIF technology inside the Business Process Choreographer. Nevertheless, if you want to send a specific complex message, you need write some lines of code!



Download

DescriptionNameSizeDownload method
JMSReader.zip fileJMSReader.zip2 KBFTP|HTTP

Information about download methods


Resources

About the author

Donato Marrazzo photo

Donato Marrazzo has worked for IBM Italy since 1999 and currently works as a WebSphere Technical Sales IT Specialist. He helps IBM clients and business partners design and implement solutions based on WebSphere products. Donato's areas of specialization include J2EE, Process Choreographer, and Web Services. Before joining the IBM Software Group, he spent three years consulting in J2EE and Portal solutions development. He is co-author of a forthcoming IBM redbook on SOA and J2EE. He earned a Masters degree in Computer Engineering from the Politecnico di Milano.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=31759
ArticleTitle=Send a simple JMS message inside a BPEL process without using Java code
publish-date=11172004
author1-email=d.marrazzo@it.ibm.com
author1-email-cc=Copy email address

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers