File tree 3 files changed +56
-0
lines changed
3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace RShief \Nab3aBundle \RabbitMq ;
4
+
5
+ use RShief \Nab3aBundle \Evenement \PluginInterface ;
6
+ use Evenement \EventEmitterInterface ;
7
+ use OldSound \RabbitMqBundle \RabbitMq \ProducerInterface ;
8
+
9
+ class EnqueueTweetPlugin implements PluginInterface
10
+ {
11
+ /**
12
+ * @var ProducerInterface
13
+ */
14
+ private $ producer ;
15
+ /**
16
+ * @var string
17
+ */
18
+ private $ routingKey ;
19
+ /**
20
+ * @var array
21
+ */
22
+ private $ additionalProperties ;
23
+
24
+ public function __construct (ProducerInterface $ producer , $ routingKey = '' , $ additionalProperties = array ())
25
+ {
26
+ $ this ->producer = $ producer ;
27
+ $ this ->routingKey = $ routingKey ;
28
+ $ this ->additionalProperties = $ additionalProperties ;
29
+ }
30
+
31
+ public function attachEvents (EventEmitterInterface $ emitter )
32
+ {
33
+ $ emitter ->on ('tweet ' , function ($ data ) {
34
+ $ data = json_encode ($ data );
35
+ $ this ->producer ->publish ($ data , $ this ->routingKey , $ this ->additionalProperties );
36
+ });
37
+ }
38
+
39
+ /**
40
+ * @param $data
41
+ */
42
+ private function enqueue ($ data )
43
+ {
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ services :
2
+ nab3a.twitter.message_emitter.plugin.rabbitmq :
3
+ class : RShief\Nab3aBundle\RabbitMq\EnqueueTweetPlugin
4
+ arguments :
5
+ - ' @old_sound_rabbit_mq.twitter_producer'
6
+ - ' twitter'
7
+ - { content_type: 'application/json' }
8
+ public : false
9
+ tags :
10
+ - { name: evenement.plugin, id: nab3a.twitter.message_emitter }
Original file line number Diff line number Diff line change 4
4
- { resource: console.yml }
5
5
- { resource: stream.yml }
6
6
- { resource: event_loop.yml }
7
+ - { resource: rabbitmq.yml }
7
8
8
9
services :
9
10
nab3a.standalone.parameters :
You can’t perform that action at this time.
0 commit comments