github:https://github.com/rabbitmq/rabbitmq-objc-client
github上的说明如下:
使用CocoaPods进行安装
-
将以下内容添加到您的Podfile中:
pod 'RMQClient', '~> 0.11.0'
我们建议添加
use_frameworks!
以启用模块化导入(仅Objective-C)。 运行
pod install
。使用打开项目
open MyProject.xcworkspace
。
Objective-C用户:使用导入@import RMQClient;
当前会在Xcode中产生错误(无法构建模块'RMQClient'),但这不会阻止代码的编译和运行。使用鳄鱼进口可以避免以下Xcode错误:#import <RMQClient/RMQClient.h>
。(Objective-C users: importing with @import RMQClient; currently produces an error in Xcode (Could not build module 'RMQClient'), but this should not prevent code from compiling and running. Using crocodile imports avoids this Xcode bug: #import <RMQClient/RMQClient.h>.)
支持的功能
- 以字符串形式发布和使用消息
- 操作队列,交换,绑定和使用者。
- 在后台使用GCD队列的异步API(委托在可配置的GCD队列上接收错误)。
- 可配置的网络中断和连接级异常恢复
- TLS支持
- 客户心跳
- 迦太基支持
- CocoaPods支持
- iOS支持
- MacOS支持
- 使用TLS身份验证机制插件的iOS上的PKCS12客户端证书
- PKCS12对MacOS的支持
- 使用链接的CA的iOS上的PKCS12客户端证书
- 发布者确认
- 发布和使用消息作为数据
- 可定制的消费者挂钩
- 代理未按计划发送心跳时关闭连接
- 基本回报支持
- 确认交易支持
Supported Features
- Publish and consume messages as strings
- Manipulate queues, exchanges, bindings and consumers.
- Asynchronous API using GCD queues under the hood (a delegate receives errors on a configurable GCD queue).
- Configurable recovery from network interruption and connection-level exceptions
- TLS support
- Client heartbeats
- Carthage support
- CocoaPods support
- iOS support
- MacOS support
- PKCS12 client certificates on iOS using the TLS auth mechanism plugin
- PKCS12 support for MacOS
- PKCS12 client certificates on iOS using chained CAs
- Publisher confirmations
- Publish and consume messages as data
- Customisable consumer hooks
- Connection closure when broker doesn't send heartbeats on schedule
- basic.return support
- Acknowledgement transaction support
文献资料
- 该客户端库提供了一些RabbitMQ教程。
(基本)用法示例
-
实例化一个
RMQConnection
:让委托= RMQConnectionDelegateLogger()//实现RMQConnectionDelegate自己对错误做出反应 let conn = RMQConnection(uri:“ amqp:// guest:guest @ localhost:5672 ”,委托:委托)
-
连接:
康恩 开始()
-
创建一个频道:
令ch = conn。createChannel()
-
使用频道:
让q = ch。排队(“ myqueue ”) q。订阅({M在 印刷(“收到的:\(字符串(数据:M体,编码:字符串。编码。UTF8)) ”) }) Q值。发布(“富”。数据(使用:字符串。编码。utf8))
-
完成后关闭连接:
conn.close()
有关更多详细说明,请参见教程。
Documentation
- Several RabbitMQ tutorials are provided for this client library.
(Basic) Usage Example
-
Instantiate an
RMQConnection
:let delegate = RMQConnectionDelegateLogger() // implement RMQConnectionDelegate yourself to react to errors let conn = RMQConnection(uri: "amqp://guest:guest@localhost:5672", delegate: delegate)
-
Connect:
conn.start()
-
Create a channel:
let ch = conn.createChannel()
-
Use the channel:
let q = ch.queue("myqueue") q.subscribe({ m in print("Received: \(String(data: m.body, encoding: String.Encoding.utf8))") }) q.publish("foo".data(using: String.Encoding.utf8))
-
Close the connection when done:
conn.close()
See the tutorials for more detailed instructions.
注:以上为网址上摘抄