Login | Register   
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 3

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


advertisement

A Quick Test for Your Publish/Subscribe Setup

Perform the following to verify you have correctly completed the setup for the News topic:
  1. Under TestQM, click Topics.
  2. In the right pane, right click News.Topic and select "Test Publication" to open the test window.
  3. In the message data field, type "publish/subscribe test" (or any other text), click the "Publish message" button, and then click the Close button. This should distribute the message to the subscriber queues Email.Queue and SMS.Queue.
  4. Under TestQM, click Queues.
  5. In the right pane, right click Email.Queue and select "Browse Messages." When the browse messages window opens, search the "Message Data" column for the text you entered. You should also see the same message in SMS.Queue.
  6. Right click Email.Queue and select "Clear Messages." Click the Clear button in the "Clear queue" window. Do the same for SMS.Queue.

Create JMS-Administered Objects

JMS applications require you to wrap vendor-specific objects in JMS-administered objects. To store JMS-administered objects, create a file-based Java Naming and Directory Interface (JNDI) namespace. Start by adding a new initial context:
  1. Right-click JMS-Administered Objects and then select Add Initial Context.
  2. On Screen 1:
    • Select "File System" for "Where is the JNDI located."
    • For the Bindings directory, browse to C:\JNDI-Directory (This directory has to exist).
    • Keep note of the factory class and provider URL; you will use them in the Java code (see Figure 10).
    • Figure 10. Add Initial Context Wizard: You will use the factory class and provider URL in the sample class.
    • Click Finish.

Next, create a JMS Connection factory and destinations under the Initial Context.



Create a Connection Factory

  1. Right-click Connection Factories and then select New –> Connection Factory. On the first screen, type TestQMConnectionFactory in the name field and click Next (see Figure 11). You will use TestQMConnectionFactory in the JNDI lookup.
  2. Click Next on Step 2, Step 3, and Step 4.
  3. On the last page, select the connection tab (on the left) and then click the Select button to select TestQM as "Base queue manager" (See Figure 12). Click Finish.


Figure 11. Create Connection Factory, Step1: Type a factory name.
 
Figure 12. Create Connection Factory, Final Step: Select TestQM as the base queue manager.

Create Destinations

JMS destinations wrap WMQ topics and queues. Create a destination corresponding to the News topic:
  1. Right-click destinations and select New –> Destination to start the "New Destination" wizard.
  2. In the first step, enter NewsTopic in the Name field and change the Type field to Topic (See Figure 13). Click Next.
  3. Click Next on the second screen.
  4. On the last page (Change properties), type News in the Topic field and then click Finish (See Figure 14). This is the topic string you defined when you created the News topic.


Figure 13. Create Topic Destination, First Step: Make sure you change the Type field to Topic.
 
Figure 14. Create Topic Destination, Final Step: Make sure you type News (not News.Topic).

Create two destinations corresponding to the subscriber queues:

  1. Right-click destinations and then select New –> Destination to start the new "Destination wizard."
  2. In the first step, type EmailQueue in the Name field and then click Next.
  3. Click Next on the second screen.
  4. On the last page, click the Select button next to the "Queue Manager" field and select TestQM from the list.
  5. Click the Select button next to the Queue field and select Email (See Figure 15). Queue from the list. Click Finish.
  6. Repeat the above steps to create another Destination called SMSQueue for SMS.Queue. Your destinations should look like the ones in Figure 16.


Figure 15. Create Queue Destination, Last Step: Select queue manager and queue.
 
Figure 16. A Third Destination Called SMSQueue for SMS.Queue: You have created three destinations.



Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap