Coder Social home page Coder Social logo

fairyhunter13 / rabbitmqclient Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 69 KB

Rabbitmqclient is built using "fairyhunter13/amqpwrapper". This client manages publishers and consumers of RabbitMQ.

License: MIT License

Go 100.00%
rabbitmq amqpwrapper amqp go golang publisher subscriber publish-subscribe client rabbitmqclient producer consumer producer-consumer queue exchange rabbitmq-topology rabbitmq-network

rabbitmqclient's Introduction

بِسْمِ اللّٰهِ الرَّحْمٰنِ الرَّحِيْمِ


السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ


ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ


اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ ، وَعَلَى آلِ مُحَمَّدٍ ، كَمَا صَلَّيْتَ عَلَى إِبْرَاهِيمَ وَعَلَى آلِ إِبْرَاهِيمَ ، إِنَّكَ حَمِيدٌ مَجِيدٌ ، اللَّهُمَّ بَارِكْ عَلَى مُحَمَّدٍ ، وَعَلَى آلِ مُحَمَّدٍ ، كَمَا بَارَكْتَ عَلَى إِبْرَاهِيمَ ، وَعَلَى آلِ إِبْرَاهِيمَ ، إِنَّكَ حَمِيدٌ مَجِيدٌ

RabbitMQ Client

Coverage Status CircleCI Go Report Card

The rabbitmq client is built using the fairyhunter13/amqpwrapper package. This package can manage the topology of queue's network inside the RabbitMQ. This package simplifies the management and usage of publishing and consuming for RabbitMQ.

Example

This is an example how to use this package.

Publish and Subscribe

This is an example of go code to publish and subscribe using this package.

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/fairyhunter13/amqpwrapper"
	"github.com/fairyhunter13/rabbitmqclient"
	"github.com/streadway/amqp"
)

func main() {
	uriHost := fmt.Sprintf("amqp://guest:guest@%s:5672", "localhost")
	conn, err := amqpwrapper.NewManager(uriHost, amqp.Config{})
	if err != nil {
		log.Panicln(err)
	}

	container, err := rabbitmqclient.NewContainer(conn)
	if err != nil {
		log.Panicln(err)
	}

	err = container.
		SetExchangeName("integration-test").
		Publish(
			"",
			"example",
			*new(rabbitmqclient.OtherPublish).
				SetPersistent().
				SetBody([]byte("test payload")),
		)
	if err != nil {
		log.Panicln(err)
	}

	var result string
	testHandler := func(ch *amqp.Channel, msg amqp.Delivery) {
		msg.Ack(false)
		result = string(msg.Body)
	}
	err = container.
		Consumer().
		SetTopic("example").
		Consume(0, testHandler)
	if err != nil {
		log.Panicln(err)
	}

	time.Sleep(2 * time.Second)
	if result != "test payload" {
		log.Panicf("Expected: %v Actual: %v doesn't match.", "test payload", result)
	}
}

Topology

For this example, see this test code inside TestRabbitMQNetwork function.

Author

fairyhunter13

License

The source code inside this package is available under the MIT License.

rabbitmqclient's People

Contributors

fairyhunter13 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

kitabisa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.