freewms / http-proxy-amqp

an amqp connection pool implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

http-proxy-amqp

Go Report

[Intro]

This is an amqp connection pool implementation.

It provides HTTP APIs to access MQ (eg, rabbitmq) And maintains a long connection to MQ to improve performance.

Alt text

[Install]

go version: go1.8.1+

$ go get github.com/iyidan/http-proxy-amqp

$ http-proxy-amqp -h
Usage of http-proxy-amqp:
  -config string
    	The config file
  -debug
    	if true, will print pool stats per requests
  -dsn string
    	The amqp address
  -httpListenAddr string
    	http api listen address
  -maxChannelsPerConnection int
    	The max channels per connection
  -maxConnections int
    	The max connections for this process
  -maxIdleChannels int
    	The max idle channels for this process
  -minConnections int
    	The min connections keeped for this process

[Start]

It is recommended to use supervisord to start

./http-proxy-amqp -config=path_to_config_file.json

path_to_config_file.json

{
    // DSN is the amqp address
    // The format is amqp://user:password@host:port/vhost
    // such as amqp://iyidan:123456@127.0.0.1:5672//aaa (the created vhost is /aaa not aaa)
    // Notice: user/password must be urlencoded if necessary
    // Notice: vhost maybe have a leading slash
    "dsn":"",

    "maxChannelsPerConnection":20000,
    "maxIdleChannels":500,
    "maxConnections":2000,
    "minConnections":5,

    // http api address
    "httpListenAddr":"127.0.0.1:35673"
}

[APIs]

  • POST /confirm_send?exchange=$exchange&routingKey=$routingKey

    send a persistent message with confirm mode

    The Response is OK if success

[Example]

curl -XPOST 'http://127.0.0.1:35673/confirm_send?exchange={xx}&routingKey={xx}' -d 'msg'
OK

About

an amqp connection pool implementation

License:MIT License


Languages

Language:Go 100.0%