Skip to content

RabbitMQ Library to using Event Driven Application based on Publish/Subscribe

License

Notifications You must be signed in to change notification settings

Gate2Up/rabbitmq-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f7d9368 · Nov 24, 2021

History

8 Commits
Nov 24, 2021
Jul 15, 2021
Nov 24, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021

Repository files navigation

RabbitMQ x Golang

RabbitMQ Library to using Event Driven Application based on Publish/Subscribe built with Go

How to use:

  1. First before use this library you should create new amqp client
  // set configuration
  config := amqp.Config{
    ServiceName: "EXAMPLE",
    Host:        "localhost",
    Port:        5672,
    User:        "guest",
    Password:    "guest",
  }

  // open connection to amqp server
  client, err := amqp.NewClient(config)
  if err != nil {
    fmt.Println(err.Error())
    return
  }
  1. Setup Publisher
  import "github.com/Gate2Up/rabbitmq-go/publisher"

  // define topic name
  var topicName = "EXAMPLE"

  // create instance of publisher
  var Publisher = publisher.NewPublisher(topicName, nil)

  // register publisher to amqp
    client.AddPublisher(Publisher)
  1. Setup Subscriber
import (
    "fmt"
    "github.com/Gate2Up/rabbitmq-go/subscriber"
)

// create handler function
func handler(data []byte) error {
  fmt.Println(data)
  return nil
}

// create instance of the subscriber
var Subscriber = subscriber.NewSubscriber("SUBSCRIBER_NAME", nil, handler)

// register subscriber to amqp
client.AddSubscriber(Subscriber)

References

  • Go client for AMQP 0.9.1

About

RabbitMQ Library to using Event Driven Application based on Publish/Subscribe

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages