gpt4 book ai didi

java - Apache Camel-DirectConsumerNotAvailableException:端点上没有可用的使用者。交换[]

转载 作者:行者123 更新时间:2023-12-03 04:07:38 25 4
gpt4 key购买 nike

Someone that can help my with this error and explain me what is wrong?


我正在开发一种简单的 Camel 路线来处理信息,然后将其存储在文件中。
我正在使用的技术:
  • JDK 11
  • Apache Camel 3.3.0
  • Spring 启动2.3.0

  • 当我想测试 Camel 路线时,出现以下错误。
    org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[]

    at org.apache.camel.CamelExecutionException.wrapCamelExecutionException(CamelExecutionException.java:47)
    at org.apache.camel.support.ExchangeHelper.extractResultBody(ExchangeHelper.java:687)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:568)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:564)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:189)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:430)
    at com.facturacionx.ms.invoice.camel.CamelTest.testMethod(CamelTest.java:40)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
    Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: direct://my-route. Exchange[]
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:59)
    at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:212)
    at org.apache.camel.processor.SharedCamelInternalProcessor$1.process(SharedCamelInternalProcessor.java:110)
    at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:83)
    at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:107)
    at org.apache.camel.impl.engine.DefaultProducerCache.send(DefaultProducerCache.java:185)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:176)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:172)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:153)
    at org.apache.camel.impl.engine.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:187)
    ... 39 more

    这是我的路线
    @Component
    public class XmlRoute extends RouteBuilder {

    @Autowired
    private MyProcessor myProcessor;

    private JaxbDataFormat jaxb = new JaxbDataFormat(true);

    @Override
    public void configure() throws Exception {

    from("direct:my-route")
    .process(myProcessor)
    .marshal(jaxb)
    .log(LoggingLevel.INFO, "${body}")
    .setHeader(Exchange.CONTENT_TYPE, constant(MediaType.TEXT_XML_VALUE))
    .setHeader(Exchange.FILE_NAME, constant("output.xml"))
    .to("file:outputFolder");
    }
    }
    这是我的测试用例
    @RunWith(CamelSpringBootRunner.class)
    @ContextConfiguration
    public class CamelTest extends CamelTestSupport {

    @Produce("direct:my-route")
    protected ProducerTemplate template;

    @EndpointInject("mock:file:outputFolder")
    protected MockEndpoint mock;

    @DirtiesContext
    @Test
    public void testMethod() throws InterruptedException, NullPointerException, JsonProcessingException {
    // Arrange
    ObjectMapper objectMapper = new ObjectMapper();

    mock.expectedBodyReceived();
    Invoice invoice = InvoiceTestDataBuilder.anInvoice().build();

    // Act
    template.sendBody(objectMapper.writeValueAsString(invoice));

    // Assert
    mock.assertIsSatisfied();
    }
    }
    这是我的gradle文件
    /*
    * This file was generated by the Gradle 'init' task.
    */

    plugins {
    id 'org.springframework.boot' version '2.3.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'org.unbroken-dome.xjc' version '1.4.3'
    }

    repositories {
    mavenCentral()
    }

    xjcGenerate {
    source = fileTree('src/main/resources/XSD/maindoc') { include '*.xsd' }
    }


    dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web') {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    }
    implementation 'org.springframework.boot:spring-boot-starter-undertow'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'

    // Camel
    implementation 'org.apache.camel.springboot:camel-spring-boot-starter:3.3.0'
    implementation 'org.apache.camel.springboot:camel-jaxb-starter:3.3.0'
    implementation 'org.apache.camel.springboot:camel-zipfile-starter:3.3.0'
    implementation 'org.apache.camel.springboot:camel-direct:3.3.0'

    implementation 'io.springfox:springfox-swagger2:2.9.2'
    implementation 'io.springfox:springfox-swagger-ui:2.9.2'

    implementation 'com.github.joschi.jackson:jackson-datatype-threetenbp:2.6.4'
    implementation 'javax.validation:validation-api:1.1.0.Final'
    testImplementation 'org.springframework.boot:spring-boot-starter-test:1.5.22.RELEASE'
    testImplementation 'org.apache.camel:camel-test-spring:3.3.0'

    }

    group = 'com.ejemplo.ms'
    version = '1.0.0'
    description = 'swagger-spring'
    sourceCompatibility = '11'
    targetCompatibility = '11'


    tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    }

    最佳答案

    您需要在您的POM文件中导入camel-direct。从 Camel 3开始,直接不再包含在 Camel 核心中。

    关于java - Apache Camel-DirectConsumerNotAvailableException:端点上没有可用的使用者。交换[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63894749/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com