diff --git a/SAS/SpecificationServices/lib/config.py b/SAS/SpecificationServices/lib/config.py index ea15b3bffc92c017756d542a4ae2cc94967116ac..19760d378174b60d0e71f4d2e36264fc4f4b427a 100644 --- a/SAS/SpecificationServices/lib/config.py +++ b/SAS/SpecificationServices/lib/config.py @@ -11,7 +11,7 @@ SPECIFICATIONTRANSLATION_SERVICENAME = "specificationtranslationservice" # TODO: mom.importxml does not prepend "test." on the test system? MOMIMPORTXML_BUSNAME = "mom.importxml" -MOMIMPORTXML_SUBJECT = "add specification" +MOMIMPORTXML_BROKER = "lcs023.control.lofar" # XSD paths (for validation service) TRIGGER_XSD = "$LOFARROOT/share/SAS/LofarTrigger.xsd" diff --git a/SAS/SpecificationServices/lib/specification_service.py b/SAS/SpecificationServices/lib/specification_service.py index afb8d9c516f2a01d109876693ef690d80ead8835..1f995c8d03151e6ae87d05ed6813f70ebb195143 100644 --- a/SAS/SpecificationServices/lib/specification_service.py +++ b/SAS/SpecificationServices/lib/specification_service.py @@ -26,8 +26,7 @@ from io import BytesIO from lofar.common.util import waitForInterrupt # TODO: mom.importxml uses old messaging interface from lofar.messagebus.message import MessageContent -from lofar.messaging import RPCService, EventMessage, DEFAULT_BROKER, DEFAULT_BUSNAME, \ - ServiceMessageHandler +from lofar.messaging import RPCService, DEFAULT_BUSNAME, DEFAULT_BROKER, ServiceMessageHandler from lofar.messagebus.messagebus import ToBus as ToBusOld from lofar.messagebus.message import MessageContent as MessageContentOld from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC @@ -35,10 +34,7 @@ from lofar.specificationservices.translation_service_rpc import TranslationRPC from lofar.specificationservices.validation_service_rpc import ValidationRPC from lofar.common.xmlparse import parse_xml_string_or_bytestring -from .config import \ - SPECIFICATION_SERVICENAME, \ - MOMIMPORTXML_BUSNAME, \ - MOMIMPORTXML_SUBJECT +from .config import SPECIFICATION_SERVICENAME, MOMIMPORTXML_BUSNAME, MOMIMPORTXML_BROKER permitted_activities = ["observation", "pipeline", "measurement"] permitted_statuses = ["opened", "approved"] @@ -253,6 +249,7 @@ class SpecificationHandler(ServiceMessageHandler): raise Exception("Invalid MoM specification: %s", response["error"]) def _add_spec_to_mom(self, mom_xml): + logger.info("about to send mom_xml: %s", mom_xml) # Construct message payload using old-style (MessageBus) message format msg = MessageContentOld() msg.protocol = "mom.importxml" @@ -260,12 +257,19 @@ class SpecificationHandler(ServiceMessageHandler): msg.summary = "Translated LOFAR specifications" msg.momid = -1 msg.sasid = -1 - msg.payload = "\n%s\n" % (mom_xml, ) # MoM needs enters around the payload to avoid "Content not allowed in prolog" error - #emsg = MessageOld(subject=MOMIMPORTXML_SUBJECT, content=content) + # prepare payload in xml to have a %s which can be filled in with plain xml in the qmsg below... + # MoM needs enters around the payload to avoid "Content not allowed in prolog" error + msg.payload = "\n%s\n" - with ToBusOld(queue=MOMIMPORTXML_BUSNAME, broker=DEFAULT_BROKER) as momimportxml_bus: - momimportxml_bus.send(msg) + # convert to qpid message (which is a proton message nowadays) + qmsg = msg.qpidMsg() + # and inject the mom_xml in the message xml + qmsg.body = qmsg.body % (mom_xml, ) + + with ToBusOld(queue=MOMIMPORTXML_BUSNAME, + broker=MOMIMPORTXML_BROKER) as momimportxml_bus: + momimportxml_bus.send(qmsg) logger.debug("Send specs to MOM: %s", mom_xml)