subscribe (method)

Subscribes to a message destination on the server.

Syntax

- (NSString*)subscribe:(NSString*)destination :(BOOL)requireAcks;
public func subscribe(_ destination: String, _ requireAcks: Bool) throws -> String

Remarks

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 + "':");
  Console.WriteLine(e.Data);
};

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

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks MQ 2020 iOS Edition - Version 20.0 [Build 8155]