Skip to content
Snippets Groups Projects
Commit 3b0a82fa authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-421: removed _send_state_change_event_message because the TMSSPGListener does that for us now.

parent c021622a
No related branches found
No related tags found
1 merge request!262Resolve TMSS-421
......@@ -18,10 +18,6 @@ from django.db.models.expressions import RawSQL
from django.core.exceptions import ValidationError
from lofar.sas.tmss.tmss.exceptions import SubtaskSchedulingException
from lofar.messaging.messagebus import ToBus, DEFAULT_BROKER, DEFAULT_BUSNAME
from lofar.messaging.messages import EventMessage
from lofar.sas.tmss.client.tmssbuslistener import DEFAULT_TMSS_SUBTASK_NOTIFICATION_PREFIX
from lofar.common.util import single_line_with_single_spaces
from django.conf import settings
from lofar.sas.resourceassignment.resourceassignmentservice.rpc import RADBRPC
#
......@@ -158,17 +154,6 @@ class Subtask(BasicCommon):
# keep original state for logging
self.__original_state_id = self.state_id
@staticmethod
def _send_state_change_event_message(subtask_id:int, old_state: str, new_state: str):
with ToBus(exchange=os.environ.get("TMSS_EXCHANGE", DEFAULT_BUSNAME),
broker=os.environ.get("TMSS_BROKER", DEFAULT_BROKER)) as tobus: #TODO: do we want to connect to the bus for each new message, or have some global tobus?
msg = EventMessage(subject="%s.%s" % (DEFAULT_TMSS_SUBTASK_NOTIFICATION_PREFIX, new_state.capitalize()),
content={'subtask_id': subtask_id, 'old_state': old_state, 'new_state': new_state})
address = tobus.remote_address
logger.info("Sending message with subject '%s' to exchange='%s' on broker=%s:%s content: %s",
msg.subject, tobus.exchange, address[0], address[1], single_line_with_single_spaces(msg.content))
tobus.send(msg)
@property
def successors(self) -> QuerySet:
'''return the connect successor subtask(s) as queryset (over which you can perform extended queries, or return via the serializers/viewsets)
......@@ -229,11 +214,6 @@ class Subtask(BasicCommon):
user=self.created_or_updated_by_user, user_identifier=identifier)
log_entry.save()
try:
self._send_state_change_event_message(self.id, log_entry.old_state.value, log_entry.new_state.value)
except Exception as e:
logger.error("Could not send state change to messagebus: %s", e)
# update the previous state value
self.__original_state_id = self.state_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment