A library of code which abstracts and encapsulates the details of connecting and configuration an AMQP connection a RabbitMQ Broker while still providing the majority of the flexibility gained by referring to the Go AMQP library directly.
$ go get github.com/KrylixZA/GoRabbitMqBroker
- Install RabbitMQ server (either yum, homebrew, etc...). If installed through yum, run by executing:
$ rabbitmq-server
If installed through homebrew, run by executing:
$ brew services start rabbitmq
- Browse to http://localhost:15672 (this the RabbitMQ management portal).
- Login using "guest", "guest".
- Create a user "admin" with password "admin".
- Give the "admin" user full permissions to the Virtual Host "/".
- Before rambo-ing your way through this code, please take a minute to check out the examples and read all the comments on all public-facing endpoints.
- All your code will communicate with RabbitMQ through messageBroker.go.
- You will need to make use of the configuration defined here.
- You will, likely, also need to make use of the Binding Type enumeration defined here.
- Publishers need only interact with the NewMessagePublisher definition.
- Subscribers will need to interact with NewMessageSubscriber definition and the IMessageHandler interface.
- Publishers and subscribes will need to interact with NewMessagePublisherSubscriber definition and the IMessageHandler interface.
- All messages that flow through RabbitMQ via the messageBroker.go are an implementation of the IDistributedMessage interface.
- All subscribers receive a concrete implementation of IDistributedMessage.
- All publishers must publish a struct which implements IDistributedMessage.
- An example of a basic publisher can be found here. To run this:
$ cd ${GOPATH}/src/github.com/KrylixZA/GoRabbitMqBroker/examples/publisher
$ go run basicPublisher.go
- An example of a basic subscriber can be found here. To run this:
$ cd ${GOPATH}/src/github.com/KrylixZA/GoRabbitMqBroker/examples/subscriber
$ go run basicSubscriber.go