github:https://github.com/rabbitmq/rabbitmq-objc-client
github上的說(shuō)明如下:
使用CocoaPods進(jìn)行安裝
-
將以下內(nèi)容添加到您的Podfile中:
pod 'RMQClient', '~> 0.11.0'我們建議添加
use_frameworks!以啟用模塊化導(dǎo)入(僅Objective-C)。 運(yùn)行
pod install。使用打開(kāi)項(xiàng)目
open MyProject.xcworkspace。
Objective-C用戶:使用導(dǎo)入@import RMQClient;當(dāng)前會(huì)在Xcode中產(chǎn)生錯(cuò)誤(無(wú)法構(gòu)建模塊'RMQClient'),但這不會(huì)阻止代碼的編譯和運(yùn)行。使用鱷魚(yú)進(jìn)口可以避免以下Xcode錯(cuò)誤:#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>.)
支持的功能
- 以字符串形式發(fā)布和使用消息
- 操作隊(duì)列,交換,綁定和使用者。
- 在后臺(tái)使用GCD隊(duì)列的異步API(委托在可配置的GCD隊(duì)列上接收錯(cuò)誤)。
- 可配置的網(wǎng)絡(luò)中斷和連接級(jí)異常恢復(fù)
- TLS支持
- 客戶心跳
- 迦太基支持
- CocoaPods支持
- iOS支持
- MacOS支持
- 使用TLS身份驗(yàn)證機(jī)制插件的iOS上的PKCS12客戶端證書(shū)
- PKCS12對(duì)MacOS的支持
- 使用鏈接的CA的iOS上的PKCS12客戶端證書(shū)
- 發(fā)布者確認(rèn)
- 發(fā)布和使用消息作為數(shù)據(jù)
- 可定制的消費(fèi)者掛鉤
- 代理未按計(jì)劃發(fā)送心跳時(shí)關(guān)閉連接
- 基本回報(bào)支持
- 確認(rèn)交易支持
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
文獻(xiàn)資料
- 該客戶端庫(kù)提供了一些RabbitMQ教程。
(基本)用法示例
-
實(shí)例化一個(gè)
RMQConnection:讓委托= RMQConnectionDelegateLogger()//實(shí)現(xiàn)RMQConnectionDelegate自己對(duì)錯(cuò)誤做出反應(yīng) let conn = RMQConnection(uri:“ amqp:// guest:guest @ localhost:5672 ”,委托:委托) -
連接:
康恩 開(kāi)始() -
創(chuàng)建一個(gè)頻道:
令ch = conn。createChannel() -
使用頻道:
讓q = ch。排隊(duì)(“ myqueue ”) q。訂閱({M在 印刷(“收到的:\(字符串(數(shù)據(jù):M體,編碼:字符串。編碼。UTF8)) ”) }) Q值。發(fā)布(“富”。數(shù)據(jù)(使用:字符串。編碼。utf8)) -
完成后關(guān)閉連接:
conn.close()
有關(guān)更多詳細(xì)說(shuō)明,請(qǐng)參見(jiàn)教程。
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.
注:以上為網(wǎng)址上摘抄