Search code examples
autobahnautobahnws

Autobahn: Subscribing to channels with regex or wildcard pattern


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 ?


Solution

  • 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.