Skip to content

open-rnd/OLRabbitMQ

Repository files navigation

OLRabbitMQ

Objective-C wrapper for rabbitmq-c.

Installation

  • Xcode Subproject
  • Cocoapods

Requirements

  • dependency on Pod 'rabbitmqc' - rabbitmq-c.
  • if you do not use cocopads you need add rabbitmq-c (currently version 0.6.1 for all architectures armv7, arm64, x86_64 and i386)

Podfile

platform :ios, '7.0'
pod "OLRabbitMQ", "~> 0.0.2"

Usage

Create socket AMQP

OLRabbitMQSocket _socketAMQP = [[OLRabbitMQSocket alloc] initWithIp:<address ip> port:<port>];
[_socketAMQP createSocketWithVhost:<vhost> login:<login> password:<password> callback:^(BOOL ready, NSError *error) {
	// your implementation...
}];

Bind to Exchange

OLRabbitMQExchange *exchange = [[OLRabbitMQExchange alloc] initWithSocket:<OLRabbitMQSocket instance>];
[exchange bindExchange:<exchange string name> routingKey:<exchange routing key string>];

Unbind to Exchange

OLRabbitMQExchange *exchange = [[OLRabbitMQExchange alloc] initWithSocket:<OLRabbitMQSocket instance>];
[exchange unbindExchange:<exchange string name> routingKey:<exchange routing key string>];

Consume

[exchange basicConsume];

Response Operation Queue

OLRabbitMQOperation *operation = [[OLRabbitMQOperation alloc] initWithSocket:<OLRabbitMQSocket instance>];
operation.delegate = self;
[[NSOperationQueue new] addOperation:operation];

Delegate Operation Queue

- (void)amqpResponse:(NSData *)data routingKey:(NSString *)routingKey;

Warning

Please remember you cannot share a socket 'OLRabbitMQSocket'. The OLRabbitMQ use librabbitmq-c. The librabbitmq library is built with event-driven, single-threaded applications.

Features

  • librabbitmq-c with SSL

License

2015 (C) Copyright Open-RnD Sp. z o.o.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.