@@ -9,18 +9,19 @@ @implementation ViewController
9
9
10
10
- (void )viewDidLoad {
11
11
[super viewDidLoad ];
12
- RMQConnection *conn = [[RMQConnection alloc ] initWithDelegate: [RMQConnectionDelegateLogger new ]];
13
- [conn start ];
14
12
15
- [self receiveLogsTopic: conn routingKeys: @[@" kern.*" , @" *.critical" ]];
13
+ [self receiveLogsTopic: @[@" kern.*" , @" *.critical" ]];
16
14
sleep (2 );
17
- [self emitLogTopic: conn message: @" Hello World!" routingKey: @" kern.info" ];
18
- [self emitLogTopic: conn message: @" A critical kernel error" routingKey: @" kern.critical" ];
19
- [self emitLogTopic: conn message: @" Critical module error" routingKey: @" somemod.critical" ];
20
- [self emitLogTopic: conn message: @" Just some module info. You won't get this." routingKey: @" somemod.info" ];
15
+ [self emitLogTopic: @" Hello World!" routingKey: @" kern.info" ];
16
+ [self emitLogTopic: @" A critical kernel error" routingKey: @" kern.critical" ];
17
+ [self emitLogTopic: @" Critical module error" routingKey: @" somemod.critical" ];
18
+ [self emitLogTopic: @" Just some module info. You won't get this." routingKey: @" somemod.info" ];
21
19
}
22
20
23
- - (void )receiveLogsTopic : (RMQConnection *)conn routingKeys : (NSArray *)routingKeys {
21
+ - (void )receiveLogsTopic : (NSArray *)routingKeys {
22
+ RMQConnection *conn = [[RMQConnection alloc ] initWithDelegate: [RMQConnectionDelegateLogger new ]];
23
+ [conn start ];
24
+
24
25
id <RMQChannel> ch = [conn createChannel ];
25
26
RMQExchange *x = [ch topic: @" topic_logs" ];
26
27
RMQQueue *q = [ch queue: @" " options: RMQQueueDeclareExclusive];
@@ -36,7 +37,10 @@ - (void)receiveLogsTopic:(RMQConnection *)conn routingKeys:(NSArray *)routingKey
36
37
}];
37
38
}
38
39
39
- - (void )emitLogTopic : (RMQConnection *)conn message : (NSString *)msg routingKey : (NSString *)routingKey {
40
+ - (void )emitLogTopic : (NSString *)msg routingKey : (NSString *)routingKey {
41
+ RMQConnection *conn = [[RMQConnection alloc ] initWithDelegate: [RMQConnectionDelegateLogger new ]];
42
+ [conn start ];
43
+
40
44
id <RMQChannel> ch = [conn createChannel ];
41
45
RMQExchange *x = [ch topic: @" topic_logs" ];
42
46
0 commit comments