I'd say you need to fundamentally look at what you are trying to achieve.

A key point about pub/sub is that it is a fire and forget paradigm. The reason you'd want to use it in the first place is because you want to decouple producers and consumers. In general a producer publishes a message and *zero* or more subscribers express an interest in messages with a given signature by subscribing to the message.

You can start to introduce measures to make a producer aware of consumers, but that implies a level of coupling, which is usually what you've gone down the path of pub/sub to avoid.


There are subtleties around this. The scenario you describe "create Queue with random name" is a common way to subscribe to topics and in this case the queue is really a sort of "subscription queue" that provides a bit of "elasticity" but in logical terms you're pretty much just subscribing to a topic. However there's nothing to prevent you having more durable queues with well known names. With AMQP youhave exchanges, queues and bindings between exchanges and queues and the three are related, but a bit orthogonal and you can very definitely have a queue that has a longer lifecycle than the physical consumer.

As an example

testqueue; {create: receiver, node: {x-declare: {arguments: {'qpid.policy_type': ring, 'qpid.max_size': 500000000}}, x-bindings: [{exchange: 'amq.match', queue: 'testqueue', key: 'data1', arguments: {x-match: all, data-service: amqp-delivery, item-owner: fadams}}]}}

This example relates to the headers exchange but the principle is the same for any other exchange - the key bit is the create: receiver and node field. This basically creates a queue called testqueue if it doesn't already exist and establishes the bindings from the default amq.match headers exchange to that queue. When the consumer that used that address string exits the queue and bindings will remain.


This still has producers and consumers decoupled, but you have to be aware that the lifecycle of the queue is now distinct from the consumer so you need to manage that (or deliberately don't manage that)


On 11/06/2020 12:32, mohank wrote:
Hi,

Broker : ActiveMQ Artemis
Client : QPID messaging C++ (AMQP 1.0)

I have a doubt, in Publisher-subscriber application.

*Subscriber application* ( create Queue with random name with address news.*
and routing multicast)
address : 'news.*'; {node: {type:topic, capabilities: [shared] }, link :
{name: 'news', durable:True}}"

*Publisher *
address:"'news.usa'; {create: always,   node: {type: topic}}

If I run Subscriber application then run publisher, published data consumed
by consumer successfully.

*But what happens, If publisher publish data to topic address but there is
no consumer to consume data ?*

As there is no Queue created bound with matching topic, exchange wont push
data to any queue.

Can anyone suggest how to avoid data loss in this scenario.

Thanks,
Mohan




--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to