📜 ⬆️ ⬇️

AMQP-REST

About AMQP talked a lot. Another development focused on AJAX.
Opportunities:

Data is returned in JSON.


Assembly


logfile /usr/local/var/amqp.log ; # logfile

pidfile / tmp / amqp. pid ; # pidfile
')
log_level notice ; # the level of logging: error, notice, warning, debug

daemon on ; # daemon mode

port 80 ; # http port, default 80
http 10.0.0.1 ; # bind IP

amqp: 5672 ; # amqp connection string psw: login @ host: port / vhost


Launch

./amqp-rest [ -]
./amqp-rest stop //
kill -s HUP `ps | grep amqp-rest | awk '{print $1}'` //


Using

reading one item from the queue
the queue name is the right side of the url to the last slash. For url / sss / q2, the queue name is “q2”. This is done intentionally, since all URLs are hung on a specific location and proxied through nginx.
curl 10.0.0.1:8080/sss/q2
{"result": "OK", "message":"message 2", size : 2}
// size - , .


reading all items from the queue
curl 10.0.0.1:8080/sss/q2?all
{"result": "OK", "count" : 2, messages ["message 3","the text\"xxxx\" tttt"]}
// count - .


queue size
curl 10.0.0.1:8080/sss/q2?count
{"result": "Ok", "count": 3 }


publication
The name of the exchange is also the part of the url between the last slash and '?', And the key of the exchange is the part of the url, after the question mark. For example for urla 10.0.0.1 : 8080 / sss / ex1? News
the name of the exchange is “ex1”, and the key of the exchange (routing key) is “news”
curl -d 'some post data' 10.0.0.1:8080/sss/ex1?news
{"result": "Ok"}


Of course, everything is designed for AJAX. nginx stands front server and proxies requests for amqp-rest. You can do without nginx, if you hang them on different IP. In my case, I use ngx_accesskey_module to protect against spam. Perhaps this functionality will be transferred to amqp-rest in the future.

conclusion

what seems to be performance: 1300rps
memory space 601k

Source: https://habr.com/ru/post/93322/


All Articles