开源软件名称(OpenSource Name):wingify/lua-resty-rabbitmqstomp开源软件地址(OpenSource Url):https://github.com/wingify/lua-resty-rabbitmqstomp开源编程语言(OpenSource Language):Lua 92.7%开源软件介绍(OpenSource Introduction):Introductionlua-resty-rabbitmqstomp - Lua RabbitMQ client library which uses cosocket api for communication over STOMP 1.2 with a RabbitMQ broker which has the STOMP plugin. LimitationsThis library is opinionated and has certain assumptions and limitations which may be addressed in future;
StatusThis library is considered production ready for publishing reliable messages to RabbitMQ. STOMP v1.2 Client ImplementationThis library uses STOMP 1.2 for communication with RabbitMQ broker and implements extensions and restrictions of the RabbitMQ Stomp plugin. Internally, RabbitMQ uses AMQP to communicate further. This way the library
enables implementation of consumers and producers which communicate with the
RabbitMQ broker over STOMP, over AMQP. The protocol is frame based and has a
command, headers and body terminated by an EOL (^@) which consists of
COMMAND is followed by EOL, then EOL separated header in key:value pair format and then a blank line which is where the BODY starts and the frame is terminated by ^@ EOL. COMMAND and headers are UTF-8 encoded. ConnectionTo connect we create and send a CONNECT frame over a TCP socket provided by the cosocket api connecting to the broker IP, both IPv4 and IPv6 are supported. In the frame we use login, passcode for authentication, accept-version to enforce client STOMP version support and host to select the VHOST of the broker.
On error, an ERROR frame is returned for example:
On successful connection, we are returned a CONNECTED frame by the broker, for example:
For creating a connection, username, password, vhost, heartbeat, broker host and port should be provided. PublishingWe can publish messages to an exchange with a routing key, persistence mode, delivery mode and other header using the SEND command:
Note that content-length includes the message and EOL byte. Methodsnew
Creates a RabbitMQ object. In case of failures, returns nil and a string describing the error. If nil table is supplied default values will be assumed on login:
set_timeout
Sets the timeout (in ms) protection for subsequent operations, including the connect method. Note timeout should be set before calling any other method after creating the object. connect
Attempts to connect to a stomp broker the RabbitMQ STOMP adapter on a host, port is listening on. send
Publishers message with a set of headers. Note msg should be a string. Some header values which can be set:
For list of supported headers see the STOMP protocol extensions and
restriction page: subscribe
Subscribe to a queue by using unsubscribe
Unsubscribes from a queue by using receive
Tries to read any MESSAGE frames received and returns the message. Trying to receive without a valid subscription will lead to errors. get_reused_times
This method returns the (successfully) reused times for the current connection. In case of error, it returns nil and a string describing the error. If the current connection does not come from the built-in connection pool, then this method always returns 0, that is, the connection has never been reused (yet). If the connection comes from the connection pool, then the return value is always non-zero. So this method can also be used to determine if the current connection comes from the pool. set_keepalive
Puts the current RabbitMQ connection immediately into the ngx_lua cosocket connection pool. You can specify the max idle timeout (in ms) when the connection is in the pool and the maximal size of the pool every nginx worker process. In case of success, returns 1. In case of errors, returns nil with a string describing the error. Only call this method in the place you would have called the close method instead. Calling this method will immediately turn the current rabbitmq object into the closed state. Any subsequent operations other than connect() on the current objet will return the closed error. close
Closes the current RabbitMQ connection gracefully by sending a DISCONNECT to the RabbitMQ STOMP broker and returns the status. In case of success, returns 1. In case of errors, returns nil with a string describing the error. ExamplesA simple producer that can send reliable persistent message to an exchange with some binding:
resty-upstream pool example
TODO
AuthorRohit "bhaisaab" Yadav, rohit.yadav@wingify.com ContributingSend a pull request on You may contact the author and the Openresty community Copyright and LicenseThis module is licensed under the MIT license. Copyright 2013 Rohit "bhaisaab" Yadav, Wingify Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See Also
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论