LiMQA
abstraction for AMQP
a Go
library that makes easier to AMQP
communication
Table of Contents
About
Limqa is an client abstraction for AMQP communication using Consumer and Producer design. Limqa is built top of streadway/amqp.
Installation
You can install using go get
go get github.com/ahmetcanozcan/limqa
Usage
Hello World
package main
import (
"fmt"
"github.com/ahmetcanozcan/limqa"
)
func main() {
uri := "amqp://guest:guest@localhost:5672"
base := limqa.New()
base.Connect(uri)
consumer, _ := limqa.NewConsumer(base,"_queue","_exchange",limqa.DeclareExchange(true))
// If you are sure that exchange is declared before
// you don't have to declare it again.
// consumer can be instantiated without DeclareExchange flag:
// consumer, _ := limqa.NewConsumer(base,"_queue","_exchange")
producer, _ := limqa.NewProducer(base,"_exchange")
// Produce a message
producer.Produce([]byte("Hello World"))
// Get message from the consumer
msg := consumer.Consume()
fmt.Println(string(msg))
// Output : Hello World
}
Options
a consumer or producer can be configured using limqa options
// ...
consumer1, _ := limqa.NewConsumer(base,"_queue","_exchange",limqa.DeclareExchange(true),limqa.NoAck(false))
// ...
consumer2, _ := limqa.NewConsumer(base,"_queue2","_exchange",limqa.NoWait(true),limqa.NoAck(true),limqa.NoLocal(true))
producer, _ := limqa.NewProducer(base,"_exchange",limqa.Durable(true),limqa.AutoDelete(false))
// ...
CLI
Limqa can be used by cli for message producing or consuming using Limqa library. It can be installed using go get
go get github.com/ahmetcanozcan/limqa/limqa
Now, we can produce and consume messages.
limqa produce -m "Hello World" -exchange hello_world
# Output : message sent
limqa consume -queue helo_queue_1 -e hello_world
# Output : Hello World
for more help for flags and commands use:
limqa -help
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
)
- Commit your Changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the Branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Ahmetcan ÖZCAN - email