Search code examples
objective-crabbitmqamqp

How should I use the library as librabbitmq-objc?


On my server are using RabbitMQ Server and client-side android RabbitMQ Client also used. Now I'm doing for iOS (not Mac) and found this bookshop profmaad made ​​by:

https://github.com/profmaad/librabbitmq-objc

I copy the project classes and I get an error "file not found Cocoa.h" then replace by "Foundation.h" and it worked. But now I ask the class amqp.h tells me "file not found amqp.h" and does not exist. But, It's using it.

And looking I saw that this class was a C, and now is not how to import the class or add amqp.h?

My problem is: How I can to use the library amqp.h or import the class?

#import <Cocoa/Cocoa.h>    <----- Replace Foundation.h (Equivalent)

# import <amqp.h>          <----- ?? When was file? or How import this file?

# import "AMQPConnection.h"
# import "AMQPObject.h"

Solution

  • For using in iOS

    Delete:

    #import <Cocoa/Cocoa.h>
    

    Use:

    #import <Foundation/Foundation.h>
    

    And if file not found using this:

    # import <amqp.h> 
    

    Use this:

    # import "amqp.h"
    

    This will almost solve your problem. You may get some error on uint64 fix it as xcode suggests you. And it will work fine.

    I am also using Objective-C wrapper for librabbitmq-c library. I am able to connect, create exchange, create queue, bind queue but i am not able to publish any message using this code:

    amqp_basic_properties_t props;
        props._flags= AMQP_BASIC_CLASS;
        props.type = amqp_cstring_bytes([@"typeOfMessage" UTF8String]);
        props.priority = 1;
        [exchange publishMessage:@"Hello Friends" usingRoutingKey:@"hello" propertiesMessage:props mandatory:NO immediate:NO error:&error];
    

    No error, No exception, i don't know why this is not working !!! I am still looking for the exact solution.

    See this, it may help you Objective-C RabbitMQ client not publishing messages to queue