Mqseries Publish/Subscribe Applications
Total Page:16
File Type:pdf, Size:1020Kb
Front cover MQSeries Publish/Subscribe Applications Guidelines for designing a publish/subscribe environment Developing and publishing with MQI, AMI, and JMS Programming examples for an information push system Mark Perry Christophe Delporte Federico Demi Animesh Ghosh Marc Luong ibm.com/redbooks International Technical Support Organization MQSeries Publish/Subscribe Applications September 2001 SG24-6282-00 Take Note! Before using this information and the product it supports, be sure to read the general information in “Special notices” on page 219. First Edition (September 2001) This edition applies to: MQSeries for Windows NT Version 5.2 MQSeries Integrator for Windows NT Version 2.01 Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. MP135 IBM United Kingdom Ltd Hursley Hampshire SO21 2JN United Kingdom When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 2001. All rights reserved. Note to U.S Government Users – Documentation related to restricted rights – Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Preface . .ix The team that wrote this redbook. .ix Special notice . .xi IBM trademarks . xii Comments welcome. xii Chapter 1. Introduction to publish/subscribe. 1 1.1 What is publish/subscribe? . 2 1.2 MQ products. 4 1.2.1 MQSeries . 4 1.2.2 MQSeries Integrator . 5 1.3 Features of MQ Publish/Subscribe systems . 6 1.3.1 Retained publications . 6 1.3.2 Message persistence . 6 1.3.3 Topic-based or content-based subscriptions . 7 1.3.4 Temporary subscriptions. 7 1.3.5 Expiration . 7 1.4 Languages and interfaces . 7 1.4.1 AMI . 8 1.4.2 JMS . 8 1.4.3 MQI . 8 1.5 Broker networks . 8 1.5.1 MQSeries Publish/Subscribe broker networks . 9 1.5.2 MQSeries Integrator and mixed broker networks . 9 Chapter 2. Technical overview . 11 2.1 Queues and message headers. 12 2.1.1 Queues . 12 2.1.2 Message formats. 16 Chapter 3. Example application . 19 3.1 The business case . 20 3.2 Application solution . 20 3.2.1 Simulated public transport system . 20 3.3 Publish/subscribe scenario 1 . 22 3.4 Publish/subscribe scenario 2 . 24 3.5 Publish/subscribe scenario 3 . 24 3.6 Publish/subscribe scenario 4 . 25 3.7 Publish/subscribe scenario 5 . 25 © Copyright IBM Corp. 2001 iii Chapter 4. The publish/subscribe application . 27 4.1 Software components. 28 4.2 Environment setup . 29 4.2.1 MQSeries Publish/Subscribe installation . 29 4.2.2 JMS installation . 32 4.2.3 JMS overview . 36 4.2.4 JMS configuration, JNDI and JMSAdmin . 39 4.2.5 Defining MQSeries required for the application . 52 4.2.6 AMI overview. 52 4.2.7 AMI installation . 56 4.2.8 AMI configuration . 60 4.3 PubLauncher . 73 4.3.1 The properties file - pub.properties . 74 4.3.2 PubLauncher coding logic. 75 4.3.3 Starting the publication application . 75 4.4 PubThread . 76 4.4.1 PubThread coding logic . 78 4.5 The publication messages . 79 4.6 Publishing in C . 80 4.6.1 Vehicle C AMI program . 81 4.6.2 Vehicle C MQI program. 84 4.7 Publishing in Java . 88 4.7.1 Publishing in JMS . 89 4.7.2 Publishing in Java AMI . 91 4.8 Subscription . 93 4.8.1 Setup of the environment . 93 4.8.2 XMLParser setup . 94 4.8.3 VAJava setup . 94 4.9 AMI administration setup . 94 4.10 Sample subscriber application . 96 4.10.1 Control Program . 97 4.10.2 XML parser program . 102 4.10.3 GUI program . 102 4.10.4 Parsing JMS-based published message. 102 4.11 Comments and extensions . 105 4.11.1 Retained publications . 105 4.11.2 Streams. 108 4.11.3 Broker networks . 110 Chapter 5. Migration to MQSeries Integrator . 115 5.1 Step-by-step guide . 116 5.1.1 Step 1 - Creation of a publication queue. 116 5.1.2 Step 2 - Creation of a simple publish message flow . 116 iv MQSeries Publish/Subscribe Applications 5.1.3 Step 3 - Deployment to the target broker . 119 5.1.4 Step 4 - Executing example applications on MQSeries Integrator . 119 5.1.5 Step 5 - Trace analysis . 120 5.2 Comments and extensions . 120 5.2.1 Streams handling in MQSeries Integrator . 121 5.2.2 Subscription points . 122 5.2.3 MQSeries Integrator broker networks and collectives. 123 5.2.4 Topic-based security . 125 5.2.5 Example - migration of applications using streams. 130 5.2.6 Example - message translation using subscription points . 133 5.2.7 Example - MQSeries Integrator broker networks ..