Add optional subscription id

This commit is contained in:
Olivier Verhaegen 2023-04-12 11:43:00 +02:00 committed by GitHub
parent 54ec71f16c
commit bf1b9b230e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -8,6 +8,14 @@
<label for="node-input-topic" style="width: 110px;"><i class="fa fa-envelope"></i> Destination</label>
<input type="text" id="node-input-topic" placeholder="topic or queue">
</div>
<div class="form-row">
<label for="node-input-enable_subscriptionid" style="width: 110px;"><i class="fa fa-envelope"></i> Destination</label>
<input type="checkbox" id="node-input-enable_subscriptionid">
</div>
<div class="form-row">
<label for="node-input-subscriptionid" style="width: 110px;"><i class="fa fa-envelope"></i> Destination</label>
<input type="number" id="node-input-subscriptionid">
</div>
<div class="form-row">
<label for="node-input-name" style="width: 110px;"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@ -33,6 +41,8 @@
defaults: {
name: {value:""},
server: {type:"stomp-server",required:true},
enable_subscriptionid: {value: false},
subscriptionid: {value: 0, required:true},
topic: {value:"",required:true}
},
inputs:0,

View File

@ -28,6 +28,8 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.server = n.server;
this.topic = n.topic;
this.enableSubscriptionId = n.enable_subscriptionid;
this.subscriptionid = n.subscriptionid;
this.serverConfig = RED.nodes.getNode(this.server);
this.stompClientOpts = {
@ -44,7 +46,14 @@ module.exports = function(RED) {
if (this.serverConfig.vhost) {
this.stompClientOpts.vhost = this.serverConfig.vhost;
}
this.subscribeHeaders = this.serverConfig.ack ? { "ack": "client" } : {};
this.subscribeHeaders = {};
if (this.enableSubscriptionId) {
this.subscribeHeaders.id = this.subscriptionid;
}
if (this.serverConfig.ack) {
this.subscribeHeaders.ack = "client";
}
var node = this;
var msg = {topic:this.topic};