Skip to content

Commit

Permalink
set prefetch count to 1 (#5398)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgauldie authored Nov 5, 2024
1 parent 774226b commit 472613e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@RequiredArgsConstructor
public class TaskService {

public static enum TaskMode {
public enum TaskMode {
@JsonAlias("sync")
SYNC("sync"),
@JsonAlias("async")
Expand Down Expand Up @@ -389,7 +389,7 @@ private void initResponseConsumers() {
// unique queue to ensure the local server also gets it.
final String queueName = !isRunningLocalProfile()
? TASK_RUNNER_RESPONSE_QUEUE
: TASK_RUNNER_RESPONSE_QUEUE + "-local-" + UUID.randomUUID().toString();
: TASK_RUNNER_RESPONSE_QUEUE + "-local-" + UUID.randomUUID();

// Declare a direct exchange
final DirectExchange exchange = new DirectExchange(TASK_RUNNER_RESPONSE_EXCHANGE, IS_DURABLE_QUEUES, false);
Expand All @@ -407,6 +407,7 @@ private void initResponseConsumers() {
rabbitAdmin.getRabbitTemplate().getConnectionFactory()
);

container.setPrefetchCount(1);
container.setQueueNames(queueName);
container.setMessageListener(message -> {
onTaskResponseOneInstanceReceives(message);
Expand Down Expand Up @@ -673,7 +674,7 @@ public TaskFuture runTaskAsync(final TaskRequest r) throws JsonProcessingExcepti
// now send request
final String requestQueue = String.format("%s-%s", TASK_RUNNER_REQUEST_QUEUE, req.getType().toString());

log.info("Readying task: {} with SHA: {} to send on queue: {}", req.getId(), hash, req.getType().toString());
log.info("Readying task: {} with SHA: {} to send on queue: {}", req.getId(), hash, req.getType());

// ensure the request queue exists
declareQueue(req.getType(), requestQueue);
Expand Down

0 comments on commit 472613e

Please sign in to comment.