Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove static references to BlockingConnection to allow configured SelectConnection #114

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions neon_mq_connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def create_unique_id():

@classmethod
def emit_mq_message(cls,
connection: pika.BlockingConnection,
connection: Union[pika.BlockingConnection,
pika.SelectConnection],
request_data: dict,
exchange: Optional[str] = '',
queue: Optional[str] = '',
Expand Down Expand Up @@ -389,13 +390,14 @@ def send_message(self,
return msg_id

@retry(use_self=True, num_retries=__run_retries__)
def create_mq_connection(self, vhost: str = '/', **kwargs):
def create_mq_connection(self, vhost: str = '/',
**kwargs) -> pika.BlockingConnection:
"""
Creates MQ Connection on the specified virtual host
Note: Additional parameters can be defined via kwargs.
Creates a Blocking MQ Connection on the specified virtual host
Note: Additional parameters can be defined via kwargs.

:param vhost: address for desired virtual host
:raises Exception if self.config is not set
:param vhost: address for desired virtual host
:raises Exception if self.config is not set
"""
if not self.config:
raise Exception('Configuration is not set')
Expand Down
4 changes: 1 addition & 3 deletions neon_mq_connector/utils/client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class NeonMQHandler(MQConnector):
def __init__(self, config: dict, service_name: str, vhost: str):
super().__init__(config, service_name)
self.vhost = vhost
import pika
self.connection = pika.BlockingConnection(
parameters=self.get_connection_params(vhost))
self.connection = self.create_mq_connection(self.vhost)

def shutdown(self):
MQConnector.stop(self)
Expand Down
Loading