PikaQ makes working with Rabbit MQ even easier. It provides a thin layer around streadway/amqp, the defacto standard golang library for publishing and consuming Rabbit MQ messages. This package makes writing your own high performance message-based services fun and type safe.
The name "pika" is used for any member of the Ochotonidae, a family within the order of lagomorphs, which also includes the Leporidae (rabbits and hares). -- Wikipedia
go get https://github.com/xentek/pikaq
import "github.com/xentek/pikaq"
The simplest consumer you can create just logs and acks each message it recieves. The example below uses the built in LoggingHandler
.
For your consumer, write a function with the following signature: func(pikaq.Messages, chan error)
, and pass it as the last argument of pikaq.LoggingHandler
. Refer to the examples for more information.
package main
import (
"log"
"github.com/xentek/pikaq"
)
func main() {
c, err := pikaq.NewConsumer("amqp://localhost:5672", "amq.direct", "direct", "example-queue", "routing-key", "example", pikaq.LoggingHandler)
if err != nil {
log.Fatalf("New Consumer Error: %s", err)
}
log.Printf("Started Consumer: %s", c.tag.Tag())
}
Refer to our Contributor's Guide to learn how you can participate in this project.