[jira] Created: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
---------------------------------------------------------------------------------------------------------

                 Key: CAMEL-1129
                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
             Project: Apache Camel
          Issue Type: Improvement
          Components: camel-core
    Affects Versions: 1.5.0
            Reporter: Ron Gavlin


The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.

The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Assigned: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang reassigned CAMEL-1129:
-----------------------------------

    Assignee: Willem Jiang

> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47801#action_47801 ]

Willem Jiang commented on CAMEL-1129:
-------------------------------------

DeadLetterChannel need to process the sync processor and the async processor.
Since we can't make the sync processor give up it's calling thread for the exchange message processing,
my patch just put  the async processor's redelivery call into a timer thread.

Here is the async processor's example code
{code}
    protected RouteBuilder createRouteBuilder() {
        final Processor processor = new AsyncProcessor() {
            public void process(Exchange exchange) {
                Integer counter = exchange.getIn().getHeader(DeadLetterChannel.REDELIVERY_COUNTER,
                                                             Integer.class);
                int attempt = (counter == null) ? 1 : counter + 1;
                if (attempt < failUntilAttempt) {
                    throw new RuntimeException("Failed to process due to attempt: " + attempt
                                               + " being less than: " + failUntilAttempt);
                }
            }
            // START SNIPPET: AsyncProcessor
            public boolean process(Exchange exchange, AsyncCallback callback) {                
                Integer counter = exchange.getIn().getHeader(DeadLetterChannel.REDELIVERY_COUNTER,
                                                             Integer.class);
                int attempt = (counter == null) ? 1 : counter + 1;
                if (attempt > 1) {
                    assertEquals("Now we should use TimerThread to call the process", Thread.currentThread().getName(), "Timer-0");
                }
               
                if (attempt < failUntilAttempt) {
                    // we can't throw the exception here , or the callback will not be invoked.
                    exchange.setException(new RuntimeException("Failed to process due to attempt: " + attempt
                                               + " being less than: " + failUntilAttempt));
                }
                callback.done(false);
                return false;
            }
            // END SNIPPET: AsyncProcessor
        };

        return new RouteBuilder() {
            public void configure() {
                from("direct:start").errorHandler(
                    deadLetterChannel("mock:failed").maximumRedeliveries(2)
                        .delay(1000)
                        .loggingLevel(LoggingLevel.DEBUG)

                ).process(processor).to("mock:success");
            }
        };
    }

{code}

> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47802#action_47802 ]

Willem Jiang commented on CAMEL-1129:
-------------------------------------

Applied the patch into trunk and camel-1.x branch.

> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47805#action_47805 ]

Claus Ibsen commented on CAMEL-1129:
------------------------------------

Willem and we are sure this only applies for async behavior?

What if end-user or 3rd part framework adds stuff to ThreadLocal and thus if we use a different thread for redelivery then that stuff is gone. Or am I not thinking clear? I just got into the office and on the first cup of coffee ;)

> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47806#action_47806 ]

Willem Jiang commented on CAMEL-1129:
-------------------------------------

@Claus

That's because if we call the sync processor, the caller will block and wait for processor finish it's work then handle the exchange.
If we put the redelivery work into the timer and return from the processor, the exchange will not handle rightly.

Current Camel AsyncProcessor API can't handle the ThreadLocal stuff, in that case , I think we  need switch to use sync processor API.



> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (CAMEL-1129) Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang resolved CAMEL-1129.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0
                   1.5.1

> Enhance ErrorHandler RedeliveryPolicy with a Timer manager to avoid locking current thread while sleeping
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1129
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1129
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Ron Gavlin
>            Assignee: Willem Jiang
>             Fix For: 1.5.1, 2.0.0
>
>
> The ErrorHandler RedeliveryPolicy appears to lock threads while sleeping until the next redelivery. With lots of concurrent requests requiring increasing redelivery times, this can be a scalability problem.
> The RedeliveryPolicy should support the use of a timer thread that would be responsible for managing the "timeouts" and firing the redelivery.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.