mxriverlynn / rabbus

A micro-service bus with built-in messaging patterns, for NodeJS and RabbitMQ
116 stars 26 forks source link

messageType property #14

Closed kevinswarner closed 8 years ago

kevinswarner commented 8 years ago

Just a question really. What is the purpose of the messageType property? I cannot find it anywhere in the AMQP documentation and it seems to serve the same purpose as a routing key. In my project, I cannot think of a reason where the message type would be different than the routing key. For example, let's say I have a service that has two commands...

pdfservice.command.create pdfservice.command.combine

So, I have the following topology...

I probably am missing some use for the message type, and am looking for a good example of why it is there.

Thanks!

mxriverlynn commented 8 years ago

Hi @kevinswarner,

The message type property comes from wascally - the library that rabbus is built on top of. It acts as a sort of routing key within your code, allowing one consumer to handle multiple message types from one or more queues, instead of requiring a new consumer per queue.

you can read more about it in the wascally docs https://github.com/LeanKit-Labs/wascally

and honestly, my routing key and message type are never different, either. i left the option in there in case someone wants to make them different.

perhaps a change would be good, to have the message type default to the routing key, if no message type is supplied? that way you wouldn't have to think about the message type, most of the time.

kevinswarner commented 8 years ago

Thanks for the clarification Derick! Did not mean to clutter up "issues" with a general question. BTW... great series on RabbitMQ. Thanks!

mxriverlynn commented 8 years ago

i don't think i need to change anything for this... i'm watching some tickets over on the wascally library, and it looks like you can just omit the messageType entirely.

i'm going to run some tests and if that is correct, i'll update the Rabbus docs to recommend not setting a messageType.

mxriverlynn commented 8 years ago

confirmed in v0.2.9+ of wascally, if no message type is provided, it uses the routing key instead. https://github.com/LeanKit-Labs/wascally/releases/tag/v0.2.9 - so, no need for me to do anything on this ticket other than update the docs. will close the ticket when i get that done.

mxriverlynn commented 8 years ago

i've updated the docs - currently in the middlewareBuilder branch - to reflect this information. there is no more use of messageType in the sample code or demos folder, and I've added a section that discusses this at the bottom https://github.com/derickbailey/rabbus/tree/middlewareBuilder#the-messagetype-attribute

kevinswarner commented 8 years ago

Thanks Derick!

mxriverlynn commented 8 years ago

well, i got that wrong... after testing things, i found i had to mod the code to handle this after all. so now Rabbus explicitly sets the message type to the routing key, when no message type is supplied.

in teh dev branch now, release soon

mxriverlynn commented 8 years ago

fixed in v0.7.1

note due to a limitation in wascally ( i think ), you should still provide a messageType or routingKey when using the pub/sub objects.

i'm going to open an issue with wascally to discuss this