apache camel - Using AdviceWith with Kotlin and Quarkus - Stack Overflow

I am trying to write tests for my camel routes. I use Kotlin with Quarkus.As I realized, CamelContext

I am trying to write tests for my camel routes. I use Kotlin with Quarkus.

As I realized, CamelContext tries to run the AdviceWithRouteBuilder before my own RouteBuilder with my production routes so tests are failing to start. I initialize the advice like:

fun configureMockEventTopicEndpoint() {
    AdviceWith.adviceWith(
        "event-collector",
        context,
        ReplaceDirectThem()
    )
}

class ReplaceDirectThem : AdviceWithRouteBuilder() {
    override fun configure() {
        replaceFromWith("direct:abc")
        interceptSendToEndpoint("jms:topic:*")
            .skipSendToOriginalEndpoint()
            .to("mock:jms:topic:someTopic")
    }
}

in this case, it throws:

Caused by: java.lang.IllegalArgumentException: originalRoute must be specified on: Routes: []

Obviously since this is running before my actual route builder. When I make it java like:

fun configureEventTopicEndpoint() {
    AdviceWith.adviceWith(
        "event-collector",
        context,
        object : AdviceWithRouteBuilder() {
            override fun configure() {
                replaceFromWith("direct:abc")
                interceptSendToEndpoint("jms:topic:*")
                    .skipSendToOriginalEndpoint()
                    .to("mock:jms:topic:sendstuff")
            }
        }
    )
}

Then it throws:

class .apache.camel.support.ObjectHelper cannot access a member of class .....CamelRoutesTest$configureMockEventTopicEndpoint$1 with modifiers ""

What am I missing here?

I tried both ways as described above. Also checked the source code of camel and realized MainConfigurationProperties.routeBuilders are seeing my test route builders before my own prod routes

I expect my routes to run before the test route builders so they can be edited. In the end tests should be succesfull.

I am trying to write tests for my camel routes. I use Kotlin with Quarkus.

As I realized, CamelContext tries to run the AdviceWithRouteBuilder before my own RouteBuilder with my production routes so tests are failing to start. I initialize the advice like:

fun configureMockEventTopicEndpoint() {
    AdviceWith.adviceWith(
        "event-collector",
        context,
        ReplaceDirectThem()
    )
}

class ReplaceDirectThem : AdviceWithRouteBuilder() {
    override fun configure() {
        replaceFromWith("direct:abc")
        interceptSendToEndpoint("jms:topic:*")
            .skipSendToOriginalEndpoint()
            .to("mock:jms:topic:someTopic")
    }
}

in this case, it throws:

Caused by: java.lang.IllegalArgumentException: originalRoute must be specified on: Routes: []

Obviously since this is running before my actual route builder. When I make it java like:

fun configureEventTopicEndpoint() {
    AdviceWith.adviceWith(
        "event-collector",
        context,
        object : AdviceWithRouteBuilder() {
            override fun configure() {
                replaceFromWith("direct:abc")
                interceptSendToEndpoint("jms:topic:*")
                    .skipSendToOriginalEndpoint()
                    .to("mock:jms:topic:sendstuff")
            }
        }
    )
}

Then it throws:

class .apache.camel.support.ObjectHelper cannot access a member of class .....CamelRoutesTest$configureMockEventTopicEndpoint$1 with modifiers ""

What am I missing here?

I tried both ways as described above. Also checked the source code of camel and realized MainConfigurationProperties.routeBuilders are seeing my test route builders before my own prod routes

I expect my routes to run before the test route builders so they can be edited. In the end tests should be succesfull.

Share Improve this question edited Nov 19, 2024 at 14:55 Ali Yüce asked Nov 19, 2024 at 14:52 Ali YüceAli Yüce 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This seems to be a bug. AdviceWithRouteBuilder types are included in the Camel Quarkus build time RouteBuilder discovery, but there's no way to set the original route being advised. Hence the 'originalRoute must be specified on...' exception.

You can can work around this issue by making any AdviceWithRouteBuilder classes private. For example, with the original example above.

private class ReplaceDirectThem : AdviceWithRouteBuilder() {
    override fun configure() {
        replaceFromWith("direct:abc")
        interceptSendToEndpoint("jms:topic:*")
            .skipSendToOriginalEndpoint()
            .to("mock:jms:topic:someTopic")
    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742421552a4440784.html

相关推荐

  • apache camel - Using AdviceWith with Kotlin and Quarkus - Stack Overflow

    I am trying to write tests for my camel routes. I use Kotlin with Quarkus.As I realized, CamelContext

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信