Autobahn: Subscribing to channels with regex or wildcard pattern

680 Views Asked by At

My question is very simple and straight-forward. In RabbitMQ, we can subscribe to channels using regex or wildcard pattern("Topic" type subscription). So is there any possibility to achieve this in Autobahn ?

2

There are 2 best solutions below

0
On BEST ANSWER

Pattern-based subscriptions are now explained in more detail in its own document which is also referenced from the WAMP IETF draft. Here's an example, quoting from the current AutobahnJS reference:

Pattern-Based Subscriptions

As a default, topic URIs in subscriptions are matched exactly.

It is possible to change the matching policy to either prefix or wildcard matching via an option when subscribing, e.g.

session.subscribe('com.myapp', on_event_all, { match: 'prefix' })
session.subscribe('com.myapp..update', on_event_update, { match: 'wildcard' })

In the first case, events for all publications where the topic contains the prefix com.myapp will be received, in the second events for all publications which match the wildcard pattern, e.g. com.myapp.user121.update and com.myapp.sensor_23.update.

Given the above example is from official AutobahnJS docs, I presume the crossbar.io WAMP router must also have support built-in now.

As for any other WAMP libraries, your mileage will likely vary.

0
On

The WAMP specification is split into 2 parts:

  1. the basic profile, which is stable and mandatory for all implementation to implement fully.
  2. the advanced profile, which is work-in-progress and the features herein are optional for implementations to provide.

Pattern-based subscriptions are part of the WAMP "Advanced Profile", but not yet (2015/01) in the Autobahn WAMP client libraries or the e.g. the Crossbar.io WAMP router (see here).