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

SW-720: use old messagebus ToBus to send the specification xml message...

SW-720: use old messagebus ToBus to send the specification xml message directly to mom.importxml at lcs023
parent 266e24eb
Branches
Tags
1 merge request!4Lofar release 4 0 minor fixes
......@@ -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"
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment