Apache Camel - Как настроить конечную точку с атрибутами в Java - PullRequest
0 голосов
/ 01 октября 2018

Вот мой отлично работающий верблюжий маршрут в XML ниже

<route id="someId">
            <from id="_from" uri="{{consumer.serviceName}}:queue:{{consumer.notificationQueue}}?{{consumer.queryParams}}"/>
            <log loggerRef="loggerId" message="Messages throttling from Queue"/>
            <throttle prop:timePeriodMillis="{{throttle.timePeriod}}">
                <constant>{{throttle.maximumRequestsPerSecond}}</constant>
                <log loggerRef="logger" message="Consuming notification message from Queue {{consumer.myQueue}} : ${body}"/> 
                <bean id="beanId" method="process" ref="MyProcessor"/>
            </throttle>
        </route>

Теперь я хочу написать аналогичную конечную точку верблюда в Java.Подскажите, пожалуйста, как добавить в него атрибуты log и throttle?

MyProcessor  messageProcessor;
String Uri = serviceName + ":queue:" + queueName + "?" + queryParams;
Endpoint ep = camelContext.getEndpoint(Uri);
Consumer consumer = ep.createConsumer(messageProcessor);
consumer.start();

1 Ответ

0 голосов
/ 01 октября 2018

Надеюсь, это вам поможет:

 from("{{consumer.serviceName}}:queue:{{consumer.notificationQueue}}?{{consumer.queryParams}}").id("from_")
            .log(LoggingLevel.INFO, loggerObject, "Messages throttling from Queue")
            .throttle(constant("{{maximumRequestsPerSecond}}")).timePeriodMillis(1000)//pass throttle.timePeriod parameter from your config here
            .log(LoggingLevel.INFO, loggerObject, "Consuming notification message from Queue {{consumer.myQueue}} : ${body}")
            .bean(beanObject, "process").id("beanId")
            .end();
...