Introduction
Pub/sub and streams help different parts of a program talk to each other by sending messages. They do this in different ways to fit different needs.
Pub/Sub: PUBLISH channel message SUBSCRIBE channel Streams: XADD stream_name * field value [field value ...] XREAD [COUNT count] [BLOCK milliseconds] STREAMS stream_name last_id XGROUP CREATE stream_name group_name last_id XREADGROUP GROUP group_name consumer_name STREAMS stream_name last_id
PUBLISH news "Hello everyone!"SUBSCRIBE news
XADD mystream * user Alice action login
XREAD COUNT 2 STREAMS mystream 0
XADD mystream * event "user_login" user "Alice" XADD mystream * event "user_logout" user "Bob" XREAD COUNT 2 STREAMS mystream 0
news?XREAD COUNT 2 STREAMS mystream 0 after adding two entries with XADD mystream * field1 val1 and XADD mystream * field2 val2?SUBSCRIBE mychannel. But your client never receives messages published with PUBLISH mychannel "Hello". What is the likely problem?Pass the test and this pattern moves unknown