Skip to content

Golang AMQP with reconnect, clustering and delivery guarantee.

License

Notifications You must be signed in to change notification settings

xssnick/safe-amqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amqp-safe

Golang AMQP with reconnect, clustering and delivery guarantee.

import (
	amqp "github.com/xssnick/amqp-safe"
)

// Start connection and open channel, async
c := amqp.NewConnector(amqp.Config{
    Hosts: []string{"amqp://admin:[email protected]"},
}).Start()

// Callback on channel ready
c.OnReady(func() {
    if err := c.ExchangeDeclare("test-exchange", amqp.ExchangeDirect, true, false, false, false, nil); err != nil {
        log.Panic(err)
    }
   
    if _, err := c.QueueDeclare("test-queue", true, false, false, false, nil); err != nil {
        log.Panic(err)
    }

    if err := c.QueueBind("test-queue", "", "test-exchange", false, nil); err != nil {
        log.Panic(err)
    }

    err := c.Publish("test-exchange", "", amqp.Publishing{
        Body: []byte("hey"),
    })
    if err != nil {
        log.Panic(err)
    }

    c.Consume("test-queue", "", func(bytes []byte) amqp.Result {
        log.Println("event:", string(bytes))
        return amqp.ResultOK
    })
})

About

Golang AMQP with reconnect, clustering and delivery guarantee.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages