You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by peter_ce <p....@cenit.de> on 2015/09/21 14:46:45 UTC

custom consumer doesn't change the delay

Hi

my custom component won't change the delay for the polling events. The
consumer inherits from ScheduledPollConsumer and sets the delay with
setDelay().
Once Camel
(org.apache.camel.impl.EventDrivenConsumerRoute.addServices(List<Service>))
creates it, the delay will be set back to default (500ms). Looks like some
weird magic which i can't grasp.

My class looks like this:

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.ScheduledPollConsumer;

public class PollTestConsumer extends ScheduledPollConsumer {

	private final PollTestConsumerConfiguration configuration;

	public PollTestConsumer(final PollTestEndpoint endpoint, final Processor
processor) {
		super(endpoint, processor);
		this.configuration = endpoint.getConsumerConfig();

		setDelay(7500);
	}

	@Override
	protected int poll() throws Exception {
		Exchange exchange = getEndpoint().createExchange();
		processExchange(exchange);

		return 1;
	}

	private void processExchange(final Exchange exchange) throws Exception {
		try {
			getProcessor().process(exchange);
		}
		catch (Exception e) {
			throw e;
		}
	}
}

I wonder if my usage is wrong.

The setup is Karaf 3.0.4 and Camel 2.15.2.
I updated recently from Karaf 2.3.2 and Camel 2.11.1. With this setup it
worked well.


Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/custom-consumer-doesn-t-change-the-delay-tp5771708.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: custom consumer doesn't change the delay

Posted by peter_ce <p....@cenit.de>.
I already tried to set the delay for the endpoint in my consumer class. Same
behavior as before.

Now i tried to set the delay in the endpoint constructor, just like you did
in your mail-component, and it works just fine.

It works for 2.15.2 and 2.15.3.


Thanks for your help.



--
View this message in context: http://camel.465427.n5.nabble.com/custom-consumer-doesn-t-change-the-delay-tp5771708p5771779.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: custom consumer doesn't change the delay

Posted by Claus Ibsen <cl...@gmail.com>.
Well its how we do it in camel-mail
https://github.com/apache/camel/blob/master/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java#L59

eg set it on the endpoint.

On Tue, Sep 22, 2015 at 7:36 AM, peter_ce <p....@cenit.de> wrote:
> Hi
>
> The behavior is still the same in Camel 2.15.3.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/custom-consumer-doesn-t-change-the-delay-tp5771708p5771744.html
> Sent from the Camel Development mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: https://www.manning.com/books/ibsen2

Re: custom consumer doesn't change the delay

Posted by peter_ce <p....@cenit.de>.
Hi

The behavior is still the same in Camel 2.15.3.



--
View this message in context: http://camel.465427.n5.nabble.com/custom-consumer-doesn-t-change-the-delay-tp5771708p5771744.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: custom consumer doesn't change the delay

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think we fixed a bug in that delay stuff. Can you try with latest release?

On Mon, Sep 21, 2015 at 2:46 PM, peter_ce <p....@cenit.de> wrote:
> Hi
>
> my custom component won't change the delay for the polling events. The
> consumer inherits from ScheduledPollConsumer and sets the delay with
> setDelay().
> Once Camel
> (org.apache.camel.impl.EventDrivenConsumerRoute.addServices(List<Service>))
> creates it, the delay will be set back to default (500ms). Looks like some
> weird magic which i can't grasp.
>
> My class looks like this:
>
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.impl.ScheduledPollConsumer;
>
> public class PollTestConsumer extends ScheduledPollConsumer {
>
>         private final PollTestConsumerConfiguration configuration;
>
>         public PollTestConsumer(final PollTestEndpoint endpoint, final Processor
> processor) {
>                 super(endpoint, processor);
>                 this.configuration = endpoint.getConsumerConfig();
>
>                 setDelay(7500);
>         }
>
>         @Override
>         protected int poll() throws Exception {
>                 Exchange exchange = getEndpoint().createExchange();
>                 processExchange(exchange);
>
>                 return 1;
>         }
>
>         private void processExchange(final Exchange exchange) throws Exception {
>                 try {
>                         getProcessor().process(exchange);
>                 }
>                 catch (Exception e) {
>                         throw e;
>                 }
>         }
> }
>
> I wonder if my usage is wrong.
>
> The setup is Karaf 3.0.4 and Camel 2.15.2.
> I updated recently from Karaf 2.3.2 and Camel 2.11.1. With this setup it
> worked well.
>
>
> Thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/custom-consumer-doesn-t-change-the-delay-tp5771708.html
> Sent from the Camel Development mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition