简体   繁体   中英

Publish/Subscribe Model, what is the structure of the topic?

This question may seem awkward and is definitely due to lack of knowledge. I couldn't find any resources on the topic of how it is structured programmatically. I understand that the publisher publishes messages to the topic and the subscribers consumes messages of the topic. But what I don't understand is how its structured programmatically.

For example within the Point to Point model you have a message queue which could be looked at as a linear data structure following FIFO. Although it doesn't necessary follow FIFO but very well could. So this gives me some emphasis of how the queue is structured programmatically. How is the topic structured in this regards?

Topic is typically implemented as a tree structure with '/' being the root of the tree and children at different levels.

The following picture shows how a topic tree could be organised. The topic tree has two child nodes, one for SPORT and another for NEWS with each having children further. 在此处输入图片说明 This way of topic tree organization allows subscriptions to be created at multiple levels. For example, a subscriber who is interested only in his/her favorite football club, LIVERPOOL would subscribe with a topic string as /SPORT/FOOTBALL/LIVERPOOL . This subscriber will only get publications published with topic /SPORT/FOOTBALL/LIVERPOOL . For someone else interested in world news, would subscribe with topic /NEWS/WORLD . For someone who is interested everything would simply subscribe to / as topic.

When a subscription is created for a topic, the JMS provider creates something known as a Subscription Queue . The JMS provider puts the publications to this queue. The subscriber then receives the publications from this queue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM