PhotoKevin
PhotoKevin

Reputation: 97

OPC UA Subscriptions and Notifications

I'm having trouble with OPC UA Subscriptions and Notifications in the ANSI C stack. OPC UA Part 4, Service says:

5.13.1 Subscription model 5.13.1.1 Description c) NotificationMessages are sent to the Client in response to Publish requests.

Sent how? I'm really expecting a callback of some sort, but there doesn't seem to be one. It does say these are in response to a 'Publish' request, but a Publish service call acknowledges receipt of a notification, it doesn't seem to request one. Besides, that would be polling and the whole point of Subscriptions and Monitoring is to not poll.

Can anyone supply an example showing monitoring of a data value in ANSI C?

Upvotes: 2

Views: 10263

Answers (2)

Kevin Herron
Kevin Herron

Reputation: 6985

PublishRequests are queued on the server and responses are only returned when notifications are ready or a keep-alive needs to be sent (or a bunch of other stuff, check the state machine description in part 4).

They do include acknowledgements of previously received notifications as well, but the idea is that the response isn't expected immediately and that the client will generally keep pumping PublishRequests out so that the server has a queue of them ready to return notifications whenever a subscription needs to.

Yes, it's polling. It's a bit of a bummer that it's not strictly unsolicited, but that's how it works.

__

edit:

It's not really polling. It's batched report by exception with a QoS guarantee and back pressure mechanism provided by subsequent PublishRequests.

Upvotes: 5

Song Young Bin
Song Young Bin

Reputation: 11

This is C# code. I hope that it will help you.

private NotificationMessageReceivedEventHandler
    m_NotificationMessageReceived;

// ...

m_NotificationMessageReceived = 
    new NotificationMessageReceivedEventHandler
       (Subscription_NotificationMessageReceived);
m_subscription.NotificationMessageReceived +=
    Subscription_NotificationMessageReceived;

// ...

private void Subscription_NotificationMessageReceived
    (Subscription subscription,
     NotificationMessageReceivedEventArgs e)
{
    if (e.NotificationMessage.NotificationData == null ||
        e.NotificationMessage.NotificationData.Count == 0)
    {
        LogMessage("{0:HH:mm:ss.fff}: KeepAlive",
                   e.NotificationMessage.PublishTime.ToLocalTime());
    }
}

Upvotes: 1

Related Questions