rhuan080 commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011871141
Hi @davsclaus
Yes, it does the operation x2 inside the map, but not inside the
DefaultTimeoutMap. Look at this code:
```
public V get(K key) {
TimeoutMapEntry<K, V> entry;
// if no contains, the lock is not necessary
if (!map.containsKey(key)) {
return null;
}
lock.lock();
try {
entry = map.get(key);
if (entry == null) {
return null;
}
updateExpireTime(entry);
} finally {
lock.unlock();
}
return entry.getValue();
}
```
Without the contains check the lock is applied even if the entry does not
exist. The ReplyManagerSupport calls the get method excessively causing a delay.
```
ForegroundTask task =
Tasks.foregroundTask().withBudget(Budgets.iterationBudget()
.withMaxIterations(50)
.withInterval(Duration.ofMillis(100))
.build())
.build();
return task.run(() -> correlation.get(correlationID), answer ->
answer != null).orElse(null);
```
https://github.com/apache/camel/blob/camel-3.21.x/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/reply/ReplyManagerSupport.java#L217
ForegroundTask no longer being able to locate it (this will happen 50
times). Implementing the 'contains' method ensures that the lock is acquired
only when necessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]