admin管理员组文章数量:1296471
Having a topic with multiple subscribers is a known use case for azure service bus in a pub/sub pattern. When a message is published to a topic, all of its subscribers (depending on whether filtering criteria results in a success) will get message. This is all good.
Now, lets say that I have a single subscriber (that is configured to receive a message from the topic). The typical practice in a cluster of nodes (that need to process incoming messages) is to listen to the same subscriber. If there are n nodes on the same subscriber, the incoming messages on the subscriber is distributed to n nodes in a FIFO manner. In other words, a given message (say message A) is only processed once by node 1. The message A will not be processed by other nodes (assuming the node 1 completed the message). This is all good.
Now, I have a use case where I want a message B to be given a chance to be processed by all nodes that are listening on the same subscription. Imagine, each of these nodes have employed in-memory cache strategy and not distributed cache strategy (lets not debate this). If there is a cache eviction message is published to the topic and this subscription receives it. But instead of any one node processing this message (i.e. to evict the cache item from its in-memory cache), I want all nodes to process this message so that every node can evict the cache item from its in-memory cache. And this cannot be based on a static number of nodes as the number of nodes can dynamically shrink and expand at will, based on the system load.
Is this possible with azure service bus in an easy manner (without lot of extra effort)? If so, how do I go about implementing it?
Having a topic with multiple subscribers is a known use case for azure service bus in a pub/sub pattern. When a message is published to a topic, all of its subscribers (depending on whether filtering criteria results in a success) will get message. This is all good.
Now, lets say that I have a single subscriber (that is configured to receive a message from the topic). The typical practice in a cluster of nodes (that need to process incoming messages) is to listen to the same subscriber. If there are n nodes on the same subscriber, the incoming messages on the subscriber is distributed to n nodes in a FIFO manner. In other words, a given message (say message A) is only processed once by node 1. The message A will not be processed by other nodes (assuming the node 1 completed the message). This is all good.
Now, I have a use case where I want a message B to be given a chance to be processed by all nodes that are listening on the same subscription. Imagine, each of these nodes have employed in-memory cache strategy and not distributed cache strategy (lets not debate this). If there is a cache eviction message is published to the topic and this subscription receives it. But instead of any one node processing this message (i.e. to evict the cache item from its in-memory cache), I want all nodes to process this message so that every node can evict the cache item from its in-memory cache. And this cannot be based on a static number of nodes as the number of nodes can dynamically shrink and expand at will, based on the system load.
Is this possible with azure service bus in an easy manner (without lot of extra effort)? If so, how do I go about implementing it?
Share Improve this question asked Feb 11 at 21:02 RaghuRaghu 3,0914 gold badges41 silver badges75 bronze badges 2- How about polling for messages in the Subscription using "Peek" mode instead of "Peek/Lock" mode? Would something like that work? – Gaurav Mantri Commented Feb 11 at 23:09
- Peek may allow the reading of the message (without deleting) by the listeners. But who gets to delete it? Ideally the last listener to read should delete the message after it is done. But the question is how does a listener know if it is the last listener to read the message or not? – Raghu Commented Feb 12 at 22:33
1 Answer
Reset to default 0TLDR: Azure Service Bus messages published to a topic and received by a scaled-out subscriber adhere to the competing consumer pattern. Only one instance will receive the message, and not the rest of the scaled-out instances. So the short answer to your question - you can't achieve that w/o some sort of investment.
If you need to evict the in-memory cache on the scaled-out instances of the subscriber, you'd need to handle the message by one of the instances and use a notification mechanism to deliver the eviction signal/request to the rest of the instances. It could be SignalR, Redis, etc.
本文标签:
版权声明:本文标题:caching - Is it possible to make a message available to all (and not just any one) listeners of a particular subscription in azu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741635214a2389601.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论