wmq v7 pub/sub introduction 李慧 [email protected] ibm cdl mq l2 support, april 2011
TRANSCRIPT
Agenda
Pub/Sub concept MQ V7 PUB/SUB new feature Pub/Sub adminstration Pub/Sub Programming MQ distributed Pub/Sub topology
What is Publish/Subscribe ?
providers of informationneed have no knowledgeof consumers
consumers of informationneed have no knowledgeof providers
new providers/consumers can be added without disruption
Publish/Subscribe is a term used to define an application model in which the provider of some information is decoupled from the
consumers of that information.
Providers of information are called publishers
Consumers of information are called subscribers
The classic example
A "feed" provides a continuous flow of information which is pushed to interested parties
Traders consume this information and use it as a basis for the buying and selling stock
Traders
StockFeed
Loose-coupling with Publish/Subscribe
Few-to-many: Research, news tickers
Many-to-many: Prices and Quotes
Many-to-few: Orders
Topic
Topic
Topic
Publications and subscriptions
Subscribers make subscriptions with the queue manager to register their interest in information relating to specific topics. They use the MQSUB verb
Publishers provide information about specific topics by sending publications to the queue manager They use the MQPUT verb
The queue manager forwards each publication it receives to all subscribers with a subscription which matches the associated topic
WebSphere MQ v7 Pub/Sub
Compatibility mode available in V7,embedded pub/sub engine
Now available on z/OS!and better performance on distributed platforms
Improved Pub/Sub adminstration
A natural part of the JMS API Combines both Publish/Subscribe and Point-to-Point patterns Now also a natural part of the native MQI
MQRFH to pub and
sub?
MQPUT + MQSUB!
v6
v7
IBM WebSphere MQ V7.0
Web 2.0Java Message Service (JMS) MQ Interface
Multi-LanguageMessage Service
Publish Subscribe
Publish/Subscribe in WebSphere MQ
ConfigureMonitor
Interface
Create TOPIC objectsTopic Status
Display Connectionsand handles
Configure attributes
Topic Tree
MQSUB‘Price/Fruit/+’MQGET
MQOPEN‘Price/Fruit/Apples’
MQPUT
Topic strings and topic tree
Price/Fruit/Apples
Price/Fruit/Oranges
Price/Vegetables/Potatoes
Price/Vegetables/Onions
Price
Fruit
Apples Oranges
Vegetables
Potatoes Onions
Topic Objects
Not necessary for Publish/Subscribe
Provide an administrative control point for your topic tree Configuration attributes Security profiles Topic tree isolation
MY.TOPIC.OBJECT
FRUIT
Defining a topic object
Price
Fruit
Apples Oranges
SYSTEM.BASE.TOPIC
Starting MQSC for queue manager TEST1.
DEFINE TOPIC(FRUIT) TOPICSTR(‘Price/Fruit’) DURSUB(NO)
DISPLAY TOPIC(FRUIT)AMQ8633: Display topic details. TOPIC(FRUIT) TYPE(LOCAL) TOPICSTR(Price/Fruit) DESCR( ) CLUSTER( ) DURSUB(NO) PUB(ASPARENT) SUB(ASPARENT) DEFPSIST(ASPARENT) DEFPRTY(ASPARENT) DEFPRESP(ASPARENT) ALTDATE(2008-02-26) ALTTIME(15.05.22) PMSGDLV(ASPARENT) NPMSGDLV(ASPARENT) PUBSCOPE(ASPARENT) SUBSCOPE(ASPARENT) PROXYSUB(FIRSTUSE) WILDCARD(PASSTHRU) MDURMDL( ) MNDURMDL( )
DEFINE TOPIC
ALTER TOPIC
DELETE TOPIC
DISPLAY TOPIC
FRUIT
Resolving ASPARENT
Price
Fruit
Apples Oranges
Starting MQSC for queue manager TEST1.
DIS TPSTATUS(‘Price/Fruit’)AMQ8754: Display topic status details. TOPICSTR(Price/Fruit) ADMIN(FRUIT) MDURMDL(SYSTEM.DURABLE.MODEL.QUEUE) MNDURMDL(SYSTEM.NDURABLE.MODEL.QUEUE) DEFPSIST(NO) DEFPRTY(0) DEFPRESP(SYNC) DURSUB(NO) PUB(ENABLED) SUB(ENABLED) PMSGDLV(ALLDUR) NPMSGDLV(ALLAVAIL) RETAINED(NO) PUBCOUNT(0) SUBCOUNT(0) PUBSCOPE(ALL) SUBSCOPE(ALL)
DISPLAY TPSTATUS
Alias Queues
APPLES
Price
Fruit
Apples Oranges
Starting MQSC for queue manager TEST1.
DEFINE TOPIC(APPLES) TOPICSTR(‘Price/Fruit/Apples’)
DEFINE QALIAS(PRICES) TARGTYPE(TOPIC) TARGET(APPLES)
MQPUT(PRICES)
PRICES
FRUIT
Administration for Publishers
Price
Fruit
Apples Oranges
Starting MQSC for queue manager TEST1.
DIS TPSTATUS('Price/Fruit/+') TYPE(PUB) allAMQ8754: Display topic status details. TOPICSTR(Price/Fruit/Oranges) LPUBDATE(2008-02-26) LPUBTIME(16:50:44) ACTCONN(414D5143544553543120202020202020832AC44720005E02) NUMPUBS(3)AMQ8754: Display topic status details. TOPICSTR(Price/Fruit/Apples) LPUBDATE(2008-02-26) LPUBTIME(16:50:37) ACTCONN(414D5143544553543120202020202020832AC44720007601) NUMPUBS(1)
TOPIC attributes
DEFPRTYDEFPSISTDEFPRESPPUBPUBSCOPEPMSGDLVNPMSGDLV
MQOPEN‘Price/Fruit/Apples’
MQPUT
MQOPEN‘Price/Fruit/Oranges’
MQPUTMQPUTMQPUT
Connection ID links to DISPLAY CONN
MQOPEN‘Price/Fruit/Apples’
MQPUT
Configuring Behaviour on FailureTOPIC attributes
PMSGDLVNPMSGDLV
MQSUB‘Price/Fruit/+’
MQGET
MQSUB‘Price/Fruit/+’
MQGET
MQSUB‘Price/Fruit/+’MQSO_
DURABLE
MQGET FULL
MSGDLV Behaviour
ALL If one failure – no-one gets itALLDUR Any failure to a durable subscriber
– no-one gets it
ALLAVAIL Failures don’t affect the delivery to subscribers who can accept it
MQRC_PUBLICATION_FAILURE
TOPIC attribute defaults
PMSGDLV (ALLDUR)NPMSGDLV (ALLAVAIL)
Creating administrative subscriptions
FRUIT
Price
Fruit
Apples Oranges
Starting MQSC for queue manager TEST1.
DEFINE SUB(APPLES.TO.Q1) TOPICSTR(‘Price/Fruit/Apples’) DEST(Q1)
MQGET(Q1)
DEFINE SUB
ALTER SUB
DELETE SUB
DISPLAY SUB
Configuring managed destinations
FRUIT
Price
Fruit
Apples Oranges
Durable ModelDEFTYPE(PERMDYN)
Non-durable ModelDEFTYPE(TEMPDYN)
MQSUB‘Price/Fruit/+’MQSO_MANAGEDMQSO_DURABLEMQGET
TOPIC attributes
MDURMDL(SYSTEM.DURABLE.MODEL.QUEUE)MNDURMDL(SYSTEM.NDURABLE.MODEL.QUEUE)
SYSTEM.BASE.TOPIC
SYSTEM.MANAGED.DURABLE.47C42A83095D0220
Starting MQSC for queue manager TEST1.
DIS SUB(*)AMQ8096: WebSphere MQ subscription inquired. SUBID(414D5120544553543120202020202020832AC44720028105) SUB(Fruit Prices) TOPICSTR(Price/Fruit/+) DEST(SYSTEM.MANAGED.DURABLE.47C42A8304810220) DESTQMGR(TEST1) DESTCLAS(MANAGED) DURABLE(YES) SUBTYPE(API)
Displaying a subscriptionMQSD.SubName
MQSD.ObjectNameMQSD.ObjectString
MQSO_WILDCARD_CHARMQSO_WILDCARD_TOPIC
MQSO_MANAGED or not
MQSUB hObj parameter
MQSD.SubCorrelId
MQSO_DURABLE or not
MQSD.SubUserData
MQSD.SelectionString
Monitoring your Application subscriptions
FRUIT
Price
Fruit
Apples Oranges
DIS TPSTATUS('Price/Fruit/+') TYPE(SUB) ALLAMQ8754: Display topic status details. TOPICSTR(Price/Fruit/Oranges) SUBID(414D5120544553543120202020202020832AC44720013D07) SUBUSER(hughson) RESMDATE(2008-02-26) RESMTIME(18:53:35) LMSGDATE(2008-02-26) LMSGTIME(18:53:41) DURABLE(NO) ACTCONN(414D5143544553543120202020202020832AC44720013D05) NUMMSGS(2) SUBTYPE(API)AMQ8754: Display topic status details. TOPICSTR(Price/Fruit/Apples) SUBID(414D5120544553543120202020202020832AC44720013D07) SUBUSER(hughson) RESMDATE(2008-02-26) RESMTIME(18:53:35) LMSGDATE(2008-02-26) LMSGTIME(18:53:41) DURABLE(NO) ACTCONN(414D5143544553543120202020202020832AC44720013D05) NUMMSGS(2) SUBTYPE(API)
MQSUB‘Price/Fruit/+’MQGET
Connection ID links to DISPLAY CONN
Subscription ID links to DISPLAY SBSTATUSandDISPLAY SUB
TOPIC attributes
DURSUBSUBSUBSCOPEPROXYSUBWILDCARD
Subscriptions – two perspectives
FRUIT
Price
Fruit
Apples Oranges
DIS TPSTATUS('Price/Fruit/+') TYPE(SUB) ALLAMQ8754: Display topic status details. TOPICSTR(Price/Fruit/Oranges) SUBID(414D5120544553543120202020202020832AC44720013D07) SUBUSER(hughson) DURABLE(NO) ACTCONN(414D5143544553543120202020202020832AC44720013D05) NUMMSGS(2) SUBTYPE(API)
DIS SBSTATUS SUBID(414D5120544553543120202020202020832AC44720AMQ8099: WebSphere MQ subscription status inquired. SUB(Fruit Prices) SUBID(414D5120544553543120202020202020832AC44720013D07) SUBUSER(hughson) ACTCONN(414D5143544553543120202020202020832AC44720013D05) DURABLE(NO) NUMMSGS(5) SUBTYPE(API)
MQSUB‘Price/Fruit/+’MQGET
PUB/SUB API
PUB application
Topic Tree isolation
SUB application
Subscription operation options
Advanced task
Publishing Application
MQOPEN a topic
MQOD describes a topic to publish to ObjectType
MQOT_Q for point-to-pointMQOT_TOPIC for publish
ObjectString/ObjectName
MQPUT a message
OpnOpts = MQOO_OUTPUT | MQOO_FAIL_IF_QUIESCING;MQOPEN( hConn, &ObjDesc, OpnOpts, &hObj, &CompCode, &Reason);MQPUT ( hConn, hObj, &MsgDesc, &pmo, strlen(pBuffer), pBuffer, &CompCode, &Reason);
MQOD ObjDesc = {MQOD_DEFAULT};
ObjDesc.ObjectType = MQOT_TOPIC;ObjDesc.Version = MQOD_VERSION_4;ObjDesc.ObjectString.VSPtr = “Price/Fruit/Apples”;ObjDesc.ObjectString.VSLength = MQVS_NULL_TERMINATED;
Topic tree isolation
Price
Apples Oranges
strncpy(ObjDesc.ObjectName, “FRUIT.ANCHOR”, MQ_TOPIC_NAME_LENGTH);ObjDesc.ObjectString.VSPtr = “Apples”;ObjDesc.ObjectString.VSLength = MQVS_NULL_TERMINATED;
Price
Discount
Hursley
Market Stalls
FRUIT.ANCHOR
Fruit
Starting MQSC for queue manager TEST1.
DEFINE TOPIC(FRUIT.ANCHOR) TOPICSTR(‘Price/Fruit’)
DEFINE TOPIC(FRUIT.ANCHOR) TOPICSTR(‘Market Stalls/Hursley/Discount/Price/Fruit’)
?
Subscribing Application
MQSUB verb
Subscription Descriptor (MQSD) describes the topic MQSD.ObjectString MQSD.ObjectName
Consume publications from the returned hObj when MQSO_MANAGED used
MQSUB ( hConn, &SubDesc, &hObj, &hSub, &CompCode, &Reason);
MQGET ( hConn, hObj, &MsgDesc, &gmo, strlen(pBuffer), pBuffer, &DataLength, &CompCode, &Reason);
MQSD SubDesc = {MQSD_DEFAULT};SubDesc.ObjectString.VSPtr = “Price/Fruit/Apples”;SubDesc.ObjectString.VSLength = MQVS_NULL_TERMINATED;SubDesc.Options = MQSO_CREATE | MQSO_MANAGED | MQSO_FAIL_IF_QUIESCING;
Subscription operation options
Operation – choose at least one of MQSO_CREATE MQSO_RESUME MQSO_ALTER
Combining them MQSO_CREATE + MQSO_RESUME
Avoids MQRC_SUB_ALREADY_EXISTS
MQSO_CREATE + MQSO_ALTER
Advanced tasks
Durable subscriptions
Subscription destinations
Wildcards
Subscription expiration
Publication Selection
Retained Publications
Security on the API
Publication Contents
Selection of specific publications
Publish/Subscribe Topologies
WMQ V6 publish/subscribe networks based on hierarchies All brokers linked in parent/child tree
WMB publish/subscribe networks based on hierarchies of collectives All systems in a collective are connected to each other (mesh) Also has "clones"
New product built on hierarchies and clusters With interoperability to other pub/sub systems through hierarchies
Clusters are built on existing WMQ cluster technology Cluster can be defined independently of any existing cluster used for queuing Behaves in a similar way to WMB collective
Design gives Scalability Availability Ease of administration
Hierarchies
QMA
QMB
QMC
QMD
Similar to WMQ v6 hierarchies Interoperable with them
Very scalable
Network split if middle qmgr fails Highly available hub and spokes
Definitions QMB – ALTER QMGR PARENT(QMA) QMC – ALTER QMGR PARENT(QMA) QMD – ALTER QMGR PARENT(QMC)
No child attribute specified on parent
Channels must exist Transmit queues of same name as remote queue manager
Uses TOPIC objects No cluster topics required Be careful using clusters as hierarchy transport
ALTER QMGR PSMODE(ENABLED)
PUB(/global/sports/football/news)
SUB(/global/sports/*)
PSUBQMB
PSUBQMA
PSUBQMC
Pub/Sub Clusters
Similar to WebSphere Message Broker Collectives
Availability – Direct links between qmgrs
Benefits of traditional clusters Simplified administration
Useful for Pub/Sub Clusters Non-disruptive add/remove of qmgrs
Workload balancing NOT useful for Pub/Sub Clusters
Cluster channels Same CLUSSDR/CLUSRCVR model Flexible connectivity All to all connectivity Overlapping clusters
No Pub/Sub through gateway queue managers Use Hierarchies for linking Pub/Sub Clusters
Cluster topics Required for publishing to remote Pub/Sub Cluster queue managers
Cluster queues Can be used in traditional way in a Pub/Sub Cluster
PUB
SUB
SUBSUB
Publish/Subscribe in Combined Hierarchy & Clusters
QM
QM QM
QM QM
QM
QMQM
QM
QM
QM
QM
QM
Summary – Pub/Sub with WebSphere MQ V7
Concept What’s pub/sub
API Pub application Topic tree isolation Sub application
New Feature Pub/Sub engine Avaiable on zos Enhanced Admin Native MQ pub/sub API
ADMIN
Topic string/Topic Tree Topic,Subsription object Dis tpstatus, Dis conn
Topology
Hierarchies Cluster
More Information about Pub/Sub
Info center: Publish⁄Subscribe User's Guide
Developerwork article: http://www.ibm.com/developerworks/cn/websphere/library/techarticles/0904_xuran_mq/
OpenMic session introduction / Survey
Frequency: Bi-Monthly
Products:
WebSphere MQ WebSphere Message Broker WebSphere Application
Server
Candidate topics survey for year 2011
MQ
MQ Introduction MQ Cluster Deploy & running MQ client
on WAS.
WAS
Advanced security configuration Enhanced Admin
Session management Data source and connection
pooling
Q & A