Реализация надежной связи между ролями с помощью AppFabric ServiceBus в Azure, шаблон IObserver

Я пытался следовать этот пример (скачайте исходный код по ссылке на сайте или здесь, но я продолжаю сталкиваться с ошибкой, которая, кажется, встроена в пример.

Моя процедура была следующей (после установки AppFabric SDK и других зависимостей):

  1. Скачать исходный код
  2. Создайте пространство имен службы в AppFabric.
  3. Импортируйте проект в новый проект Windows Azure с одной рабочей ролью, убедитесь, что все это компилируется и что метод Run() рабочей роли по умолчанию запускается и работает.
  4. Настройте метод GetInterRoleCommunicationEndpoint в InterRoleCommunicationExtension.cs с ServiceNameSpace и IssuerSecret из моего пространства имен службы AppFabric (IssuerName и ServicePath остаются по умолчанию). Это жесткое подключение моих собственных параметров.
  5. Скопируйте/вставьте логику инициализации из файла «SampleWorkerRole.cs» в демо-версии в метод OnStart() рабочей роли моего проекта.
  6. Закомментируйте ссылки на Tracemanager.*, поскольку в демонстрационном коде методы Tracemanager не реализованы и они не имеют решающего значения для работы этого теста. Таких ссылок около 7-10 (просто выполните Find -> «Tracemanager» во всем решении).
  7. Стройте успешно.
  8. Запустите на локальном эмуляторе вычислений.

When I run this test, during the initialization of a new InterRoleCommunicationExtension (the first piece of the inter-role communication infrastructure to be initialized, this.interRoleCommunicator = new InterRoleCommunicationExtension();), an error is raised: "Value cannot be null. Parameter name: contractType."

Drilling into this a bit, I follow the execution down to the following method in ServiceBusHostFactory.cs (one of the files from the sample):

public static Type GetServiceContract(Type serviceType) { Guard.ArgumentNotNull(serviceType, "serviceType");

        Type[] serviceInterfaces = serviceType.GetInterfaces();

        if (serviceInterfaces != null && serviceInterfaces.Length > 0)
        {
            foreach (Type serviceInterface in serviceInterfaces)
            {
                ServiceContractAttribute serviceContractAttr = FrameworkUtility.GetDeclarativeAttribute<ServiceContractAttribute>(serviceInterface);

                if (serviceContractAttr != null)
                {
                    return serviceInterface;
                }
            }
        }

        return null;
    }



The serviceType parameter's Name property is "IInterRoleCommunicationServiceContract," which is one of the classes of the demo, and which extends IObservable. The call to serviceType.GetInterfaces() returns the "System.IObservable`1" interface, which is then passed into FrameworkUtility.GetDeclarativeAttribute(serviceInterface);, which has the following code:

public static IList GetDeclarativeAttributes(Type type) where T : class { Guard.ArgumentNotNull(type, "type");

        object[] customAttributes = type.GetCustomAttributes(typeof(T), true);
        IList<T> attributes = new List<T>();

        if (customAttributes != null && customAttributes.Length > 0)
        {
            foreach (object customAttr in customAttributes)
            {
                if (customAttr.GetType() == typeof(T))
                {
                    attributes.Add(customAttr as T);
                }
            }
        }
        else
        {
            Type[] interfaces = type.GetInterfaces();

            if (interfaces != null && interfaces.Length > 0)
            {
                foreach (object[] customAttrs in interfaces.Select(iface => iface.GetCustomAttributes(typeof(T), false)))
                {
                    if (customAttrs != null && customAttrs.Length > 0)
                    {
                        foreach (object customAttr in customAttrs)
                        {
                            attributes.Add(customAttr as T);
                        }
                    }
                }
            }
        }

        return attributes;
    }</code><br>

It is here that the issue arises. After not finding any customAttributes on the "IObservable1" type, it calls type.GetInterfaces(), expecting a return. Even though type is "System.IObservable1," this method returns an empty array, which causes the function to return null and the exception with the above message to be raised.

Я чрезвычайно заинтересован в том, чтобы этот сценарий работал, так как я думаю, что парадигма обмена сообщениями публикации/подписки является идеальным решением для моего приложения. Кто-нибудь смог заставить этот демо-код (от самой команды AppFabric CAT!) работать или может обнаружить мою ошибку? Спасибо за помощь.


person user483679    schedule 15.02.2011    source источник


Ответы (1)


Ответил в оригинальном сообщении в блоге (см. ссылку ниже). Пожалуйста, сообщите, если вы все еще испытываете проблемы. Мы стремимся поддерживать наши образцы на основе максимальных усилий.

http://blogs.msdn.com/b/appfabriccat/archive/2010/09/30/implementing-reliable-inter-role-communication-using-windows-azure-appfabric-service-bus-observer-pattern-amp-parallel-linq.aspx#comments

person Valery M    schedule 16.02.2011
comment
Спасибо, что ответили мне, Валерий. Ваши изменения, похоже, работают над моей коробкой ткани для разработки. Я снова опубликую здесь через неделю или две, когда я запустил его в Azure и смогу увидеть, как он работает в ряде сценариев. Еще раз спасибо! - person user483679; 21.02.2011