I’m starting to work with RabbitMQ and the amqp
package and I have a couple noob questions that I’m hoping someone can set me straight on…
First: is it possible to name the RabbitMQ connection PID? I’m used to Phoenix.PubSub
where you can start one or more processes and refer to them by the named pid so that messages can be broadcast/published to that instance. In amqp
, there is a :name
option, but the docs specifically state that it is not unique and cannot be used as a connection identifier. I’m guessing that this is intentional due to some specifics about how RabbitMQ operates, but can anyone shed light on this? How can easily send/publish/broadcast messages? Is the recommended method to open up a new connection as needed? (Instead of holding onto a named connection pid).
Secondly: is there a way to create topics (i.e. open a channel) when the app starts? I’m seeing warnings when parts of the app subscribe to topics that don’t exist yet. I can manually create these channels and the logs quiet down – this is different from Phoenix.PubSub
which lets you subscribe to any topic name you want regardless if it has been formally “initialized” or not. Is it advisable to pre-define these channel names (i.e. topic names) when the app starts? Or is that not recommended?
I’m wanting to be more simplistic about sending messages, something more like
# wishful thinking pseudo-code?
Rabbit.send(:instance_name, "my-topic", "my-message", my_options)
Thanks for any pointers! Sorry if my nomenclature and way of thinking about this is all from the Phoenix.PubSub
point of view, but that has been the bulk of experience.