小编gho*_*ago的帖子

消息混淆:发布/发布与多播与扇出

我一直在为我的公司评估消息传递技术,但我对几个术语之间的概念差异感到非常困惑:

发布/订阅多播扇出 我正在使用以下定义:

  • Pub/Sub有发布者向每个订阅者提供每个消息的单独副本,这意味着存在保证传递的机会
  • 扇出有一个队列推送到所有侦听客户端.
  • 多播只是发送数据,如果有人正在听,那么很好,如果没有,这没关系.没有可能保证客户肯定收到消息.

这些定义是对的吗?或者Pub/Sub模式和组播,直接,扇出等方式来实现模式?

我正在尝试将开箱即用的RabbitMQ定义应用到我们的架构中,但我现在只是试图为我们的应用程序编写规范.

请有人可以告诉我,我是否正确?

messaging message-queue amqp publish-subscribe rabbitmq

38
推荐指数
2
解决办法
3万
查看次数

Active Directory COM异常 - 发生操作错误(0x80072020)

当我尝试使用方法GroupPrincipal.FindByIdentity查询Active Directory时,我收到间歇性COM异常" 发生操作错误(0x80072020) "(如下所示)

这是我的代码:

PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Environment.UserDomainName);
GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, "Group to find");
Run Code Online (Sandbox Code Playgroud)

我收到例外:

Inner Exception: System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred.
  at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
  at System.DirectoryServices.DirectoryEntry.Bind()
  at System.DirectoryServices.DirectoryEntry.get_AdsObject()
  at System.DirectoryServices.PropertyValueCollection.PopulateList()
  at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
  at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
  at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
  at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
  at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
  at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
  at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
  at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue)
  at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, …
Run Code Online (Sandbox Code Playgroud)

.net c# com exception active-directory

27
推荐指数
3
解决办法
5万
查看次数

c#在对象构造函数中启动异步方法 - 不好的做法?

我在一个类似的对象构造函数中有一些代码

delegate DataSet MyInvoker;

public MyObject(Param1 p1)
{
    // property sets here
    // ...

    BeginMyAsyncMethod();
}

public void BeginMyAsyncMethod() 
{
    // set some properties
    // ...

    MyInvoker inv = new MyInvoker(SomeBeginMethod);
    inv.BeginInvoke(new AsyncCallback(SomeEndMethod), null);
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 这通常被认为是不好的做法吗?
  2. 在我的类中定义一个start方法(用户可以调用它来执行异步操作)会更好(或更好)吗?

这个答案给我的印象是,将它留给用户是不好的做法,虽然我特别谈到在构造函数中启动异步方法,而不是正确构造对象.

.net c# asynchronous

25
推荐指数
5
解决办法
2万
查看次数

c#锁定传递给方法的引用 - 不好的做法?

我有一个类似的方法:

public static void DoSomething (string param1, string param2, SomeObject o) 
{
   //.....

   lock(o) 
   {
       o.Things.Add(param1);
       o.Update();
       // etc....
   }
}
Run Code Online (Sandbox Code Playgroud)

几点:

  1. 用这种方式锁定不好的做法?
  2. 我应该锁定private static object吗?
  3. 如果是这样,为什么?

.net c# multithreading locking thread-safety

16
推荐指数
1
解决办法
7026
查看次数

如何使用C#滚动到WinForms TextBox中的指定行?

如何使用C#滚动到WinForms TextBox中的指定行?

谢谢

c# textbox line winforms

13
推荐指数
2
解决办法
1万
查看次数

我在mysql查询中使用Join时出错了 - 解释结果也发布了

我有这个查询,只需要3.5秒来获取2条记录.然而,推荐书中有超过10万行,用户为13k,课程为850,考试为2.

SELECT t.*, u.name, f.feedback
FROM testmonials t
INNER JOIN user u ON u.id = t.userid
INNER JOIN courses co ON co.id = t.courseid
LEFT JOIN exam ex ON ex.id = t.exam_id
WHERE t.status = 4
AND t.verfication_required = 'Y'
AND t.verfication_completed = 'N'
ORDER BY t.submissiondate DESC
Run Code Online (Sandbox Code Playgroud)

.解释结果:.

id  select_type     table   type    possible_keys   key     key_len     ref     rows    Extra
1   SIMPLE  co  ALL     PRIMARY     NULL    NULL    NULL    850     Using temporary; Using filesort
1   SIMPLE  t   ref     CID,nuk_tran_user   CID     4   kms.co.id …
Run Code Online (Sandbox Code Playgroud)

mysql join explain

7
推荐指数
1
解决办法
526
查看次数

gridview中的排序不起作用

我正在尝试在网格视图中排序功能,但它不工作.可以帮助一些身体吗?

码:

  private string ConvertSortDirectionToSql(SortDirection sortDirection)
{
    string newSortDirection = String.Empty;

    switch (sortDirection)
    {
        case SortDirection.Ascending:
            newSortDirection = "ASC";
            break;

        case SortDirection.Descending:
            newSortDirection = "DESC";
            break;
    }

    return newSortDirection;
}
protected DataSet FillDataSet()
{
    string source = "Database=GridTest;Server=Localhost;Trusted_Connection=yes";
    con = new SqlConnection(source);
    cmd = new SqlCommand("proc_mygrid", con);
    ds = new DataSet();
    da = new SqlDataAdapter(cmd);
    da.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();

    return ds;


}
 protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
    DataTable dt = GridView1.DataSource as DataTable;
    if (dt != null) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net sorting ado.net gridview

5
推荐指数
1
解决办法
2万
查看次数

wcf - MaxConcurrentCalls和MaxConcurrentSessions属性之间的区别

阅读http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentsessions.aspx后

http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentcalls.aspx

我的结论是:

MaxConcurrentSessions是每个客户端的排队会话数(默认值为10) MaxConcurrentCalls是服务上的活动连接数(默认值为16),即任何一次访问该服务的所有客户端,这意味着如果2个客户端每次执行10次调用, 4必须在队列中等待处理.

问题:

  1. 我的结论是否正确?
  2. MaxConnections如何与这些交互?
  3. MaxConnections是否优先于MaxConcurrentX设置?

(注意:我使用的是.NET 3.5)

.net c# wcf

4
推荐指数
1
解决办法
7445
查看次数

新的ObservableCollection与在循环中添加项目

在速度和生成的通知量方面,这段代码是:

ObservableCollection<Foo> foo = new ObservableCollection<Foo>(bar);
this.SomeProperty = foo;
Run Code Online (Sandbox Code Playgroud)

同样如下:

this.SomeProperty = new ObservableCollection<Foo>();

foreach (var v in bar) 
{
    this.SomeProperty.Add(v);
}
Run Code Online (Sandbox Code Playgroud)

如果它们相同,是否有可能以某种方式关闭生成的通知?

目标: 我正试图加速在Silverlight中显示Telerik RadChart.即使在设置了包含ObservableCollection的属性之后,似乎还需要一段时间才能显示(并在浏览器应用程序中冻结).绘制图表后,一切正常.

c# silverlight telerik observablecollection radchart

4
推荐指数
1
解决办法
1486
查看次数

确定AD安全组的电子邮件地址

在AD工作中,我们有一些启用了邮件的安全组.我正在使用System.DirectoryServices.AccountManagement命名空间,如下所示:

        List<GroupPrincipal> result = new List<GroupPrincipal>();            
        using (PrincipalContext domain = new PrincipalContext(ContextType.Domain, userinfo[0]))
        using (UserPrincipal user = UserPrincipal.FindByIdentity(domain, username))
        {

            if (user != null)
            {
                PrincipalSearchResult<Principal> groups = user.GetAuthorizationGroups();

                int totalGroupCounter = 0;
                StringBuilder output = new StringBuilder();
                List<GroupPrincipal> securityGroups = new List<GroupPrincipal>();
                List<GroupPrincipal> distributionGroups = new List<GroupPrincipal>();

                foreach (Principal group in groups)
                {
                    totalGroupCounter++;

                    if (((GroupPrincipal)group).IsSecurityGroup.Value)                        
                        securityGroups.Add((GroupPrincipal)group);                        
                    else                        
                        distributionGroups.Add((GroupPrincipal)group);                        
                }                
            }
        }
Run Code Online (Sandbox Code Playgroud)

有了这些信息,找到该组的电子邮件地址的正确方法是什么?

c# directoryservices active-directory

4
推荐指数
1
解决办法
4015
查看次数