Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipe workers with different configuration #16

Open
mimaom opened this issue Nov 4, 2020 · 3 comments
Open

Multipe workers with different configuration #16

mimaom opened this issue Nov 4, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@mimaom
Copy link

mimaom commented Nov 4, 2020

Hi Alexey

First of all thank you for implementing the worker library.
I am currently evaluating it, and I have a question. I would like to be able to use multiple workers with different configurations (number of workers). Would the following be a valid use of the worker library:

`

      services.AddCamundaWorker(options =>
            {
                options.WorkerId = "Worker_1";
                options.WorkerCount = 1;
                options.BaseUri = new Uri("http://localhost:8080/engine-rest");
            })
            .AddHandler<SayHelloHandler>()
            .ConfigurePipeline(pipeline =>
            {
                pipeline.Use(next => async context =>
                {
                    var logger = context.ServiceProvider.GetRequiredService<ILogger<Startup>>();
                    logger.LogInformation("Started processing of task {Id}", context.Task.Id);
                    await next(context);
                    logger.LogInformation("Finished processing of task {Id}", context.Task.Id);
                });
            });
        services.AddCamundaWorker(options =>
            {
                options.WorkerId = "Worker_2";
                options.WorkerCount = 4;
                options.BaseUri = new Uri("http://localhost:8080/engine-rest");
            })
            .AddHandler<SayHelloGuestHandler>()
            .ConfigurePipeline(pipeline =>
            {
                pipeline.Use(next => async context =>
                {
                    var logger = context.ServiceProvider.GetRequiredService<ILogger<Startup>>();
                    logger.LogInformation("Started processing of task {Id}", context.Task.Id);
                    await next(context);
                    logger.LogInformation("Finished processing of task {Id}", context.Task.Id);
                });
            });

`

Would this result in 2 workers - the first with only one worker count and only getting external tasks for the topic "sayHello" for task handler SayHalloHandler.
And a second worker with worker count 4 only getting external tasks for topic "sayHelloGuest" for task handler SayHelloGuestHandler?

If so, how are the TaskHandlers added using AddTaskHandler() tied to the worker?

Thanks.

BR
Michael

@TechnoBerry
Copy link
Owner

TechnoBerry commented Nov 5, 2020

Hi Michael

Thank you for your feedback.

Unfortunately implementation of this library doesn't support multiple registration of CamundaWorker that you expect. The case that you described will lead to the fact that each worker processes two types of tasks (sayHello and sayHelloGuest).

I think that support for your case can be implemented by binding most of the internal services to the registered worker (for example, through the worker's name). If you have an idea how this can be implemented, we can discuss it.

@mimaom
Copy link
Author

mimaom commented Nov 13, 2020

Hi Alexey

Sorry for the late reply. I understand what you mean and I also think that can be done. Maybe this is something I can find the time to do. I will have a look into that.

PS: I can see that you have released a version 0.10 - which changes does that include?

BR
Michael

@TechnoBerry
Copy link
Owner

In 0.10.0 version, I removed obsolete APIs and changed ASP.NET Core's version. You can see the breaking changes in the release description

@TechnoBerry TechnoBerry added the enhancement New feature or request label Nov 19, 2020
@TechnoBerry TechnoBerry self-assigned this Dec 2, 2020
@TechnoBerry TechnoBerry added this to the 1.0.0 milestone Apr 2, 2021
@TechnoBerry TechnoBerry removed this from the 1.0.0 milestone Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants