Skip to content

Commit 14ec7c6

Browse files
committed
Add virtual host to connection
Add virtual host to connection
1 parent 4e8377b commit 14ec7c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

b_rabbit/b_rabbit.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ def __init__(
4343
port: int = 5672,
4444
user: str = None,
4545
password: str = None,
46+
virtual_host: str = None,
4647
):
4748

4849
"""
4950
Wrapper class to store the connection to server globally.
5051
:param str host: Hostname of RabbitMQ Server
5152
:param int port: Port of RabbitMQ Server
5253
"""
53-
54-
if user != None:
54+
if virtual_host != None:
55+
self.connection = rabbitpy.Connection(
56+
"amqp://{}:{}@{}:{}/{}".format(user, password, host, str(port), virtual_host)
57+
)
58+
elif user != None:
5559
self.connection = rabbitpy.Connection(
5660
"amqp://{}:{}@{}:{}/".format(user, password, host, str(port))
5761
)

0 commit comments

Comments
 (0)