azure - Windows Azure 中的 SQL 筛选器问题

标签 azure

我正在为使用主题/订阅的云服务创建 SQL 过滤器。我为我的代理消息声明了一个属性,如下所示

BrokeredMessage message = new BrokeredMessage("Response Message#"+ (++counter) +" Body");

// Set additional custom app-specific property
message.Properties["MsgGUID"] = RequestMessageID; //assign msgGUID read from the Azure Queue

// Send message to the topic
Client.Send(message);

想要实现的是,当我向我的辅助角色发送消息时,该消息将包含一个随机生成的字符串。辅助角色会将该字符串视为我的 ID 并创建一条代理消息,其“MsgGUID”属性将保存该 ID。我的 SQL 过滤器如下所示:

SqlFilter CompareGUIDFilter = new SqlFilter("MsgGUID = '" + messageID + "'");//Filter based on the Requested GUID i.e. msgGUID

if (!nameSpaceManager.SubscriptionExists("TestTopic", "RequestMessageGUIDSubscriber"))
            {
                /*Subscriber with Filter as Receive only those Messages from the Topic that are 
                requested by the controller from another RequestQueue(Azure Queue) with GUID as messageID*/
                nameSpaceManager.CreateSubscription("TestTopic", "RequestMessageGUIDSubscriber", CompareGUIDFilter);

            }

我随机生成的字符串如下所示:

public string GetRandomString(int length)
        {
            Random r = new Random();
            string result = "";
            for (int i = 0; i < length; i++)
            {
                result += allowedchars.Substring(r.Next(0,allowedchars.Length),1);
            }
            return result;
        }

现在的问题是,当我将 messageId 设置为静态内容(例如“GUID”)时,过滤器可以正常工作,但是当我使用上述函数生成它时,它不起作用。任何帮助将不胜感激。

最佳答案

sql过滤器没有问题。但主题会使用该 id 键值将消息保留在其中。因此您无法通过您的订阅者访问后续消息。

关于azure - Windows Azure 中的 SQL 筛选器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16332753/

相关文章:

Azure 插槽交换导致 HTTP 错误 500.30 - ANCM 进程内启动失败

azure - 在 Azure 存储帐户中创建表

python - 我无法从程序中获取授权码

azure - 如何将 docker 容器作为 Windows 服务运行

MVC 应用程序中的 Azure AD ADAL - token 过期

azure - 问题解决后,作业仍然失败

azure - 如何使用 terraform 配置 azure 存储生命周期?

c# - azure 存储队列中的最大出队计数

c# - 从 webAPI 访问调用 GetSecretAsync 时偶尔出现 500 错误

powershell - “Set-AzureRmDataFactoryV2”未被识别为 cmdlet 的名称