Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdviceWithRouteBuilder replaceFromWith and microprofile-metrics conflict #1894

Closed
jwwallin opened this issue Oct 9, 2020 · 3 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jwwallin
Copy link

jwwallin commented Oct 9, 2020

I'm trying to write tests for a quartz triggered route by replacing the original from-endpoint using AdviceWithRouteBuilder.adviceWith(camelContext, "scheduler-daily", advisor -> {advisor.replaceFromWith("direct:scheduler-daily");}).

When I run the test, I get this error:

org.apache.camel.FailedToCreateRouteException: Failed to create route scheduler-daily: Route(scheduler-daily)[From[direct:scheduler-daily] -> [Log[... because of A metric with metricID MetricID{name='camel.route.exchanges.inflight.count', tags=[camelContext="camel-1",routeId="scheduler-daily"]} already exists
        at TimerRouteTest.mockRouteEndpoints(TimerRouteTest.java:53)
Caused by: java.lang.IllegalArgumentException: A metric with metricID MetricID{name='camel.route.exchanges.inflight.count', tags=[camelContext="camel-1",routeId="scheduler-daily"]} already exists
        at TimerRouteTest.mockRouteEndpoints(TimerRouteTest.java:53)

Am I missing something or is there a bug in the way the replaceFromWith(...) interacts (or maybe doesn't interact) with camel-quarkus-microprofile-metrics?

Log before the error looks like this:

[INFO] Running TimerRouteTest
2020-10-09 14:45:50,431 INFO  [org.apa.cam.com.qua.QuartzEndpoint] (main) Pausing trigger schedule.daily
2020-10-09 14:45:50,433 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Route: scheduler-daily is stopped, was consuming from: quartz://schedule/daily
2020-10-09 14:45:50,435 INFO  [org.apa.cam.com.qua.QuartzEndpoint] (main) Deleting job schedule.daily
2020-10-09 14:45:50,437 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Route: scheduler-daily is shutdown and removed, was consuming from: quartz://schedule/daily
2020-10-09 14:45:50,439 INFO  [org.apa.cam.bui.AdviceWithTasks] (main) AdviceWith replace input from [quartz://schedule/daily?cron=0+6+6+?+*+*] --> [direct:scheduler-daily]
2020-10-09 14:45:50,439 INFO  [org.apa.cam.rei.RouteReifier] (main) AdviceWith route after: Route(scheduler-daily)[From[direct:scheduler-daily] -> [Log[Starting Scheduled daily ], To[direct:input-daily]]]
@jamesnetherton
Copy link
Contributor

It's probably a bug in the camel-microprofile-metrics component. Looks like adviceWith or replaceFrom results in an attempt to register a metric that already exists.

You could try disabling the route metrics by adding the following to application.properties:

quarkus.camel.metrics.enable-route-policy=false

@jwwallin
Copy link
Author

jwwallin commented Oct 9, 2020

I disabled the route metrics as suggested and it works fine.

jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Oct 14, 2020
@jamesnetherton jamesnetherton self-assigned this Oct 14, 2020
@jamesnetherton jamesnetherton added the bug Something isn't working label Oct 14, 2020
@jamesnetherton
Copy link
Contributor

I added a workaround to fix the issue for the 1.2.0 release.

It'll be fixed properly when the project upgrades to Camel 3.6.0.

https://issues.apache.org/jira/browse/CAMEL-15675

jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Oct 21, 2020
@jamesnetherton jamesnetherton added this to the 1.4.0 milestone Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants