Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] One client and a delegating callback OR multiple clients/callbacks?

There are a few approaches, some of which depend on the messaging server that is being used.  

For a server that only supports MQTT.  (The approaches are what have been suggested)
  • Single client that subscribes for multiple topics (maybe wild carded). A message arrived callback uses a selector built in to discriminate and delegate based on the topic.  
  • Multiple clients where each client subscribes to a unique topic.   Most MQTT servers are good at handling large numbers of MQTT connections so there should be no problem using one connection per topic for back end apps.

For servers that support additional messaging capability e.g. queueing and JMS.
  • Some messaging servers support JMS - JMS supports a callback per subscription.  Hence if the messaging server supports both MQTT clients and JMS clients; messages can be published by MQTT clients and consumed by JMS clients..
  • Some messaging servers allow messages to arrive as a publication and be routed to/placed on a queue.  This is useful if the rate of messages arriving requires multiple back end processes/threads to process the message load.  By dint of the messages being placed on a queue each back end process can get the next message independent of other processes.   If this was attempted in a pub sub way where there are two or more  subscribers for each topic then each message would be given to all of the subscribers.
  • Similar to the approach where messages can be routed to a queue, some servers support a special form of subscription (sometimes referred to as anycast) where;  there may be multiple consumers/subscribers that subscribe to  the same topic but each message is only handed to one of the consumers/subscribers.

All the best
Dave

 



From:        Andreas Lindfalk <Andreas.Lindfalk@xxxxxx>
To:        "paho-dev@xxxxxxxxxxx" <paho-dev@xxxxxxxxxxx>,
Date:        19/03/2013 07:55
Subject:        [paho-dev] One client and a delegating callback OR multiple        clients/callbacks?
Sent by:        paho-dev-bounces@xxxxxxxxxxx




Hi!

Since the relationship between a client and a callback implementation is 1 to 1 then what's the recommended design in my situations when I will be pushing out a bunch of different messages to (Android) clients and collect various responses? ONE client for the whole backend with a callback that delegate each arrived message on to the appropriate consumer (based on the name of the topic) or MULTIPLE clients/callbacks where I have one for each known "message type"?

The code would look a lot a nicer with one callback per subscription instead of some "Java 7-string-switch", but that means that I would have around 5-10 client connections... Is it "expensive" to have multiple client connections to say Mosquitto?

Br
Andreas
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Back to the top