@@ -27,6 +27,9 @@ class AMQPLogstashHandler(SocketHandler, object):
2727 :param exchange_type: AMQP exchange type (default 'fanout').
2828 :param durable: AMQP exchange is durable (default False)
2929 :param virtual_host: AMQP virtual host (default '/').
30+ :param passive: exchange is declared passively, meaning that an error is
31+ raised if the exchange does not exist, and succeeds otherwise. This is
32+ useful if the user does not have configure permission on the exchange.
3033
3134 :param tags: list of tags for a logger (default is None).
3235 :param message_type: The type of the message (default logstash).
@@ -43,8 +46,8 @@ class AMQPLogstashHandler(SocketHandler, object):
4346 def __init__ (self , host = 'localhost' , port = 5672 , username = 'guest' ,
4447 password = 'guest' , exchange = 'logstash' , exchange_type = 'fanout' ,
4548 virtual_host = '/' , message_type = 'logstash' , tags = None ,
46- durable = False , version = 0 , extra_fields = True , fqdn = False ,
47- facility = None , exchange_routing_key = '' ):
49+ durable = False , passive = False , version = 0 , extra_fields = True ,
50+ fqdn = False , facility = None , exchange_routing_key = '' ):
4851
4952
5053 # AMQP parameters
@@ -55,6 +58,7 @@ def __init__(self, host='localhost', port=5672, username='guest',
5558 self .exchange_type = exchange_type
5659 self .exchange = exchange
5760 self .exchange_is_durable = durable
61+ self .declare_exchange_passively = passive
5862 self .virtual_host = virtual_host
5963 self .routing_key = exchange_routing_key
6064
@@ -81,6 +85,7 @@ def makeSocket(self, **kwargs):
8185 self .exchange ,
8286 self .routing_key ,
8387 self .exchange_is_durable ,
88+ self .declare_exchange_passively ,
8489 self .exchange_type )
8590
8691 def makePickle (self , record ):
@@ -90,7 +95,7 @@ def makePickle(self, record):
9095class PikaSocket (object ):
9196
9297 def __init__ (self , host , port , username , password , virtual_host , exchange ,
93- routing_key , durable , exchange_type ):
98+ routing_key , durable , passive , exchange_type ):
9499
95100 # create connection parameters
96101 credentials = pika .PlainCredentials (username , password )
@@ -104,6 +109,7 @@ def __init__(self, host, port, username, password, virtual_host, exchange,
104109 # create an exchange, if needed
105110 self .channel .exchange_declare (exchange = exchange ,
106111 exchange_type = exchange_type ,
112+ passive = passive ,
107113 durable = durable )
108114
109115 # needed when publishing
0 commit comments