Publish / Subscribe
publish subscribe - that is similar to a newspaper. The sender is sending out messages. People who subscribe will receive the messages.
Sample
open instance of WSL
1 | stm config init |
- Creates a client endpoint for a ‘Barista Station’
- This endpoint will be reading from a queue called “coffeeshop/order/details/v1/*/ca/>”
- coffeeshop/order/details/v1/*/ca/> - is a 6 (or more) hierarchical definition
- Actually /*/ is a wildcard saying it will receive all messages directed to any variation in that queue …/v1/x/ca/… and …/v1/y/ca/… and …/v1/marysville/ca/…
- /> is a whilecard meaning
- The stm program is now waiting to receive messages
- –output-mode full ???
Open a second terminal window
1 | stm receive --topic "coffeeshop/order/details/v1/*/ca/>" --client-name "Kitchen Floor" |
- Creates a second client endpoint for a computer in the ‘Kitchen Floor’ area.
- This is receiving the same messages as the barista station is receiving.
- The stm program is now waiting to receive messages
Open a third terminal window
1 | stm receive --topic "coffeeshop/staff/arrive/v2/*/ca/>" --client-name "Human Resources" |
- Creates a third client endpoint for a computer in the ‘Human Resources’ area
- Notice – this points to a different queue. So it wont receive the same messages as the other 2 receivers.
Open a forth terminal window
1 | stm send --topic coffeeshop/order/details/v1/mobile/ca/437/44334 --file order.json --client-name "Order Management" |
- This will send a message to the queue system.
- –topic coffeeshop/order/details/v1/mobile/ca/437/44334
- This is the name of the queue to post the message into
- I don’t think you are allowed to use wildcards in this case.
- –file order.json
- We are going to send a json file. With the name provided below.
- –client-name “Order Management”
- This is the name of the process sending out the message.
- Send - this is sending messages, it will load, send a message and then exit.