-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should a queue will be created automatically after first message is delivered to an exchange #3
Comments
Hello @marcio199226, thanks for your attention to the project! Publisher class is abstracted away from queue creation, this class only works with exchanges, because that's the only thing RabbitMQ publishers should really work with - it's rarely a good practice to work directly with queues themselves. What is your use case? Optional queue assertion and binding during publisher creation might be a nice feature request. |
About publisher confirms you can read here, but to keep it short, it's a way for publisher to identify the fact that RabbitMQ did receive a message we just published. If publisher confirmation fails for whatever reason, an instance of PublisherConfirmationError is thrown to the publisher actions stream. You can use |
Ok thanks for explanation i have no special use case for not using an exchange. I have another question when i start to consume messages from a queue new exchange was created an example:
After a message was consumed i see exchange_accounts_input_google. How can i prevent from creating new exchange? |
Exchange is created by default and bound to your queue. If for some reason, you don't need an exchange, you can leverage a setup function. You can find an example here under With custom setup function section. Not using an exchange is not a usual use case for RabbitMQ setup, therefore an exchange is created by default when you instantiate a Consumer instance. This exchange is later needed when you're going to publish messages. |
I will explain better you my rabbitmq setup. I would have 1 exchange of direct type which has bindings based on routing keys which will routing those messages to queue with corresponding routing key. The "issue" is when i have a consumer for queue "bar" it automatically created an exchange bar_exchange but in my case already exists an exchange so i wouldn't to create a new one for each queue the consumer is subscribed to. Thanks for all replies i will look for custom setup function anyway or rewrite my consumers using raw ampqlib |
@marcio199226 I see. Well, you can provide exchange info within consumer configs. Consumer class uses assertions, these operations are idempotent, meaning, they will either create a required resource or ensure its existence. Therefore if you provide necessary info about your exchanges and bindings to your consumer configs, not only it will work for you, but also you'll be sure that your setup is alright, before you start consuming. |
@marcio199226 If you decide to use consumer configs for your case, please let me know if they don't fit your needs 🙂 |
Hi, i have used custom setup function but it will throw an error:
After executing i have the following error: But the exchange is created successfully with right bindings and the queue is created too. What i'm doing wrong ? P.S i have the latest version installed 0.1.1 P.S2 seems that while constructing publisher/consumer factory some configs seems are still needed by them but configs & rawConfigs are sets to null, you should set them at least to an empty object i think beacuse of this for example: https://github.com/skif48/nabbitmq/blob/develop/src/models/publisher.ts#L164 when config = null https://github.com/skif48/nabbitmq/blob/develop/src/models/publisher.ts#L74 |
Hello again. Working on it @marcio199226, thanks for the snippet. |
extend custom setup function interface and usage, fix bug from issue #3
@marcio199226 fixed in v 0.1.2. You can go ahead and |
Hey @marcio199226. Is it still an issue for you? If not, I'll close this one. 🙂 |
I noticed that when consuming messages if I try to get message's routing key through |
Hello @marcio199226! P.S. I just released version 1.0.0 which changed consumer and publisher configs a little. You can have a look here and here. Also there are examples updated in README. |
I have used a custom setup function
And after consuming some message, I have used 0.1.2v Best regards |
@marcio199226 thanks for the snippet. Working on that. |
@marcio199226 I think I know where the bug is, will publish a fix soon. Thank you very much! |
I'll close this issue and move this conversation in another one: #7 . |
Hi thanks for this awesome.
I have a question because i noticed that when I publish a new message to an queue that does not exists that queue is not created itself at the first message delivered so i have to create them manually from rabbitmq dashobard.
Is this the desired behaviour, isn't it??
P.S might you explain me what is for the publisherConfirms option?
The text was updated successfully, but these errors were encountered: