@yarkivaev/source-to-sink 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarkivaev/source-to-sink",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Generic library for building data streaming pipelines",
5
5
  "repository": {
6
6
  "type": "git",
package/src/stompSend.js CHANGED
@@ -7,6 +7,20 @@ import stompit from 'stompit';
7
7
  * @param {object} options - Connection options
8
8
  * @returns {object} stompit connect parameters
9
9
  */
10
+ /**
11
+ * STOMP SEND headers that persist the body on a durable RabbitMQ queue.
12
+ *
13
+ * @param {string} destination - STOMP destination
14
+ * @returns {object} headers including persistent true
15
+ */
16
+ export function stompHeaders(destination) {
17
+ return {
18
+ destination,
19
+ 'content-type': 'application/json',
20
+ persistent: 'true'
21
+ };
22
+ }
23
+
10
24
  function connectParams(parsed, options) {
11
25
  return {
12
26
  host: parsed.hostname,
@@ -55,10 +69,7 @@ export default function stompSend(url, destination, payload, options = {}) {
55
69
  reject(error);
56
70
  return;
57
71
  }
58
- const frame = client.send({
59
- destination,
60
- 'content-type': 'application/json'
61
- });
72
+ const frame = client.send(stompHeaders(destination));
62
73
  frame.end(body);
63
74
  client.disconnect((disconnectError) => {
64
75
  if (disconnectError) {
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { describe, it } from 'mocha';
3
- import stompSend from '../src/stompSend.js';
3
+ import stompSend, { stompHeaders } from '../src/stompSend.js';
4
4
 
5
5
  describe('stompSend', () => {
6
6
  it('throws on missing url', () => {
@@ -23,6 +23,15 @@ describe('stompSend', () => {
23
23
  );
24
24
  });
25
25
 
26
+ it('marks SEND frames persistent', () => {
27
+ const destination = `/exchange/\u00e9${Math.random().toString(36).slice(2)}`;
28
+ assert.strictEqual(
29
+ stompHeaders(destination).persistent,
30
+ 'true',
31
+ 'stompSend did not mark the frame persistent'
32
+ );
33
+ });
34
+
26
35
  it('returns a promise', () => {
27
36
  const pending = stompSend(
28
37
  `stomp://\u00e9${Math.random()}:61613`,