Skip to content

Simple Go client for listening and publishing on RabbitMQ

License

Notifications You must be signed in to change notification settings

iz4vve/rabbitmq-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rabbitmq-client

Pietro Mascolo
iz4vve@gmail.com

A lightweight client for publishing/subscribing on RabbitMQ.

Installation

$ go get -u -v github.com/iz4vve/rabbitmq-client

Examples

Connection
connector := rabbit.NewConnector()
connString := "amqp://<user>:<password>@<host>:<port>"
connector.Dial(connString)
Publishing
connector.PublishOnQueue(jsonPayload, qName, exchName)
Subscribing
connector.SubscribeToQueue(qName, consumerName, callback, closeCh)

Closing connections

Remember to close a connection when not needed anymore. To do so, send a value to the close channel you used for the subscription, and call close on the connection.
This is best setup when instantiating the connector.

connector := rabbit.NewConnector()
defer connector.Close()

...

connector.SubscribeToQueue(qName, consumerName, callback, closeCh)
defer func() {closeCh <- true} ()

About

Simple Go client for listening and publishing on RabbitMQ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages