Azure ServiceBus provides both queues and topics for the messaging. I want to know if instead of an application subscribing to a topic, can I queue do that? can we receive the topic messages into queue?
1 Answers
Queues are for unicast operations, sending to a specific single destination. Topics are for multicast operations, broadcasting.
You cannot subscribe to a queue, only listen to it. You can subscribe to a topic and then... listen to it. The difference is in who else can receive messages sent to a queue vs topic.
When a message is sent to a queue, it will be received by one listener only (assuming listener successfully processes and completes the message).
When a message is sent to a topic (also called "published"), every single subscriber will get a copy of that message.
can we receive the topic messages into queue?
Yes you can. You can enable Auto Forwarding on one of the subscriptions and point to the destination queue. It doesn't have to be a queue, could be another topic. Important thing to remember is that Azure Service Bus broker will protect from excessive auto-forwarding by limiting it to up to 3 hops at most.

- 23,443
- 7
- 55
- 80
-
I was told that topics do not guarantee delivery, but a co-worker disagrees because, according to the documentation, a subscription act like a "virtual queue" which a receiver can get messages from. But I'm observing that if the receiver goes down, messages sent to a topic subscription get dead-lettered. Am I right that delivery is not guaranteed for topics or is there a way to make messages in the subscription "queue" stay there like a Service Bus Queue? Or is forwarding it to an actual queue the only way to do that? – adam0101 Jan 27 '23 at 15:47
-
"Topics do not guarantee delivery" - nonsense. Ask them to elaborate why and show you documentation that states so. A subscription is a queue, correct. Your messages sent to a topic end up in a subscription DLQ for a reason, not because topic is unreliable or doesn't guarantee delivery. Raise a separate question with details. – Sean Feldman Jan 27 '23 at 15:52
-
I don't think they were saying that topics are unreliable, just that if a receiver goes offline, then a message is sent, then they go back online, the receiver would not receive that message because it went to a dead-letter queue. Conversely, if using a Service Bus Queue and a receiver goes down before a message is sent, the message will remain in the queue until the receiver comes back online and "completes" the message. I think the question is, can a topic exhibit the same behavior as a queue in that the message will remain in the subscription queue until completed? – adam0101 Jan 27 '23 at 16:17
-
Sorry, that's just nonsense. A topic is a way to route a message to multiple subscriptions. Once a message is in a subscription, it's not different than to be in a queue. The fact that consumers come and go doesn't matter at all. The whole point is to have decoupled producers and consumers. Queues or topics/subscriptions. I willing to bet money that the issue you've experienced was either a misconfiguration of the ASB client or a flaw in the consumer code. Raise a different question or reach ping me at feldman.sean on gmail. – Sean Feldman Jan 27 '23 at 20:16