0

I have 2 VOLTTRON agents on a single machine deployment created with the agent creation wizard.

I have one agent publishing to the pubsub message bus a string and on the listeragent the string is Message:'6/8/54' looks like this:

2021-12-26 08:54:33,462 (listeneragent-3.3 22947) __main__ INFO: Peer: pubsub, Sender: platform.checkeragent:, Bus: , Topic: fsm/control/topic, Headers: {'min_compatible_version': '3.0', 'max_compatible_version': ''}, Message:
'6/8/54'

Where I am struggling is on a different VOLTTRON agent (platform.fsmagent) trying to subscribe to receive this Message:'6/8/54' information/data through message bus subscription of the original sender (platform.checkeragent). All internal VOLTTRON message bus on a single machine deployment.

What am I doing wrong on the VOLTTRON agent (platform.fsmagent) trying to receive the info Message by listening to the bus? My on "onstart" looks like this below in the code snip. Am not having any luck trying to subscribe to the topic or the sender.

@Core.receiver("onstart")
def onstart(self, sender, **kwargs):

    # subscribe to this sender VOLTTRON agent
    self._create_subscriptions("platform.checkeragent")

And my _create_subscriptions method looks like this with the _handle_publish callback:

def _create_subscriptions(self, sender):

    _log.debug(f'[FSM AGENT] -  _create_subscriptions {sender}')
    self.vip.pubsub.subscribe(peer='pubsub',
                            sender=sender,
                            callback=self._handle_publish) 

And my _handle_publish callback looks like this:

def _handle_publish(self, peer, sender, bus, topic, headers, message):

    _log.debug(f"[FSM AGENT] - topic_formatted {topic}")
    _log.debug(f"[FSM AGENT] - message {message}")

But in the VOLTTRON log these debug messages in the _handle_publish callback are not getting printed to the log. Do I need to loop through topics in this callback? No errors its just catching anything which I am hoping to the Message:'6/8/54'

When I install the platform.fsmagent agent , I see debug statements that the subscriptions seem OK.

2021-12-26 08:52:45,177 (fsmagentagent-0.1 59147) __main__ DEBUG: [FSM AGENT] -  _create_subscriptions platform.checkeragent
2021-12-26 08:52:45,178 (fsmagentagent-0.1 59147) __main__ DEBUG: [FSM AGENT] - Onstart FSM Machine SUCCESS!

My vctl status looks like this:

UUID AGENT                 IDENTITY              TAG      STATUS          HEALTH
0 actuatoragent-1.0     platform.actuator     actuator running [52337] GOOD
c bacnet_proxyagent-0.5 platform.bacnet_proxy proxy    running [23089] GOOD
1 checkeragentagent-0.1 platform.checkeragent checker  running [57410] GOOD
f fsmagentagent-0.1     platform.fsmagent     fsm      running [59147]
8 listeneragent-3.3     listeneragent-3.3_1   listener running [22947] GOOD
bbartling
  • 3,288
  • 9
  • 43
  • 88

1 Answers1

0

When subscribing to the message bus you subscribe to a topic prefix. Based on the listener agent output you posted, the sender (platform.checkeragent agent) is publishing to the Topic "fsm/control/topic". To subscribe to that specific topic you should modify your subscribe statement in platform.fsmagent to

self.vip.pubsub.subscribe(peer='pubsub',
                           prefix='fsm/control/topic',
                           callback=cb)

you can also provide a topic prefix such as 'fsm' or 'fsm/control' to receive messages posted to all subtopics.

To subscribe you can also use the decorator @PubSub.subscribe('pubsub', 'fsm/control/topic') on top of the _handle_publish method. if you leave the prefix empty then it subscribes to all topics. This is what the Listener agent does.

chandrika
  • 218
  • 1
  • 5