CloudFx QueueListener似乎不适合我。为什么?

时间:2012-08-28 15:34:52

标签: azure-storage cloudfx

我正在尝试使用Microsoft发布的CloudFx库和一组示例。库中有很少的文档以及它应该如何使用(除了使用服务总线),但我正在尝试使用CHM参考和样本。我正在尝试复制他们在通过存储队列进行通信的简单生产者/消费者工作者角色中所做的事情,但我似乎无法让CloudQueueListenerExtension类以我希望的方式工作。首先,我围绕侦听器编写了一个简单的包装类:

public class QueueListener<T>
{
    private readonly CloudQueueLocation _queueLocation;
    private readonly CloudQueueListenerExtension<T> _queueListenerExtension;
    private readonly IObserver<T> _observer;

    public static QueueListener<T> StartNew(IExtensibleComponent owner, string storageAccount, Action<T> action)
    {
        var location = new CloudQueueLocation()
                            {
                                StorageAccount = storageAccount,
                                QueueName = typeof(T).Name.ToLowerInvariant()
                            };
        return new QueueListener<T>(owner, location, action).Start();
    }

    protected QueueListener(IExtensibleComponent owner, CloudQueueLocation queueLocation, Action<T> action)
    {
        _queueLocation = queueLocation;
        _queueListenerExtension = new CloudQueueListenerExtension<T>(queueLocation, owner);
        _observer = Observer.Create(action);

        _queueListenerExtension.Subscribe(_observer);            
    }

    protected QueueListener<T> Start()
    {
        _queueListenerExtension.StartListener();
        return this;
    }
}

然后我将其设置为主要的工作者角色,如下所示:

QueueListener<MyMessageType>.StartNew(this, storageAccountString,
         newMsg => _log.InfoFormat("Got {0}", newMsg));

我有一个将MyMessageType消息发布到队列的Web应用程序,但该动作永远不会执行。我在诊断日志中看到一些跟踪,指示侦听器指向正确的存储帐户和正确的队列,我甚至看到对ReliableCloudQueueStorage.Get的调用。我无法构建样本,但我认为我正在使用与示例完全相同的侦听器扩展。

关于可能发生的事情的任何想法?

1 个答案:

答案 0 :(得分:1)

感谢您提供了很好的解释和代码段。它对于故障排除非常有用。 : - )

我们最近将CloudFx迁移到Reactive Extensions 2.0,当我们进行迁移时,我们没有理解我们如何在队列侦听器组件内部处理可观察序列的一些细节。现在已经解决了这个问题,我刚刚推出了新版本的NuGet软件包(1.3.0.1),旨在解决您所面临的挑战。

告诉我们您将如何进行。

瓦列