You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "rhuan080 (via GitHub)" <gi...@apache.org> on 2024/03/21 01:09:51 UTC

[PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

rhuan080 opened a new pull request, #13556:
URL: https://github.com/apache/camel/pull/13556

   # Description
   
   As described on the issue, the 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 is executing the get excessively. This delay occurs because the ReplyHandler has already been removed by the RabbitMQReplyManagerTimeoutChecker. The contains avoid getting locked when the TimeoutMapEntry does not exist.
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [ ] I have run `mvn clean install -DskipTests` locally and I have committed all auto-generated changes
   
   <!--
   You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011006457

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :warning: Please note that the changes on this PR may be **tested automatically**. 
   
   If necessary Apache Camel Committers may access logs and test results in the job summaries!


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2012805450

   MHO, as long as we retain the second `if (entry == null) {` we should be fine (i.e.: to avoid a TOCTOU issue). 
   
   Obs.: without measuring is hard to attest if the lock is a bottleneck , but I think the proposed fix makes sense. 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "rhuan080 (via GitHub)" <gi...@apache.org>.
rhuan080 commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2012045071

   I'll come back soon with results of camel-spring-rabbitmq


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "rhuan080 (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2012267360

   Yeah sure the contains check is outside the lock, but is the locking really a bootleneck. And that frequencey is only every 100ms.
   
   @orpiske ^^


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #13556:
URL: https://github.com/apache/camel/pull/13556


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "rhuan080 (via GitHub)" <gi...@apache.org>.
rhuan080 commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2012043503

   Sure! I'll test it.
   Regarding the update, I believe it's feasible to incorporate it since camel-support is utilized by various components, and it improves the DefaultTimeoutMap avoiding needed lock.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011042500

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011042512

   ### Core test results:
   
   | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- |  --- |
   | 1 | 1 | 0 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011040795

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011040803

   ### Core test results:
   
   | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- |  --- |
   | 1 | 1 | 0 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011088138

   ### Core test results:
   
   | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- |  --- |
   | 1 | 0 | 1 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011906873

   camel-rabbitmq is deprecated and removed in v4. You should use camel-spring-rabbitmq, and can you check what it does in this spring component


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011088132

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011040630

   ### Core test results:
   
   | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- |  --- |
   | 1 | 1 | 0 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011040621

   :no_entry_sign: There are (likely) no components to be tested in this PR


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20590: avoiding delay to execute timeout to Camel RabbitMQ (InOut) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13556:
URL: https://github.com/apache/camel/pull/13556#issuecomment-2011760967

   is the map empty, as checking for empty is faster. If you do a exists and then after wards get, then you do x2 the operation.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org