Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Latest commit

 

History

History
48 lines (42 loc) · 3.88 KB

README.md

File metadata and controls

48 lines (42 loc) · 3.88 KB

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.

Build Status GoDoc license

To install

$ go get github.com/KrylixZA/GoRabbitMqBroker

Setting up RabbitMQ

  1. 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
  1. Browse to http://localhost:15672 (this the RabbitMQ management portal).
  2. Login using "guest", "guest".
  3. Create a user "admin" with password "admin".
  4. Give the "admin" user full permissions to the Virtual Host "/".

Using this package

  • 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.
  1. All your code will communicate with RabbitMQ through messageBroker.go.
  2. You will need to make use of the configuration defined here.
  3. You will, likely, also need to make use of the Binding Type enumeration defined here.
  4. Publishers need only interact with the NewMessagePublisher definition.
  5. Subscribers will need to interact with NewMessageSubscriber definition and the IMessageHandler interface.
  6. Publishers and subscribes will need to interact with NewMessagePublisherSubscriber definition and the IMessageHandler interface.
  7. All messages that flow through RabbitMQ via the messageBroker.go are an implementation of the IDistributedMessage interface.
  8. All subscribers receive a concrete implementation of IDistributedMessage.
  9. All publishers must publish a struct which implements IDistributedMessage.

Examples

  1. 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
  1. 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