Search code examples
c#.net-coremessagebrokersolace

Solace topic subscription with correlationId


I subscribe to topics like that:

var topics = new string[]{
    "TOP/IC/*/A/>", 
    "TOP/IC/*/B/>",
    "ANY/*/STRU/CTURE"
    // etc... 
};
foreach(var t in topics)
{
    var topic = ContextFactory.Instance.CreateTopic(t);
    var sessionReturnCode = _session.Subscribe(topic, false); // _session is ISession
}

Incomming message has full topic name information. E.g. TOP/IC/ANY/A/N123/XFDJK985.

I would like to know from which subscription the message comes. Is it possible? (correlationId, whatever...). If yes, sample please.


Solution

  • When Solace .NET API, by default, Direct messages are dispatched to the same receive callback or delegate that is configured for the Session. However, it is possible to use special receive callbacks or delegates to handle Direct messages that are published to specific Topics. This functionality is also known as topic dispatching because messages with a specific Topic are dispatched to a specific callback or delegate.

    More information is available here: https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Receiving-Direct-Message.htm