I am developing a node.js social networking application using senecajs and need to implement a scenario where a producer can send the same message to multiple consumers. I found an article that seems to illustrate sample code for pulling this off using senecajs. The issue is that I am trying to translate this to my scenario, here is the example, from this article(https://github.com/senecajs/seneca-amqp-transport/issues/27):
I have 1 client publish event to 2 listeners.
Client:
.client({
type: 'amqp',
pin: 'incomingMessage:*',
url: process.env.AMQP_URL,
exchange: {
name: process.env.NODE_ENV + ':events',
type: 'fanout'
}
});
Listeners:
.listen({
type: 'amqp',
pin: 'incomingMessage:*', //maybe useless
url: process.env.AMQP_URL,
name: process.env.NODE_ENV + ':service1',
exchange: {
name: process.env.NODE_ENV + ':events',
type: 'fanout'
}
});
.listen({
type: 'amqp',
pin: 'incomingMessage:*', //maybe useless?
url: process.env.AMQP_URL,
name: process.env.NODE_ENV + ':service2',
exchange: {
name: process.env.NODE_ENV + ':events',
type: 'fanout'
}
});
There are a few items are confusing:
1) For the client settings, it seems as if the name will end up being "development:events" or "production:events". Am I correct in this thinking?
2) For the name field for the listener outside of the exchange object, what is the purpose of this field?
3) When I call the add method, I need to pass in a name that maps to the function call that is made when the listener receives a message, would I pass the "incomingMessage:*" to the add call?
3) Will this code actually effectively provide for fanout functionality using senecajs?
Any help and guidance will be greatly appreciated.
via user1790300
No comments:
Post a Comment