Updates to attribute events

Hi OR team

Looking through the git commits I noticed that there have been a lot of changes to the AttributeEvents model. I was working on a custom mqtt handler and ran into an issue where I wanted my handler to subscribe to attributeEvents and filter them by source of (client or gateway) these values would then be published back to the device. I was not able to do this successfully and had to have a very hacky cache of the most recent value from the device check to see if it was different and the publish.

So my question now: Is it possible to subscribe to attribute events and filter by source?

Hi,

Indeed there have been a few model changes and some structural ones, things should be covered in this forum post:

To answer your question then you can use the ClientEventService and the addInternalSubscription() method with a custom EventFilter.

Might also be worth looking at the DefaultMQTTHandler which handles the standard attribute topics and uses the ClientEventService to do this.

Not sure of your exact use case but there is also a new interface called AttributeEventInterceptor which the built in GatewayService uses to intercept AttributeEvents coming through the system that are destined for a gateway (AgentService also uses this mechanism to intercept writes destined for agent link attributes).

You can now use AttributeEvent.getSource() to see where an AttributeEvent orginated, this is a string but generally it is the simple class name of the source, might need to look through the code to see what it will be for events you are interested in.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.