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

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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