Commit 519d40d8 authored by Manuel's avatar Manuel

traceRetrieval: fixed messagehandler repository

parent 78d74fc2
...@@ -19,12 +19,12 @@ import connexion ...@@ -19,12 +19,12 @@ import connexion
from security import swagger_util from security import swagger_util
from env_info import is_running_locally from env_info import is_running_locally
from database.MongoRepository import MongoRepository from database.repository import Repository
from messaging.MessageHandler import MessageHandler from messaging.MessageHandler import MessageHandler
from messaging.ReconnectingMessageManager import ReconnectingMessageManager from messaging.ReconnectingMessageManager import ReconnectingMessageManager
# init message handler # init message handler
message_handler = MessageHandler(MongoRepository(), ReconnectingMessageManager.getInstance()) message_handler = MessageHandler(Repository(), ReconnectingMessageManager.getInstance())
def message_received_callback(channel, method, properties, body): def message_received_callback(channel, method, properties, body):
message_handler.handle_generic(body) message_handler.handle_generic(body)
......
...@@ -21,8 +21,6 @@ class MessageHandler: ...@@ -21,8 +21,6 @@ class MessageHandler:
_mongo_repo = None _mongo_repo = None
_message_sender = None _message_sender = None
_repository = Repository()
def __init__(self, mongo_repo, message_sender): def __init__(self, mongo_repo, message_sender):
self._mongo_repo = mongo_repo self._mongo_repo = mongo_repo
self._message_sender = message_sender self._message_sender = message_sender
...@@ -153,7 +151,7 @@ class MessageHandler: ...@@ -153,7 +151,7 @@ class MessageHandler:
if "ApplicationType" not in transaction_message.keys(): if "ApplicationType" not in transaction_message.keys():
LOGGER.error("Transaction has no ApplicationType, storing it under use-case 'unknown'.") LOGGER.error("Transaction has no ApplicationType, storing it under use-case 'unknown'.")
transaction_message["ApplicationType"] = "unknown" transaction_message["ApplicationType"] = "unknown"
MessageHandler._repository.add_failed_transaction(transaction_message) self._mongo_repo.add_failed_transaction(transaction_message)
return return
use_case = transaction_message["ApplicationType"] use_case = transaction_message["ApplicationType"]
...@@ -162,14 +160,14 @@ class MessageHandler: ...@@ -162,14 +160,14 @@ class MessageHandler:
data = self._fetch_schema_information(use_case) data = self._fetch_schema_information(use_case)
except ValueError as e: except ValueError as e:
print(f"{e}") print(f"{e}")
MessageHandler._repository.add_failed_transaction(transaction_message) self._mongo_repo.add_failed_transaction(transaction_message)
return return
mappings = data["mappings"] mappings = data["mappings"]
flattened = self._flatten_transaction(transaction_message, mappings) flattened = self._flatten_transaction(transaction_message, mappings)
transaction = Transaction(use_case, flattened) transaction = Transaction(use_case, flattened)
MessageHandler._repository.add_transaction(transaction) self._mongo_repo.add_transaction(transaction)
msg = { msg = {
"type": "new-trace", "type": "new-trace",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment