🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

Unable to Map Topic to Queue using C# Client API

RanjeethMalachira
RanjeethMalachira Member Posts: 3
edited October 2019 in Connectors & Integrations #1

I need to dynamically map Topic to queue through C# client API.
I have followed every step that is written in https://solace.com/samples/solace-samples-dotnet/topic-to-queue-mapping/ and Github sample https://github.com/SolaceSamples/solace-samples-dotnet/blob/master/src/TopicToQueueMapping/TopicToQueueMapping.cs. 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?

Tagged:

Answers

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 644 admin

    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: https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Adding-Topic-Subscriptio.htm

  • RanjeethMalachira
    RanjeethMalachira 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);
    
                            _logger.Debug(
                                $"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.