Subscribe(String,TimeSpan,Boolean) Method
- Last UpdatedApr 08, 2026
- 2 minute read
IPubSubSubscription Subscribe(
string topic,
TimeSpan timeout,
bool withIntegrity
)
IPubSubSubscription^ Subscribe(
String^ topic,
TimeSpan timeout,
bool withIntegrity
)
Parameters
- topic
- The topic string to subscribe to.
- timeout
- The receive message timeout.
- withIntegrity
- Indicates whether or not integrity updates have been requested.
Return Value
This version of subscribing is useful if the application wants to process messages in a synchronous manner from a special processing thread or a pool of such threads.
If this routine is called after any subscriptions are made with callbacks, then an exception will be raised indicating the use of incompatible subscription semantics.
If the specified timeout is equal to System.Threading.Timeout.InfiniteTimeSpan, then the associated PubSub subscription Receive operation will block until a message is received. However, if the specified timeout is a non-infinite value, the PubSub subscription receive operation will be canceled if no PubSub message has been received within the specified time window and the blocking Receive call will return a PubSubStatus.PS_TIMEOUT status.
using (var subscription = connection.Subscribe("mySystem.MyTopic", TimeSpan.FromSeconds(30), withIntegrity: true))
{
var topic = default(String);
var buffer = default(PubSubBuffer);
var headerData = default(PubSubHeaderData);
subscription.Receive(ref topic, ref buffer, ref headerData);
// Process buffer.
}