Skip to content

Instantly share code, notes, and snippets.

@dhanush
Last active December 25, 2020 04:02
Show Gist options
  • Save dhanush/94f8b0243162ccd7a7655daad3288b16 to your computer and use it in GitHub Desktop.
Save dhanush/94f8b0243162ccd7a7655daad3288b16 to your computer and use it in GitHub Desktop.
The publisher main method which will publish messages to multiple queues
package main
func main() {
conn := comms.NewConnection("my-producer", "my-exchange", []string{"queue-1", "queue-2"})
if err := conn.Connect(); err != nil {
panic(err)
}
if err := conn.BindQueue(); err != nil {
panic(err)
}
for _, q := range c.queues {
m := comms.Message{
Queue: q,
//set the necessary fields
}
if err := conn.Publish(m); err != nil {
panic(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment