You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
Hello! I need a help. For example, I just have a simple console java app with a poller and some workers inside of it.
TaskClient taskClient = new TaskClient();
taskClient.setRootURI("http://localhost:8080/api/"); //Point this to the server API
int threadCount = 2; //number of threads used to execute workers. To avoid starvation, should be same or more than number of workers
Worker worker1 = new SampleWorker("task_1");
Worker worker2 = new SampleWorker("task_5");
// Create TaskRunnerConfigurer
TaskRunnerConfigurer configurer = new TaskRunnerConfigurer.Builder(taskClient, Arrays.asList(worker1, worker2))
.withThreadCount(threadCount)
.build();
// Start the polling and execution of tasks
configurer.init();
I register 2 workers and start polling here. And now I have a question. What will happend if I run a second one yet?
They both start polling the server and at the same time they try to get some data from the same queue. Poller calls to the endpoint "poll/batch/{tasktype}" for data, but in the code futher I can't find anything which can prevent to get dublicate data or can synchronize this both calls. Especially here after a redis call you don't check data for duplicates. So in this case in the end the each worker will run the same task and we have a problem here.
May be am I wrong or miss something?
Can somebody explain how do you scale your workers in production?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I need a help. For example, I just have a simple console java app with a poller and some workers inside of it.
I register 2 workers and start polling here. And now I have a question. What will happend if I run a second one yet?
They both start polling the server and at the same time they try to get some data from the same queue. Poller calls to the endpoint
"poll/batch/{tasktype}"
for data, but in the code futher I can't find anything which can prevent to get dublicate data or can synchronize this both calls. Especially here after a redis call you don't check data for duplicates. So in this case in the end the each worker will run the same task and we have a problem here.Beta Was this translation helpful? Give feedback.
All reactions