I am trying to make a messaging application using, RabbitMQ for iOS. and i am using this wrapper classes for objective c, with RabbitMQ-C client libraries.
https://github.com/profmaad/librabbitmq-objc
Exchange, Queue & Queue Binding all are ok but my code is not publishing message to RabbitMQ server. Please help me , what is the problem?
this is my code:
NSError *error= nil; AMQPConnection *connection = [[AMQPConnection alloc] init]; [connection connectToHost:@"SERVER_NAME" onPort:PORT error:&error]; if (error != nil){ NSLog(@"Error connection: %@", error); return; } [connection loginAsUser:@"USER_NAME" withPasswort:@"PASSWORD" onVHost:@"/" error:&error]; if (error != nil){ NSLog(@"Error logined: %@", error); return; } AMQPChannel *channel = [connection openChannel]; AMQPExchange *exchange = [[AMQPExchange alloc] initFanoutExchangeWithName:@"EXCHANGE_NAME" onChannel:channel isPassive:NO isDurable:NO getsAutoDeleted:NO error:&error]; if (error != nil){ NSLog(@"Error declareExchange: %@", error); return; } //AMQPQueue *queue = [[AMQPQueue alloc] initWithName:@"NAME" onChannel:channel isPassive:NO isExclusive:NO isDurable:YES getsAutoDeleted:YES error:&error]; AMQPQueue *queue = [[AMQPQueue alloc] initWithName:@"NAME" onChannel:[connection openChannel]]; if (error != nil){ NSLog(@"Error declare Queue: %@", error); return; } NSError *error ; [queue bindToExchange:exchange withKey:@"KEY" error:&error]; amqp_basic_properties_t props; props._flags= AMQP_BASIC_CLASS; props.type = amqp_cstring_bytes([@"typeOfMessage" UTF8String]); props.priority = 1; [exchange publishMessage:@"Test message" usingRoutingKey:@"ROUTING_KEY" propertiesMessage:props mandatory:NO immediate:NO error:&error]; if (error != nil){ NSLog(@"Error declareExchange: %@", error); return; }