@@ -34,7 +34,7 @@ class RabbitMQInput < Input
34
34
config_param :user , :string , default : nil
35
35
config_param :pass , :string , default : nil , secret : true
36
36
config_param :vhost , :string , default : nil
37
- config_param :exchange , :string , default : nil
37
+
38
38
config_param :routing_key , :string , default : nil
39
39
config_param :connection_timeout , :time , default : nil
40
40
config_param :continuation_timeout , :integer , default : nil
@@ -47,6 +47,13 @@ class RabbitMQInput < Input
47
47
end
48
48
config_param :consumer_pool_size , :integer , default : nil
49
49
50
+ config_param :exchange , :string , default : nil
51
+ config_param :create_exchange , :bool , default : false
52
+ config_param :exchange_to_bind , :string , default : nil
53
+ config_param :exchange_type , :string , default : "topic"
54
+ config_param :exchange_routing_key , :string , default : nil
55
+ config_param :exchange_durable , :bool , default : false
56
+
50
57
config_param :tls , :bool , default : false
51
58
config_param :tls_cert , :string , default : nil
52
59
config_param :tls_key , :string , default : nil
@@ -57,8 +64,7 @@ class RabbitMQInput < Input
57
64
config_param :durable , :bool , default : false
58
65
config_param :exclusive , :bool , default : false
59
66
config_param :auto_delete , :bool , default : false
60
-
61
- config_param :prefetch_count , :integer , default : nil
67
+ config_param :ttl , :integer , default : nil
62
68
63
69
config_param :include_headers , :bool , default : false
64
70
config_param :headers_key , :string , default : "headers"
@@ -106,11 +112,23 @@ def start
106
112
@bunny . start
107
113
channel = @bunny . create_channel ( nil , @consumer_pool_size )
108
114
channel . prefetch ( @prefetch_count ) if @prefetch_count
115
+ if @create_exchange
116
+ exchange_options = {
117
+ durable : @exchange_durable ,
118
+ auto_delete : @auto_delete
119
+ }
120
+ @bunny_exchange = Bunny ::Exchange . new ( channel , @exchange_type , @exchange , exchange_options )
121
+ if @exchange_to_bind
122
+ @bunny_exchange . bind ( @exchange_to_bind , routing_key : @exchange_routing_key )
123
+ end
124
+ end
125
+ queue_arguments = { "x-message-ttl" => @ttl } if @ttl
109
126
queue = channel . queue (
110
127
@queue ,
111
128
durable : @durable ,
112
129
exclusive : @exclusive ,
113
- auto_delete : @auto_delete
130
+ auto_delete : @auto_delete ,
131
+ arguments : queue_arguments
114
132
)
115
133
if @exchange
116
134
queue . bind ( @exchange , routing_key : @routing_key )
0 commit comments