locked
Auto re-connect when using Microsoft.EnterpriseManagement.Monitoring.DataProviders!AlertProvider/GetAlertsForEntities RRS feed

  • Question

  • hey :)

    I am creating a widget.

    The widget utilizes Microsoft.EnterpriseManagement.Monitoring.DataProviders!AlertProvider/GetAlertsForEntities to get the alerts. (same as the walkthrough #1)

    besides the GetAlertsForEntities, i have implemented the AutoRefreshTimer.

    Here is my implementation of the objects in the ComponentImplementation for the Widget Host.

    <Binding PropertyId="Objects">
                  <Component TypeId="Visualization!Microsoft.SystemCenter.Visualization.AutoRefreshTimer">
                    <Binding PropertyId="TickInterval">
                      <!--<Reference>$Property/AutoRefreshTickInterval$</Reference>-->
                      <!-- <SimpleValue Type="xsd://int" Value="5"/>-->
                      <Reference>$Property/RefreshInterval_widget$</Reference>
                    </Binding>
                    <Binding PropertyId="AutoRefreshAction">
                      <Reference>$Variable/AutoRefreshAction$</Reference>
                    </Binding>
                  </Component>
                </Binding>
                <Binding PropertyId="Objects">
                  <Component TypeId="GetResolutionStatesQuery">
                    <Binding PropertyId="Output">
                      <Reference>$Variable/ResolutionStates$</Reference>
                    </Binding>
                  </Component>
                </Binding>
                
                <Binding PropertyId="Objects">
                  <Component TypeId="Visualization!Microsoft.SystemCenter.Visualization.Consolidator">
                    <Binding PropertyId="From1">
                      <Reference>$Variable/AutoRefreshAction$</Reference>
                    </Binding>
                    <Binding PropertyId="From2">
                      <Reference>$Service/RefreshAction$</Reference>
                    </Binding>
                    <Binding PropertyId="To">
                      <Reference>$Variable/ConsolidatedRefreshAction$</Reference>
                    </Binding>
                  </Component>
                </Binding>
                <Binding PropertyId="Objects">
                  <Component TypeId="GetAlertsForEntitiesQuery">
                    <Binding PropertyId="Output">
                      <Reference>$Variable/Alerts$</Reference>
                    </Binding>
                        <Binding PropertyId="CriteriaString">
                      <Reference>$Property/QueryMain_widget$</Reference>
                    </Binding>
                    <Binding PropertyId="Refresh">
                      <Reference>$Variable/ConsolidatedRefreshAction$</Reference>
                    </Binding>
    
                    <Binding PropertyId="AlertProperties">
                      <ComplexValueCollection Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition[]">
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="Name"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='Name']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="ResolutionState"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='ResolutionState']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
    
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="TimeAdded"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='TimeAdded']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="LastModified"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='LastModified']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
    
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="TimeResolutionStateLastModified"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='TimeResolutionStateLastModified']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue> 
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="Owner"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='Owner']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="Severity"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='Severity']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="Priority"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='Priority']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
    
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="Context"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='Context']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
    
                        <ComplexValue Type="xsd://Microsoft.SystemCenter.Visualization.Library!Microsoft.SystemCenter.Visualization.DataSourceTypes/ValueDefinition">
                          <Binding PropertyId="OutputPropertyName">
                            <SimpleValue Type="xsd://string" Value="ResolvedBy"/>
                          </Binding>
                          <Binding PropertyId="XPath">
                            <SimpleValue Type="xsd://string" Value="$Object/Property[Name='ResolvedBy']$"/>
                          </Binding>
                          <Binding PropertyId="DisplayName">
                            <SimpleValue Type="xsd://string" Value="$NONE$"/>
                          </Binding>
                        </ComplexValue>
                      </ComplexValueCollection>
                    </Binding>
                  </Component>
                </Binding>


    Problem happens when the connection for the server is lost and the widget have to reconnect

    The AutoRefresh still runs every 30 seconds, but when it tried to refresh i get this error:

     Please provide the following information to the support engineer if you have to contact Microsoft Help and Support :

    Microsoft.EnterpriseManagement.Presentation.DataAccess.DataProviderException: An error occurred executing the command: [Microsoft.EnterpriseManagement.Monitoring.DataProviders!AlertProvider/GetAlertsForEntities] in provider: [Microsoft.EnterpriseManagement.Monitoring.DataProviders.AlertProvider, Microsoft.EnterpriseManagement.Monitoring.DataProviders, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35].The client has been disconnected from the server. Please call ManagementGroup.Reconnect() to reestablish the connection. ---> Microsoft.EnterpriseManagement.Common.ServerDisconnectedException: The client has been disconnected from the server. Please call ManagementGroup.Reconnect() to reestablish the connection. ---> System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

    Server stack trace: 
       at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Microsoft.EnterpriseManagement.Common.Internal.IDispatcherService.DispatchUnknownMessage(Message message)
       at Microsoft.EnterpriseManagement.Common.Internal.OperationalDataServiceProxy.SetupAlertsByCriteriaReaderWithProperties(String criteria, String languageCode, Nullable`1 lastModified, Byte[] alertProperties)
       --- End of inner exception stack trace ---
       at Microsoft.EnterpriseManagement.Monitoring.DataProviders.RetryCommandExecutionStrategy.Invoke(IDataProviderCommandMethodInvoker invoker)
       at Microsoft.EnterpriseManagement.Presentation.DataAccess.DataProviderCommandMethod.Invoke(CoreDataGateway gateWay, DataCommand command)
       --- End of inner exception stack trace ---
       at Microsoft.EnterpriseManagement.Presentation.DataAccess.DataProviderCommandMethod.Invoke(CoreDataGateway gateWay, DataCommand command)
       at Microsoft.EnterpriseManagement.Presentation.DataAccess.CoreDataGateway.ExecuteInternal[TResult](DataCommand command)
       at Microsoft.EnterpriseManagement.Presentation.DataAccess.CoreDataGateway.<ExecuteAsync>b__0[TResult](<>f__AnonymousType0`1 data)

    It seems that the GetAlertsForEntities Query does not try to reconnect when the connection is lost.

    This subjext is very hard to get any kind og help. since it is (as far as i know) undocumented.

    Does anyone know if i can implement auto reconnect for the query?

    - Jakob


    Best Regards
    Jakob Gottlieb Svendsen
    Trainer/Consultant - Coretech A/S - Blog
    MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript Mastering System Center Orchestrator 2012 - 3 day workshop - worldwide training click here

    Friday, June 21, 2013 8:35 AM

All replies

  • I have a similar issue with a custom connector I wrote.  The connector takes a significant amount of time to complete, and for some reason, it will drop the management group connection after X amount of time.  I have implemented the following type of reconnect code that seems to be working, but I honestly cannot attest to it as a solution.  This is an old post so I am sure you found a resolution by now, but others in the future may want to see the below:

    //mg is a ManagementGroup instance
    if (!mg.IsConnected) 
      {
         Console.WriteLine("Reconnecting Management Group");
         mg.Reconnect(); 
      }



    Always seek the innovative solution.

    Friday, November 22, 2013 1:37 AM