A RabbitMQ client, largely influenced by Bunny.
Test-driven from Swift and implemented in Objective-C, to avoid burdening Objective-C developers with Swift baggage.
- 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
- OSX support
- PKCS12 support for OSX
- PKCS12 client certificates on iOS using the TLS auth mechanism plugin
- PKCS12 client certificates on iOS using chained CAs
- Publisher confirmations
- Publish and consume messages as data
- Connection closure when broker doesn't send heartbeats fast enough
- Customisable consumer hooks
- basic.return support
- Transaction support
Installation with Carthage
-
Create a Cartfile with the following line:
github "rabbitmq/rabbitmq-objc-client" ~> 0.10.0
Run carthage, for example in a new project:
carthage bootstrap
-
In your Xcode project, in the Build Phases section of your target, open up Link Binary With Libraries. Now drag e.g.
Carthage/Build/iOS/RMQClient.framework
(choose Mac for OSX) into this list. -
If you don't already have one, click the '+' icon under Build Phases to add a Copy Files phase.
-
Under Destination, choose Frameworks.
-
Click the '+' and add RMQClient.framework. Ensure Code Sign On Copy is checked.
Installation with CocoaPods
-
Add the following to your Podfile:
pod 'RMQClient', '~> 0.10.0'
We recommend adding
use_frameworks!
to enable modular imports (Objective-C only). -
Run
pod install
. -
Open your project with
open MyProject.xcworkspace
.
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>
.
- Several RabbitMQ tutorials are provided for this client library.
-
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.
Then start a local RabbitMQ node (any way you please, doesn't have to be from Homebrew or source),
configure it using files under .travis/etc/
, for example:
brew install rabbitmq
cp .travis/etc/* /usr/local/etc/rabbitmq/
/usr/local/sbin/rabbitmq-plugins enable --offline rabbitmq_auth_mechanism_ssl
brew services start rabbitmq
Then run a few setup steps:
bin/bootstrap-if-needed
make test_user
Finally, run the test suite:
make tests
This package, the RabbitMQ Objective-C client library, is dual-licensed under the Mozilla Public License 1.1 ("MPL") and the Apache License version 2 ("ASL").