Skip to content
Snippets Groups Projects
Commit 0aad3215 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SW-720: using old implementation to connect to mom and send the xml specification

parent ca6ab66e
No related branches found
No related tags found
1 merge request!6Import cobalt2 into lofar4
......@@ -26,8 +26,10 @@ 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, ToBus, EventMessage, DEFAULT_BROKER, DEFAULT_BUSNAME, \
from lofar.messaging import RPCService, EventMessage, DEFAULT_BROKER, DEFAULT_BUSNAME, \
ServiceMessageHandler
from lofar.messagebus.messagebus import ToBus as ToBusOld
from lofar.messagebus.message import MessageContent as MessageContentOld
from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC
from lofar.specificationservices.translation_service_rpc import TranslationRPC
from lofar.specificationservices.validation_service_rpc import ValidationRPC
......@@ -139,7 +141,6 @@ class SpecificationHandler(ServiceMessageHandler):
self.validationrpc = ValidationRPC.create(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER)
self.specificationtranslationrpc = TranslationRPC.create(exchange=DEFAULT_BUSNAME,
broker=DEFAULT_BROKER)
self.momimportxml_bus = ToBus(exchange=MOMIMPORTXML_BUSNAME, broker=DEFAULT_BROKER)
def add_specification(self, user, lofar_xml):
logger.info("got specification from user %s", user)
......@@ -253,18 +254,18 @@ class SpecificationHandler(ServiceMessageHandler):
def _add_spec_to_mom(self, mom_xml):
# Construct message payload using old-style (MessageBus) message format
msg = MessageContent()
msg = MessageContentOld()
msg.protocol = "mom.importxml"
msg.from_ = "specification_service"
msg.summary = "Translated LOFAR specifications"
msg.momid = -1
msg.sasid = -1
msg.payload = "\n%s\n" # MoM needs enters around the payload to avoid "Content not allowed in prolog" error
content = msg.content() % (mom_xml,)
msg.payload = "\n%s\n" % (mom_xml, ) # MoM needs enters around the payload to avoid "Content not allowed in prolog" error
emsg = EventMessage(subject=MOMIMPORTXML_SUBJECT, content=content)
with self.momimportxml_bus:
self.momimportxml_bus.send(emsg)
#emsg = MessageOld(subject=MOMIMPORTXML_SUBJECT, content=content)
with ToBusOld(queue=MOMIMPORTXML_BUSNAME, broker=DEFAULT_BROKER) as momimportxml_bus:
momimportxml_bus.send(msg)
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.
Finish editing this message first!
Please register or to comment