SolaceDev / solace-dev-tutorials

Repo for Solace Tutorials. Located at tutorials.solace.dev
MIT License
7 stars 8 forks source link

Topic to queue mapping in JS (tutorial) #95

Open gszol opened 3 years ago

gszol commented 3 years ago

Hi,

The upcomig solclientjs release (10.8.0) adds topic to queue mapping support to the solclientjs API, for both the browser and node platforms.

This means the relevant tutorial page will need an update: https://tutorials.solace.dev/javascript/topic-to-queue-mapping/#Topic-to-Queue-Mapping-and-the-JavaScript-API https://tutorials.solace.dev/nodejs/topic-to-queue-mapping/#Topic-to-Queue-Mapping-and-Nodejs

The new mechanism requires the establishment of a MessageConsumer to the queue, and invoking the addSubscription()/removeSubscription() methods on it. These operations are idempotent, they report success if the queue is already subscribed/unsubscribed.

Here's a brief example modifying the QueueConsumer.js example, but you'll probably want a separate tutorial instead of complicating the basic one: https://github.com/gszol/solace-samples-nodejs/commit/ae88dddb2b83e96bc642d412ce9d3e5d5c798d0c

Also the same release lifts the restriction on durable queue/TE creation. The syntax is the same as it always has been for temporary queues/TEs. The only difference is a new bindProperty flag, "createIfMissing", defaulting to false for backwards compatibility. (it must be explicitly set to true to enable the new functionality.)

I modified the NoLocal sample to demonstrate, but we probably don't want to do that publicly:

$ git diff src/features/NoLocalPubSub.js diff --git a/src/features/NoLocalPubSub.js b/src/features/NoLocalPubSub.js index 3dc549d..597997a 100644 --- a/src/features/NoLocalPubSub.js +++ b/src/features/NoLocalPubSub.js @@ -137,12 +137,13 @@ var NoLocalPubSub = function (solaceModule, topicName) { if (params.isConsumerFlag) { // Create the message consumer with NoLocal SET var messageConsumer = session.createMessageConsumer({