IPWorks IoT 2020 JavaScript Edition

Questions / Feedback?

Subscribe Method

Subscribes to a message destination on the server.


async stomp.subscribe(destination : string, requireAcks : boolean): Promise<string>


This method is used to subscribe to the specified message Destination on the server. The Id of the subscription is returned.

Once subscribed, the Subscribed event will fire and an item will be added to the Subscription* properties. The MessageIn event will fire anytime a message is received for any subscription.

The STOMP specification does not place any restrictions on Destination names. Instead, each STOMP server is free to define its own requirements for, and/or interpretations of, a Destination name; for example, a server might prohibit certain characters, require a specific format, or interpret some patterns in a special manner. Be sure to consult the documentation for your STOMP server to determine how to build proper Destination names.

If the RequireAcks parameter is set to True, the server will expect the class to send it a message acknowledgment for each message it delivers as part of this subscription. (Refer to the MessageIn event for more information about sending message acknowledgments).

Basic Subscriptions Example

stomp1.OnMessageIn += (s, e) => {
  Console.WriteLine("Received message from destination '" + e.Destination + "':");

string subId = stomp1.Subscribe("test/a/b", false);
// Some time later...

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 JavaScript Edition - Version 20.0 [Build 8265]