diff --git a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py index b10dc6daf59db2ef65951d29b8e99953a8654db7..3a52403c49094bbd9ee76be371eaf7aa45b26cab 100644 --- a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py +++ b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py @@ -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