小编Ros*_*sky的帖子

是否可以在Simple Injector的方法中使用Thread Scoped Lifestyle

我有以下代码:

public class TempForm : Form
{
    private readonly IGoogleAuth _googleAuth;
    private readonly IComAssistant _comAssistant;

    public TempForm(IGoogleAuth googleAuth, IComAssistant comAssistant)
    {
        _googleAuth = googleAuth;
        _comAssistant = comAssistant;

        InitializeComponent();
    }

    private void ButtonClick(object sender, EventArgs e)
    {
        var excelThread = new Thread(() =>
        {
            //NEED NEW INSTANCE OF EXCEL_APP PER THREAD
            using (IExcelApp excel = new ExcelApp(_comAssistant))
            {
                //Do stuff with excel.
                excel.CreateWorkBook();
                //...
            }
        });

        excelThread.SetApartmentState(ApartmentState.STA);
        excelThread.Start();
    }

    private void InitializeComponent()
    {
        //Initialize form components
    }
}
Run Code Online (Sandbox Code Playgroud)

我没有问题IGoogleAuth或 …

.net c# multithreading dependency-injection simple-injector

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

为两个独立的集群配置 Spring Kafka

是否可以将 Kafka 配置为在单个 Spring Boot 应用程序中使用两个独立的集群?

用例:我有两个带有副本+zookeeper的集群:

  • 集群 #1引导服务器server1.example.com,server2.example.com,server3.example.com
  • 集群 #2引导服务器target-server1.example.com,target-server2.example.com,target-server3.example.com

我需要使用该消息,Cluster #1然后根据该数据进行一些计算,并生成Cluster #2主题结果。有没有办法在单个 Spring 应用程序中配置 Kafka 来处理这种方法?

apache-kafka spring-boot spring-kafka

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