Retained events with pattern-based subscriptions

#1

I’ve noticed some interesting edge cases around retained events and pattern-based subscriptions. As an example:

Node 1 publishes message A to topic ‘myprefix.A’ with PublishOptions(retain=True)
Node 1 publishes message B to topic ‘myprefix.B’ with PublishOptions(retain=True)

Node 2 subscribes to ‘myprefix’ with SubscribeOptions(match=‘prefix’, get_retained=True)

My naive expected behaviour was that Node 2 would immediately receive messages A and B.

The spec suggests that, at the least, Node 2 should receive message B:

When they opt-in to receiving the Retained Event, the Broker MUST send the Subscriber the most recent Retained Event that they would have received if they were subscribing when it was published.

(emphasis original) - “if they were subscribing when it was published” here includes both messages A and B, the most recent of which is B.

A further observation is that, if now Node 1 published message C to topic ‘myprefix.C’ with PublishOptions(retain=True), then Node 2 receives the message, but the EventDetails object has retained=False, whereas I would have expected it to contain retained=True.

It looks like retained events are only really supported for exact-match subscriptions - https://github.com/crossbario/crossbar/blob/master/crossbar/router/broker.py#L457 doesn’t include a match argument in the call to get_observation, so it defaults to exact. Retained events are stored against observations, rather than “bound to the topic it was sent to”.

So I suppose my questions are:

  • Is the current behaviour expected?

  • Is the current behaviour in line with the spec?

  • Will Crossbar ever support using retained events in the way I describe?

  • Are there alternative methods to achieving the same goal (Node 2 receiving A and B at the point of subscription)?

Thanks,

James

0 Likes

#2

This sounds like a bug, consider filing an issue.

0 Likes

#3

Thanks! I’ve now done so - https://github.com/crossbario/crossbar/issues/1242.

···

On Tuesday, 23 January 2018 04:10:09 UTC, Adam Jorgensen wrote:

This sounds like a bug, consider filing an issue.

0 Likes