Closed fmesnata closed 4 years ago
The second parameter is headers that is sent to the broker as part of the subscription request. So, you need to check if the broker implements filtering. These operations are broker specific in terms of capability and syntax.
On the other hand if your broker does not support these, you can filter in your code using RxJS operations (pipe
and filter
). In this case your client will receive all messages but will get filtered before your handler is called.
I try to filter messages coming from a topic using headers. I didn't find documentation about this using rxStomp and I presume it should works like stompjs so I tried this way https://stomp-js.github.io/stomp-websocket/codo/extra/docs-src/Usage.md.html#toc_9.
My code :
and the message never arrived.
If I remove headers selectors, the message arrive and I can see that headers are present (from firefox developers tool) :
a["MESSAGE\ndestination:/user/topic/lobby.players.me\ncountry:france\ncontent-type:application/json\nsubscription:sub-1\nmessage-id:hj2rymoy-0\ncontent-length:87\n\n{\"id\":\"farid#06001a20-ea95-4cec-b96c-f0b24ad0b3aa\",\"username\":\"farid\",\"state\":\"ONLINE\"}\u0000"]
I tried other notations like :
but no one worked.
Do you know what am I doing wrong?