1
+ <?php
2
+
3
+ namespace NavJobs \RabbitMessenger ;
4
+
5
+ use Illuminate \Support \ServiceProvider ;
6
+ use PhpAmqpLib \Connection \AMQPStreamConnection ;
7
+
8
+ class RabbitMessengerLumenServiceProvider extends ServiceProvider
9
+ {
10
+ /**
11
+ * Bootstrap the application services.
12
+ */
13
+ public function boot ()
14
+ {
15
+ }
16
+
17
+ /**
18
+ * Register the application services.
19
+ */
20
+ public function register ()
21
+ {
22
+ $ this ->app ->configure ('rabbit-messenger ' );
23
+ $ this ->mergeConfigFrom (__DIR__ .'/../config/rabbit-messenger.php ' , 'rabbit-messenger ' );
24
+
25
+ $ this ->app ->bind (AMQPStreamConnection::class, function ($ app ) {
26
+ return new AMQPStreamConnection (
27
+ config ('rabbit-messenger.host ' ),
28
+ config ('rabbit-messenger.port ' ),
29
+ config ('rabbit-messenger.user ' ),
30
+ config ('rabbit-messenger.password ' ),
31
+ $ vhost = '/ ' ,
32
+ $ insist = false ,
33
+ $ login_method = 'AMQPLAIN ' ,
34
+ $ login_response = null ,
35
+ $ locale = 'en_US ' ,
36
+ $ connection_timeout = 60 ,
37
+ $ read_write_timeout = 60 ,
38
+ $ context = null ,
39
+ $ keepalive = false ,
40
+ $ heartbeat = 30
41
+ );
42
+ });
43
+
44
+ $ this ->app ->bind ('command.rabbit.consume ' , function ($ app ) {
45
+ return $ app ['NavJobs\RabbitMessenger\Commands\Consumer ' ];
46
+ });
47
+
48
+ $ this ->commands ('command.rabbit.consume ' );
49
+ }
50
+ }
0 commit comments