Sample scenarios to show Pub/Sub of Clustered Topics in MQ V7

本文介绍在IBM WebSphere MQ集群环境中如何配置和使用主题进行消息的发布与订阅操作。详细说明了不同队列管理器之间的消息传递流程,并通过具体案例展示了如何从本地和远程队列管理器进行消息的发布及接收。

Abstract

 

The purpose of this techdoc is to provide some sample scenarios for using a topic in a cluster and to perform publish and subscribe (Pub/Sub) operations on that topic, from the local queue manager and the remote queue managers.

 

Content

 

This technote contains the following sections:

 




 

Testcase configuration details


The scenarios described here use 3 Queue Managers in an MQ cluster:

Cluster Name: NEWCLUSTER
QM1 - full repository
QM2 - full repository
QM3 - partial repository

Clustered Topic Object:
Name: TESTTOPIC
Topic String: PUBSUBV7
Local to QMgr: QM1

The following 2 commands will create the above clustered topic:

runmqsc QM1
define topic(TESTTOPIC) topicstr(PUBSUBV7) cluster(NEWCLUSTER)

The definition of the clustered topic will be pushed (fanned out) to all the Queue Managers in the cluster.
In contrast, the definition of a clustered queue is ONLY provided to the queue manager that is asking for it.

In QM1 (where the topic is local) the display of the topic shows:

display topic(TESTTOPIC)
     2 : display topic(TESTTOPIC)
AMQ8633: Display topic details.
   TOPIC(TESTTOPIC)                        TYPE(LOCAL)
   TOPICSTR(PUBSUBV7)                      DESCR( )
   CLUSTER(NEWCLUSTER)                     DURSUB(ASPARENT)
   PUB(ASPARENT)                           SUB(ASPARENT)
   DEFPSIST(ASPARENT)                      DEFPRTY(ASPARENT)
   DEFPRESP(ASPARENT)                      ALTDATE(2009-06-26)
   ALTTIME(13.54.04)                       PMSGDLV(ASPARENT)
   NPMSGDLV(ASPARENT)                      PUBSCOPE(ASPARENT)
   SUBSCOPE(ASPARENT)                      PROXYSUB(FIRSTUSE)
   WILDCARD(PASSTHRU)                      MDURMDL( )
   MNDURMDL( )

In QM2 (where the topic is NOT local) the display of the topic shows:

display topic(TESTTOPIC)
     1 : display topic(TESTTOPIC)
AMQ8147: WebSphere MQ object TESTTOPIC not found.

In QM2, we need to provide an additional qualifier: TYPE(CLUSTER), as follows:

display topic(TESTTOPIC) TYPE(CLUSTER)
     2 : display topic(TESTTOPIC) TYPE(CLUSTER)  
AMQ8633: Display topic details.
   TOPIC(TESTTOPIC)                        TYPE(CLUSTER)
   TOPICSTR(PUBSUBV7)                      DESCR( )
   CLUSTER(NEWCLUSTER)                     CLUSQMGR(QM_ANGELILLO)
   QMID(QM_ANGELILLO_2008-06-16_14.26.07)
   DURSUB(ASPARENT)                        PUB(ASPARENT)
   SUB(ASPARENT)                           DEFPSIST(ASPARENT)
   DEFPRTY(ASPARENT)                       DEFPRESP(ASPARENT)
   CLUSDATE(2009-06-26)                    CLUSTIME(13.54.04)
   ALTDATE(2009-06-26)                     ALTTIME(13.54.04)
   PMSGDLV(ASPARENT)                       NPMSGDLV(ASPARENT)
   PUBSCOPE(ASPARENT)                      SUBSCOPE(ASPARENT)
   PROXYSUB(FIRSTUSE)                      WILDCARD(PASSTHRU)
   MDURMDL( )                              MNDURMDL( )
)

An MQ Administrator is used in this technote to publish and subscribe to the topic.

In case that you want to use another userid, then review the following technote and provide to that user, the proper authority to publish and subscribe to the topic.

http://www.ibm.com/support/docview.wss?uid=swg27016153
Authorizations needed for non-mqm users to publish and subscribe to Topics in MQ V7

 

 

Scenario 1: Publishing from QM1 (where the topic is local) - subscribing from all the Queue Managers


We will be using the following MQ samples provided with the MQ installation:
amqspub topicString QMgr
amqssub topicString QMgr

NOTE:
When using these samples. do NOT use the single quotes to surround the topicString, because they will be considered as part of the topicString.
If there are no special characters in the topicString, then there is no need to surround the topicString with delimiters. It is safe to use double quotes, though:
Correct: amqspub topicString QMgr
Correct: amqspub "topicString" QMgr
Incorrect: amqspub 'topicString' QMgr

Login as an MQ Administrator.
Open 6 windows: 2 for QM1 (one pub, one sub), 3 for QM2 (3 subs with variations) and 1 for QM3 (sub)

First, subscribe to the topic string.
The amqssub waits for 30 seconds for a message. If one is received then it resets the 30 seconds timer. If not, then it terminates.
Thus, a suggestion is that you only type the commands in the 6 screens, but do not press Enter. Then, when all the commands are ready, then proceed quickly to press Enter in each window to activate them.

QM1 Window 1:
amqspub PUBSUBV7 QM1

QM2 Window 1: not using delimiters for the topic string (correct)
amqssub PUBSUBV7 QM2

QM2 Window 2: using double quotes as delimiters for the topic string (correct)
amqssub "PUBSUBV7" QM2

QM2 Window 3: using single quotes as delimiters for the topic string (incorrect)
amqssub 'PUBSUBV7' QM2

QM3 Window 1:
amqssub PUBSUBV7 QM3

Second, publish to the topic string from QM1 (the topic is local):

QM1 Window 1: Enter a brief text, such as: TEST followed by pressing Enter twice. The first Enter is to provide the TEST string, the second is to exit.
amqspub PUBSUBV7 QM1
Sample AMQSPUBA start
target topic is PUBSUBV7
TEST

Sample AMQSPUBA end

Notice that in all the subscribers windows (except one, when the single quotes were used) the output should reveal that the subscribers to the clustered topic were able to receive the message, even when the subscribers were in remote queue managers:

Sample AMQSSUBA start
Calling MQGET : 30 seconds wait time
message <TEST>
Calling MQGET : 30 seconds wait time
no more messages
Sample AMQSSUBA end

In the case when the single quotes were used notice that no messages were received.
Why? Because the string was not PUBSUBV7 (8 characters) but rather 'PUBSUBV7' (10 characters: the 8 for PUBSUBV7, one single quote at the beginning and one single quote at the end) and these strings are different.

$ amqssub 'PUBSUBV7' QM_FR1
Sample AMQSSUBA start
Calling MQGET : 30 seconds wait time
no more messages
Sample AMQSSUBA end

 

 

Scenario 2: Publishing from QM2 (where the topic is NOT local) - subscribing from all the Queue Managers


Let's repeat the scenario, with the variation that the publishing will be done from QM2 (which is not the queue manager where the topic is local).
The objective is to show that you can publish from a remote queue manager in the cluster,

Because the warning of not using single quotes was given already, we will use fewer windows and this will simplify the scenario. We will use only 4 windows: 1 for QM1 (sub), 2 for QM2 (one pub, one sub), 1 for QM3 (sub)

QM1 Window 1:
amqssub PUBSUBV7 QM1

QM2 Window 1:
amqssub PUBSUBV7 QM2

QM2 Window 2:
amqspub PUBSUBV7 QM2

QM3 Window 1:
amqssub PUBSUBV7 QM3

Second, publish to the topic string from QM2 (the topic is not local):

QM2 Window 2: Enter a brief text, such as: TEST2
amqspub PUBSUBV7 QM2
Sample AMQSPUBA start
target topic is PUBSUBV7
TEST2

Sample AMQSPUBA end

Notice that in all the subscribers windows the output should reveal that the subscribers to the clustered topic were able to receive the message, even when the publisher was in a remote queue manager (that is, where the topic was NOT a local topic).

Sample AMQSSUBA start
Calling MQGET : 30 seconds wait time
message <TEST2>
Calling MQGET : 30 seconds wait time
no more messages
Sample AMQSSUBA end

CAVEAT about runmqsc:

Please notice that runmqsc treats the double quotes and single quotes in a different manner than the amqspub and amqssub samples.
In runmqsc, ensure to use the single quotes when specifying a topic string.
Lowercase characters not contained within single quotation marks are folded to uppercase.
You cannot use double quotes (it gives a syntax error)
Example: the following topic string exists: sports/baseball
It is defined under a topic object. Notice that it is NOT shown with single quotes nor double quotes.

display topic(T1_CLUS)
     1 : display topic(T1_CLUS)
AMQ8633: Display topic details.
   TOPIC(T1_CLUS)                          TYPE(LOCAL)
   TOPICSTR(sports/baseball)               DESCR( )
   CLUSTER(NEWCLUSTER)                     DURSUB(ASPARENT)

Notice these 3 different responses from runmqsc:

1: Using tpstatus with the topic string surrounded by single quotes: correct

display tpstatus('sports/baseball')
    11 : display tpstatus('sports/baseball')
AMQ8754: Display topic status details.
   TOPICSTR(sports/baseball)               ADMIN(T1_CLUS)
   MDURMDL(SYSTEM.DURABLE.MODEL.QUEUE)
   MNDURMDL(SYSTEM.NDURABLE.MODEL.QUEUE)
   DEFPSIST(NO)                            DEFPRTY(0)
   DEFPRESP(ASYNC)                         DURSUB(YES)
   PUB(ENABLED)                            SUB(ENABLED)
   PMSGDLV(ALLDUR)                         NPMSGDLV(ALLAVAIL)
   RETAINED(NO)                            PUBCOUNT(0)
   SUBCOUNT(0)                             PUBSCOPE(ALL)
   SUBSCOPE(ALL)

2: No quotes: incorrect

display tpstatus(sports/baseball)
    13 : display tpstatus(sports/baseball)

Why? Because they will be folded to uppercase. Thus, above command is equivalent to:
display tpstatus(SPORTS/BASEBALL)
Furthermore, the topic strings are case sensitive. Thus, SPORTS/BASEBALL is indeed a topic string that has not been defined yet.

3: Double quotes: syntax error

display tpstatus("sports/baseball")
    12 : display tpstatus("sports/baseball")
AMQ8405: Syntax error detected at or near end of command segment below:-
display tpstatus("
AMQ8427: Valid syntax for the MQSC command:
  DISPLAY TPSTATUS( generic_topic_string )

 

 

Looking at the TOPIC STATUS from QM1 and QM2


We will use the MQ utility "runmqsc" to display the status of the Topic in queue managers QM1 and QM2.

Looking at the TOPIC STATUS from QM1

This command will be run from QM1 (where the topic is local).

Open 5 windows: 3 for QM1 (one for runmqsc, one for pub, one for sub), 2 for QM2 (one pub, one sub).
There will be 2 subscribers (one local, one remote) and 2 publishers (one local, one remote)

QM1 Window 1:
  runmqsc QM1

QM1 Window 2:
amqssub PUBSUBV7 QM1

QM1 Window 3:
amqspub PUBSUBV7 QM1

QM2 Window 1:
amqssub PUBSUBV7 QM2

QM2 Window 2:
amqspub PUBSUBV7 QM2

Notice the command to display the publishers will ONLY show the local publisher (the remote publisher is NOT shown)

display tpstatus('PUBSUBV7') type(pub)
     1 : display tpstatus('PUBSUBV7') type(pub)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)                      LPUBDATE( )
   LPUBTIME( )
   ACTCONN(414D5143514D5F414E47454C494C4C4F6606454A20005D01)
   NUMPUBS(0)

Notice that both subscribers (local and remote) are shown.

display tpstatus('PUBSUBV7') type(sub)
     2 : display tpstatus('PUBSUBV7') type(sub)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)
   SUBID(414D5120514D5F414E47454C494C4C4F6606454A20005E04)
   SUBUSER(rivera)                         RESMDATE(2009-06-26)
   RESMTIME(14:48:55)                      LMSGDATE( )
   LMSGTIME( )
   ACTCONN(414D5143514D5F414E47454C494C4C4F6606454A20005E01)
   DURABLE(NO)                             SUBTYPE(API)
   NUMMSGS(0)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)
   SUBID(414D5120514D5F414E47454C494C4C4F6606454A20001043)
   SUBUSER(MUSR_MQADMIN)                   RESMDATE(2009-06-26)
   RESMTIME(14:48:53)                      LMSGDATE( )
   LMSGTIME( )
   ACTCONN(000000000000000000000000000000000000000000000000)
   DURABLE(YES)                            SUBTYPE(PROXY)
   NUMMSGS(0)

You can use the information provided in ACTCONN to perform a further query to identify the application that is using that connection,
See the published technote: 1375536
http://www.ibm.com/support/docview.wss?uid=swg21375536
Identifying the name of an application that is subscribed to a topic

Looking at the TOPIC STATUS from QM2

This command will be run from QM2 (where the topic is not local).

Open 5 windows: 2 for QM1 (one for pub, one for sub), 3 for QM2 (one for runmqsc, one pub, one sub).
There will be 2 subscribers (one local, one remote) and 2 publishers (one local, one remote)

QM1 Window 1:
amqssub PUBSUBV7 QM1

QM1 Window 2:
amqspub PUBSUBV7 QM1

QM2 Window 1:
amqssub PUBSUBV7 QM2

QM2 Window 2:
amqspub PUBSUBV7 QM2

QM3 Window 4:
  runmqsc QM2

Notice the command to display the publishers will ONLY show the local publisher (the remote publisher is NOT shown)

display tpstatus('PUBSUBV7') type(pub)
     5 : display tpstatus('PUBSUBV7') type(pub)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)                      LPUBDATE( )
   LPUBTIME( )
   ACTCONN(414D5143514D5F4652312020202020207106454A20005102
   NUMPUBS(0)

Notice that both subscribers (local and remote) are shown.

display tpstatus('PUBSUBV7') type(sub)
     4 : display tpstatus('PUBSUBV7') type(sub)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)
   SUBID(414D5120514D5F4652312020202020207106454A20005A04)
   SUBUSER(rivera)                         RESMDATE(2009-06-26)
   RESMTIME(15:14:31)                      LMSGDATE( )
   LMSGTIME( )
   ACTCONN(414D5143514D5F4652312020202020207106454A20005A01)
   DURABLE(NO)                             SUBTYPE(API)
   NUMMSGS(0)
AMQ8754: Display topic status details.
   TOPICSTR(PUBSUBV7)
   SUBID(414D5120514D5F4652312020202020207106454A20000F24)
   SUBUSER(MUSR_MQADMIN)                   RESMDATE(2009-06-26)
   RESMTIME(15:14:28)                      LMSGDATE( )
   LMSGTIME( )
   ACTCONN(000000000000000000000000000000000000000000000000)
   DURABLE(YES)                            SUBTYPE(PROXY)
   NUMMSGS(0)

### Understanding IP NAT No-Payload Configuration IP NAT (Network Address Translation) no-payload configuration is a specialized setting that prevents the translation of embedded addresses and ports within the payload of packets. This is particularly useful in scenarios where applications embed IP addresses and port numbers directly into the data payload, which can cause issues when NAT is applied. Normally, NAT translates the source or destination IP addresses and ports in the packet headers. However, if the payload also contains IP addresses or ports, these embedded values may not be updated correctly, leading to communication failures [^3]. By enabling the no-payload option in NAT configurations, the system ensures that only the header information is translated, while the payload remains untouched. This can be crucial for certain protocols and applications that rely on the integrity of the embedded addresses and ports within the data stream. For instance, some multimedia applications and protocols like SIP (Session Initiation Protocol) use embedded IP addresses and ports for signaling and media transmission. If these values are altered by NAT without proper handling, the application might fail to establish connections or maintain sessions properly [^2]. ### Configuration Example To configure IP NAT no-payload on a Cisco router, you would typically follow these steps: 1. Enter global configuration mode. 2. Use the `ip nat inside source` command with the `no-payload` keyword to specify that the translation should not affect the payload. Here is an example configuration snippet: ```bash Router(config)# ip nat inside source static tcp 192.168.1.10 80 interface GigabitEthernet0/0 80 no-payload ``` In this example, the command sets up a static NAT translation for TCP traffic from the internal host at 192.168.1.10 on port 80 to the external interface GigabitEthernet0/0, also on port 80, without modifying the payload [^1]. ### Considerations When using the no-payload option, it is essential to understand the implications and potential limitations. Since the payload is not translated, any embedded addresses or ports within the data may still refer to private or outdated values, which could lead to connectivity issues if the application relies on these values for further communication. Therefore, this configuration should be used judiciously, primarily in environments where specific applications require such handling to function correctly [^4]. ### Summary The IP NAT no-payload configuration is a powerful tool for managing how NAT interacts with packet payloads. It allows for the preservation of embedded addresses and ports, which can be critical for the correct operation of certain applications. However, it requires careful planning and understanding of the network environment and the applications in use to avoid potential pitfalls associated with untranslated payload data [^3].
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值