STOMP refactor in accordance with MQTT (shared connection using config node) + client ACK (#988)

* Bugfix: show connected state after reconnect

* Bugfix: show connected state for stomp out node after reconnect

* Add support for ACK messages

* Add optional subscription id

* Typo fix

* Subscription ID not required

* Bugfix "node.ack is not a fuction"

* Use shared client connection

* Bugfix shared connection

* Improvements & bugfixes to shared connection

* Bugfix connecting state

* Set connected state in connect callback

* Typo fix

* add server shared connection variables

* Bugfix for shared state

* WIP

* Complete refactor based on MQTT nodes to be able to share server connection between nodes

* Change address back to server for backwards compatibility

* Fixes for race conditions on node closing

* Add disconnect timeout of 2s to avoid "Error stopping node"

* If not connected, do not try to disconnect

* Fix for disconnecting log

* Styling fix for ack select form row

* Typo fixes

* Typo fix

* Bugfix: subscription before connected

* Bugfix: stringify payload before sending to be able to send numbers etc

* Bugfix: not saving ack field

* Bugfix: ack

* Bugfix: ack

* Bugfix: ack & better docs regardign ack

* BugFix: reconnect delay

* Improvements regarding cleanup on close

* Handle connect and reconnect event in the same way

* Typo fix

* Fix backwards compatibility
This commit is contained in:
Olivier Verhaegen
2023-05-30 12:05:25 +02:00
committed by GitHub
parent 490a3d8d37
commit 0d7f0cb16d
2 changed files with 554 additions and 127 deletions

View File

@@ -8,6 +8,18 @@
<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-ack" style="width: 110px;"><i class="fa fa-check"></i> Message acknowledgment</label>
<select type="text" id="node-input-ack" style="display: inline-block; width: 250px; vertical-align: top;">
<option value="auto">Auto</option>
<option value="client">Client</option>
<option value="client-individual">Client individual (only v1.1)</option>
</select>
</div>
<div class="form-tips">
Enabling the ACK (acknowledgment) will set the <code>ack</code> header to <code>client</code> while subscribing to topics.
This means the items on the broker queue will not be dequeue'd unless an ACK message is sent using the <code>ack</code> node.
</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 +45,7 @@
defaults: {
name: {value:""},
server: {type:"stomp-server",required:true},
ack: {value: "auto", required: true},
topic: {value:"",required:true}
},
inputs:0,
@@ -148,8 +161,8 @@
port: {value:61613,required:true,validate:RED.validators.number()},
protocolversion: {value:"1.0",required:true},
vhost: {},
reconnectretries: {value:"0",required:true,validate:RED.validators.number()},
reconnectdelay: {value:"0.5",required:true,validate:RED.validators.number()},
reconnectretries: {value:0,required:true,validate:RED.validators.number()},
reconnectdelay: {value:1,required:true,validate:RED.validators.number()},
name: {}
},
credentials: {
@@ -161,3 +174,56 @@
}
});
</script>
<script type="text/html" data-template-name="stomp ack">
<div class="form-row">
<label for="node-input-server" style="width: 110px;"><i class="fa fa-bookmark"></i> Server</label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<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-name" style="width: 110px;"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="stomp ack">
<p>
ACK is used to acknowledge consumption of a message from a subscription using client acknowledgment. When a client has issued a SUBSCRIBE frame with the ack header set to client any messages received from that destination will not be considered to have been consumed (by the server) until the message has been acknowledged via an ACK.
</p>
<p>
The node allows for following inputs:
<ul>
<li><code>msg.messageId</code>: The id of the message to acknowledge</li>
<li><code>msg.transaction</code>: Optional transaction name</li>
</ul>
</p>
<p>
See the <a href="https://stomp.github.io/stomp-specification-1.0.html#frame-ACK" target="new">Stomp 1.0 spec</a> for more details.
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('stomp ack',{
category: 'output',
color:"#e8cfe8",
defaults: {
name: {value:""},
server: {type:"stomp-server",required:true},
topic: {value:""}
},
inputs:1,
outputs:0,
icon: "bridge.png",
align: "right",
label: function() {
return this.name||"stomp";
},
labelStyle: function() {
return (this.name)?"node_label_italic":"";
}
});
</script>