Skip to content

Releases: jmesnil/stomp-websocket

2.3.4

17 Nov 10:40
Compare
Choose a tag to compare
  • fix Bower packaging

2.3.2

03 Jul 13:49
Compare
Choose a tag to compare
prepare version 2.3.2

Fix computation of UTF-8 string length

18 Feb 13:07
Compare
Choose a tag to compare

fix content-length computation for UTF-8 strings [#44]

Support for node.js app for TCP and Web Sockets

25 Sep 14:31
Compare
Choose a tag to compare

Stomp.js can now be used in node.js app to connect to STOMP brokers over TCP socket or Web Sockets

This version adds the heart-beat feature that was missing in version 2.2.0

Install the package:

$ npm install stompjs

In the node.js app, require the module with:

var Stomp = require('stompjs');

To connect to a STOMP broker over a TCP socket, use the Stomp.overTCP(host, port) method:

var client = Stomp.overTCP('localhost', 61613);

To connect to a STOMP broker over a WebSocket, use instead the Stomp.overWS(url) method:

var client = Stomp.overWS('ws://localhost:61614');

Apart from this initialization, the STOMP API remains the same whether it is running in a Web browser or in node.js application.

Support for node.js app for TCP and Web Sockets

25 Sep 09:38
Compare
Choose a tag to compare

Stomp.js can now be used in node.js app to connect to STOMP brokers over TCP socket or Web Sockets

Install the package:

$ npm install stompjs

In the node.js app, require the module with:

var Stomp = require('stompjs');

To connect to a STOMP broker over a TCP socket, use the Stomp.overTCP(host, port) method:

var client = Stomp.overTCP('localhost', 61613);

To connect to a STOMP broker over a WebSocket, use instead the Stomp.overWS(url) method:

var client = Stomp.overWS('ws://localhost:61614');

Apart from this initialization, the STOMP API remains the same whether it is running in a Web browser or in node.js application.

Simplified stomp.js API

03 Sep 15:44
Compare
Choose a tag to compare

The Stomp API has been updated to make code simpler to write and understand.
The documentation has been updated to reflect the new API.

Simplified API:

Connection

The connect() method accepts different number of arguments to provide a simple API to use in most cases:

client.connect(login, passcode, connectCallback);
client.connect(login, passcode, connectCallback, errorCallback);
client.connect(login, passcode, connectCallback, errorCallback, host);

where login, passcode are strings and connectCallback and errorCallback are functions (some brokers also require to pass a host String).

The connect() method also accepts two other variants if you need to pass additional headers:

client.connect(headers, connectCallback);
client.connect(headers, connectCallback, errorCallback);

where header is a map and connectCallback and errorCallback are functions.

Please note that if you use these forms, you must add the login, passcode (and eventually host) headers yourself:

var headers = {
  login: 'mylogin',
  passcode: 'mypasscode',
  // additional header
  'client-id': 'my-client-id'
};
client.connect(headers, connectCallback);

Acknowledgement

add ack() and nack() methods to the message
object passed to the subscribe callback.

var sub = client.subscribe("/queue/test",
  function(message) {
   // do something with the message
   ...
   // and acknowledge it
   message.ack();
 },
 {ack: 'client'}
);

Unsubscription

Instead of returning an id from client.subscribe(), return
an object with an unsubscribe() method that can be called directly.

var subscription = client.subscribe(...);
...
subscription.unsubscribe();

Transaction

The begin() method returns a JavaScript object with commit() and
abort() methods to complete the transaction.

var tx = client.begin();
message.ack({ transaction: tx.id, receipt: 'my-receipt' });
...
tx.commit(); // or tx.abort();

A transaction ID is automatically generated when calling 'begin() and is available in the returned object's idproperty.

Miscellanous changes and fixes

default onreceive method

When a subscription is automatically created on the broker-side, the received messages are discarded by the Stomp.client that find no matching callback for the subscription headers.
To workaround that, the client can set a default onreceive callback that will be called if no matching subscription is found.
This is required to support RabbitMQ temporary queue destinations.

debug log

By default, debug messages are now written in window.console.

WebWorker support

STOMP can now be used from a WebWorker (an example shows how to use it).

STOMP frame fragmentation

If the STOMP frames are big to send on a single WebSocket frame, some web server may have trouble process them. It is now possible to split a STOMP frame on multiple Web Socket frames by configuring the client.maxWebSocketFrameSize (in bytes). If the STOMP frame is bigger than this size, it will be send over multiple Web Socket frames (default is 16KiB).

use the 1st value for repeated headers

Stomp.js was keeping the last value of repeated headers. This has been fixed according to the specification to take the 1st value of repeated headers.

fix generation of timestamp on IE8

Make sure that timestamp generation works on IE8.