Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Publish/Subscribe Messaging Can Be Simple with WebSphere MQ  : Page 2

Combine publish/subscribe messaging, JMS, and WebSphere MQ to build powerful message-oriented applications simply.


advertisement

Set Up Your Own Publish/Subscribe Use Case

In this section, you will create a publish/subscribe setup resembling part of the use case in Figure 3. You will create a publisher for the news topic and two subscriptions for the email and SMS applications using the following procedure:
  1. Create a queue manager.
  2. Create a news topic.
  3. Create subscription queues.
  4. Create subscriptions.
  5. Create Java Messaging Services (JMS)-administered objects.
  6. Write publisher and subscriber classes.
  7. Run the classes.

This tutorial uses MQ Version 7 on Windows XP. (Download a trial version from the IBM web site.) Installation on Windows is straightforward. Just keep all the default values as you go through the installation wizard, but be sure to perform the installation as a user from the administrators group.

Don't worry if you haven't used WMQ before. You will use the Eclipse-based WebSphere MQ Explorer, an easy GUI for administering WMQ, to perform basic definitions.



Start WebSphere MQ Explorer as follows: Start –> All Programs –> IBM WebSphere MQ –> WebSphere MQ Explorer. If this is the first time you are starting MQ Explorer, a welcome screen will appear. Just close the welcome screen.

Create a Queue Manager

  1. In MQ Explorer's Navigator view, right-click Queue Managers and then select New –> Queue Manager. This starts the "Create Queue Manager" wizard.
  2. On Step 1, enter TestQM as the queue manager name and then click Next (see Figure 4).
  3. Click Next on the wizard screens for Steps 2 and 3. At Step 4, make sure "Create listener configured for TCP/IP" is checked and the entered port number is free (see Figure 5), and then click Finish.


Figure 4. Create Queue Manager Wizard, Step 1: Enter the queue manager name.
 
Figure 5. Create Queue Manager Wizard, Step 4: Check the port number for the queue manager's listener.

Create a News Topic

  1. Under TestQM, right-click Topics and then select New –> Topic to start the "New Topic" wizard.
  2. Type News.Topic as the topic name (see Figure 6). This represents the WMQ administrative object used to manage the topic. Click Next.
  3. On the topic properties page, type News in the "Topic string" field (see Figure 7). This string is used when creating JMS administered objects to refer to the News topic. Click Finish.


Figure 6. Create Topic, Step 1: Enter the topic's administrative object name.
 
Figure 7. Create Topic, Step 2: Enter the topic's string name.

Create Subscription Queues

Next, you will set up news publications to be delivered to Subscription queues. Create two queues for the email and SMS applications:
  1. Under TestQM, right-click Queues then select New –> Local Queue to start the "New Local Queue" wizard.
  2. In the name field, type Email.Queue and click Finish.
  3. Repeat the above steps to create another queue called SMS.Queue.

Create Subscriptions

In order to receive a topic's publications, subscribers have to register interest in the topic. They use subscriptions to accomplish this. You can can create subscriptions programmatically or through MQ Explorer. Through the following steps, you will create two subscriptions using MQ Explorer:
  1. Under TestQM, right-click Subscriptions and then select New –> Subscription to start the "New Subscription" wizard.
  2. In the name field, type EmailSubscription and click Next (see Figure 8).
  3. In the "Change properties" page, press the Select button next to the "Topic name" and then select News.Topic from the displayed topics list. Press OK. On the same page, type Email.Queue in the destination name field (see Figure 9). Click Finish.

  4. Figure 8. Create Subscription, Step 1: Enter the subscription name.
     
    Figure 9. Create Subscription, Step 2: Select topic and enter subscription queue.

  5. Repeat the above steps to create another subscription called SMSSubscription with the topic set to News.Topic and the destination name set to SMS.Queue.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap