Im using HornetQ as an embedded server. I am able to create multiple queues and have them bound to a single address. This works well and I can send a message to a single address and have it consumed by multiple queues. I've another business need to have multiple addresses sending messages to a single queue. The use case would be if you think of the queue as a user who is "subscribed" to multiple things happening in the system. Meaning that different events will post to different addresses and those messages will go to a users personal queue if he subscribed to them. Is this possible?
The only way I could think of it was to set up diverts. Wondering If there is a better way. Diverts work because I divert the messages on multiple addresses to a single unique address per user which maps to the queue. Btw; I'm using the CORE API
Wildcard queues?
http://docs.jboss.org/hornetq/2.2.5.Final/user-manual/en/html_single/index.html#wildcard-routing
Divert is a good option as well
Related
Looking to understand differences between various options for moving messages i.e. diverts , bridges & Federation. As I understand diverts are for within same broker and can mix along with brides.Bridge on the other hand,can be used to move messages to different broker instance(JMS Compliant one).
Then Federation when I read looks similar to Bridging , where messages can be moved/pulled from upstream. Quick help on when which feature to be used is helpful.
Thanks a lot for your help!
Bridges are the most basic way to move messages from one broker to another. However, each bridge can only move messages from one queue to one address, and each bridge must be created manually in broker.xml or programmatically via the management interface. Many messaging use-cases involve dynamically created addresses and queues so manually creating bridges is not feasible. Furthermore, many messaging use-cases involve lots of addresses in queues and manually creating corresponding bridges would be undesirable.
Federation uses bridges behind the scenes, but it allows configuring one element in broker.xml to apply to lots of addresses and queues (even those created dynamically). Federation also allows upstream & downstream configurations whereas bridges can only be configured to "push" messages from one broker to another.
I would like to implement the following logging architecture:
whereby I have three clients logging via a <SocketAppender> to a single load balancer (Nginx in this case), and just two log listeners (LogServer1, Logserver2) to consume the TCP traffic from all three clients.
Can all three apps' messages be consumed simultaneously like this? I have been prototyping and I am repeatedly finding that each client gets exclusive access to one listener, leaving latecomer clients' messages dropped completely. There must be N servers to handle N clients. Is this true?
Socket.io offers first-class support to address specific recipients by using rooms
I'm creating a webapp where the server passes notifications to the user via Socket.io. It is a marketplace. Users may favourite/buy/sell articles and will therefore be notified from the server when something changes.
Now I've got to make the choices whether a user joins a room for every article he is interested upon login or whether I emit a message for every user individually when something changes.
What is more efficient? Is there a best practice? Am I taking on this problem from the wrong perspective?
Rooms are only a construct on the server for keeping track of lists of sockets. When you broadcast to a room, all the socket.io code does is loop through the list of sockets and send a message individually to each one.
So, in either of your cases, a message is being sent individually to each socket - same for both. Use rooms if the mechanism for keeping track of groups of sockets and being able to easily send a message to each one is useful and works for your purpose.
If you have some reason to want to use your own data structures for keeping track of lists of sockets, then that's fine too and it won't cost any more to loop through it and send a message to each one as long as you have an efficient scheme for finding which sockets you want to send the message to.
I want to achieve point-to-point messaging in Bluemix using MQ Light.
Can I do this? I don't want to define topics, but rather have the MQ Light service be aware of the destination where the message needs to be sent.
I don't want to use the pub-sub model, instead I wish to have the messages directly delivered to the destined consumer node.js application.
How can I achieve this?
Although the addresses used by applications to send messages have a topic/pubsub style format, the MQ Light API supports the delivery of these messages in both the queue and pub/sub models. Further details for the concepts can be found here:
https://developer.ibm.com/messaging/mq-light/docs/concepts/
In summary, the style of message delivery (queued or pub/sub) is selected by the receiving application when it defines the destination it wants to receive messages from. If it specifies a 'shared destinaton' it will get queue style semantics, where each message at the destination will only be delivered to one of the applications which are receiving from that destination (e.g. who use the same shared destination). If it doesn't use a shared destination then it will receive its own copy of every message e.g. pub/sub. The sending application is the same in both cases.
As an example. If an applications sends messages to the address '/address/Q1'
If applications A, B and C all define to use a shared destination 'dest1' which is mapped to the address '/address/Q1' then any message sent to that address will be shared between them (a queue style delivery model), so only one of the apps will receive each message.
If applications A, B and C all define to use a non-shared destination which is mapped to the address '/address/Q1' then any message sent to that address will be received by all the applications (a pub/sub style delivery model).
In both cases the application can set the timeToLive for the destination to control the length of time that messages will be kept when the application is not connected. This again is commonly set differently between pub/sub and queue delivery models, but is easily controlled by the application.
I am not sure if pubsub or multiuserchat is the way to go?
What I think I need is pubsub, but with the added ability for subscribers to broadcast messages to the feed as well. Bidirectional information flow, if you will.
The use case is such that subscribers will be subscribed to on average 1000 different feeds, but each individual feed only broadcasts information on average once per week. So, lots of feeds, but low activity in each one. However, b/c there are 1000 different active subscriptions, a subscriber might still be notified of 100 messages per day, and they should be able to "reply" aka post content to any one of those feeds.
It seems like what I need is a pubsub/multiuserchat hybrid. But that doesn't exist, or does it? Any ideas or pointers?
Thanks a bunch!
If a subscriber is publishing data then they are not just a subscriber, they are a publisher. And there is no reason the same entity can't be a publisher and a subscriber at the same time.
As for your more general question about pubsub vs. MUC, that's a question that I find comes up a lot nowadays.
Obviously at first glance MUC and pubsub are very similar, they are both about broadcasting to a group. Many applications could easily use one or the other with no trouble.
To help decide which fits best with your applications, let's go through some of the differences between the two protocols.
MUC:
Is absolutely good for standard chatrooms of online users communicating with each other. If this is what you're doing, use it.
Includes presence, i.e. notifying other occupants about joining, leaving and changing status.
Allows for anonymous private communication between occupants.
Works out of the box with practically any standard XMPP client (for standard chat messages).
Automatic leaving of the room when the user goes offline or disconnects.
Messages with custom payloads are supported, meaning you are limited to routing standard chat messages.
Pubsub:
One or a few publishers transmitting to many read-only subscribers is core pubsub territory. In contrast to MUC the subscribers are not publishing, and are not receiving information about other subscribers.
Server implementations tend to have much more flexible access control for pubsub.
Custom payloads only, no standard chat messages.
Optionally has full item persistence.
A node can be managed as a list of items (ie. add/remove with notification) rather than just simple broadcast.
Subscriptions can persist through being offline.
The points above are just a guide. A lot can typically be achieved through server configuration. As an example, the MUC specification allows for rooms withholding presence broadcasts for certain classes of occupants based on configuration. The catch here is in the implementations... since this is an uncommon usage of MUC, you will find it may not be supported in many MUC implementations. The point being that as MUC was designed for chatting and not generic pubsub, you will largely find all the implementations and tooling around MUC to focus on that kind usage.
Not sure what the problem is. The subscriber simply needs to be a publisher as well. There is nothing stopping them from publishing as well as subscribing (unless the nodes are configured to disallow it).
This appears to be a very typical pubsub case.