Try PubSub+
If you haven't already, check out our new Developer Portal! You'll find useful information about Solace PubSub+ as well as handy resources to get you started.

Unable to Map Topic to Queue using C# Client API

RanjeethMalachiraRanjeethMalachira Member Posts: 3
edited October 2019 in Integrations with Solace

I need to dynamically map Topic to queue through C# client API.
I have followed every step that is written in and Github sample However everything works as expected until i hit the line

session.Subscribe(queue, tutorialTopic, SubscribeFlag.WaitForConfirm, null);

The API throws Client_Fail error and something in the line of unable to subscribe. Initially i thought that it could be the problem with the user not having the right permission. But even though the infrastructure team said that they have given the user all access including permission to bridge, I have hit a roadblock. What am I missing?


  • AaronAaron Member, Moderator, Employee Posts: 63 Solace Employee

    client-profile permissions are important, but so are the permissions on the queue itself. Two settings:
    1) Who is the owner of the queue? (if any?). If it's a specific client-username, this user has ALL permissions on the queue
    2) What is the value of "All Others Permissions"? This is for all other client-usernames. This is often configured as "Consume".

    If the queue has been created by management, and not owned by a particular username, then you must ensure the "All Others Permissions" of the queue is set to either "modify-topic" or "delete". This allows any other client-username (that doesn't own the queue) to add subscriptions.

    Hope that helps. Let me know if the queue's permissions are already one of these, and we might need to dig further.

    Some other docs that may help:

  • RanjeethMalachiraRanjeethMalachira Member Posts: 3

    The code is creating both the topic and the queue and I guess the owner of both the queue and topic is client we own. Below is the code that we are using to create subscription where GetSubscription gives the mapping information.

    foreach (var map in _subscription.GetSubscription())
                    using (var topic = ContextFactory.Instance.CreateTopic(map.PublishConfig.TopicName))
                        using (var queue = ContextFactory.Instance.CreateQueue(map.QueueName))
                            var endpointProps = new EndpointProperties()
                                Permission = EndpointProperties.EndpointPermission.Consume,
                                AccessType = EndpointProperties.EndpointAccessType.Exclusive,
                            _session.Provision(queue, endpointProps,
                                ProvisionFlag.IgnoreErrorIfEndpointAlreadyExists | ProvisionFlag.WaitForConfirm, null);
                            _logger.Debug($"Queue {map.QueueName} is provisioned.");
                            _session.Subscribe(queue, topic, SubscribeFlag.WaitForConfirm, null);
                                $"Subscription for queue {map.QueueName} for topic {map.PublishConfig.TopicName} created.");

    The session properties used for this mapping

    var sessionProperties = new SessionProperties()
                    Host = Configuration.Host,
                    VPNName = Configuration.VpnName,
                    UserName = Configuration.UserName,
                    Password = Configuration.Password,
                    ReconnectRetries = Configuration.ReconnectRetries,
                    IgnoreDuplicateSubscriptionError = true

    Let me know if you need any more information.

Sign In or Register to comment.