0

メッセージをactivemqキューに送信するテストがあります。sendBody を使用する場合は問題ありませんが、requestBody を要求するとエバーエシングが正確に発生しますが、応答が得られませんでした

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: com.qqq.dw.beans.invocations.Ping@10699ea]
    at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)
    at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:509)
    at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)
    at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:120)
    at org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:264)
    at functional.RoutesFunctionalTest.testDirectEndpoint1(RoutesFunctionalTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:182)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: ID-Dimas-PC-61919-1341382148513-0-2 not received. Exchange[Message: com.qqq.dw.beans.invocations.Ping@10699ea]
    at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:126)

組み込みの ActiveMQ を使用したり、手動で起動したりしても依存しません。ここに私のルートがあります:

<routeContext id="dwContext" xmlns="http://camel.apache.org/schema/spring">

        <route trace="true">
            <from ref="dwQueueEndpoint"/>
            <to uri="direct:dwEndpoint"/>
        </route>

        <route trace="true">
            <from uri="direct:dwEndpoint"/>
            <to uri="direct:dw.dispatch"/>
        </route>

        <route id="dwDispatcherRoute" trace="true">
            <from uri="direct:dw.dispatch"/>
            <doTry>
                <to uri="direct:dw.dispatchRequest"/>

                <doCatch>
                    <exception>com.qqq.dw.listener.exceptions.ListenerException</exception>
                    <to uri="direct:dw.ExpectedError"/>
                </doCatch>
                <doCatch>
                    <exception>org.apache.camel.CamelException</exception>
                    <exception>org.apache.camel.RuntimeCamelException</exception>
                    <exception>java.lang.Exception</exception>
                    <to uri="direct:dw.Error"/>
                </doCatch>
                <doFinally>
                    <to uri="direct:dw.ResponsePublisher"/>
                </doFinally>
            </doTry>
        </route>

        <route id="dwDispatcherSwitchRoute">
            <from uri="direct:dw.dispatchRequest"/>
            <choice>
                <when>
                    <simple>${body} is 'com.qqq.dw.beans.invocations.Ping'</simple>
                    <log loggingLevel="DEBUG" message="Processing Ping invocation"/>
                    <to uri="direct:dw.Ping"/>
                </when>
            </choice>
        </route>

        <route id="dwPingRoute">
            <from uri="direct:dw.Ping"/>
            <to uri="bean:pingInitializer"/>
            <to uri="bean:pingValidator"/>
            <to uri="bean:pingProcessor"/>
            <to uri="bean:pingFinalizer"/>
        </route>

        <route id="dwErrorRoute">
            <from uri="direct:dw.Error"/>
            <to uri="bean:dwUnknownErrorExceptionProcessor"/>
        </route>

        <route id="dwExpectedErrorRoute">
            <from uri="direct:dw.ExpectedError"/>
            <to uri="bean:dwExceptionProcessor"/>
        </route>

        <route id="dwResponsePublisherRoute">
            <from uri="direct:dw.ResponsePublisher"/>
            <to uri="bean:dwResponsePublisher"/>
        </route>

    </routeContext>

そしてテスト:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/dw-listener-test-jms-client.xml"})
public class RoutesFunctionalTest {

    @Autowired
    ProducerTemplate producerTemplate;

    @Before
    public void before() {
        ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
                "/dw-listener-test-jms-server.xml"
        );
    }
@Test
    public void testDirectEndpoint1() throws Exception {
        Ping invocation = new Ping();
        invocation.setRequestId("123456789");
        invocation.setMessage("PING-PING-PING");
        invocation.setRequestTime(new Date().getTime());
        Object o = producerTemplate.requestBody(invocation);
        Thread.sleep(3000);
        assertNotNull(o);
    }

私が逃したものは何ですか?

4

1 に答える 1

0

ActiveMQ への参照は表示されませんが、通常、キューへの送信は InOnly 操作であり、OUT 応答は返されません (したがって、sendBody は機能しますが、requestBody は失敗します)...

InOut 動作が必要な場合は、次のようにします...

https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOutSynchronousTest.java

于 2012-07-05T05:05:57.723 に答える