ChannelResolutionException: ไม่มีช่องสัญญาณออกหรือส่วนหัวช่องตอบกลับ - มีเพียงคำขอจำนวนมากเท่านั้น

ฉันกำลังเรียกใช้ส่วนไคลเอนต์ของตัวอย่าง Spring Integration TCP Multiplex ฉันพยายามดูว่าสามารถจัดการคำขอได้จำนวนเท่าใดในคราวเดียวและประมาณ 1,000 รายการ ฉันเริ่มได้รับข้อผิดพลาดนี้: ChannelResolutionException: no output-channel or ReplyChannel header available

ทุกอย่างเรียบร้อยดีต่ำกว่า 1,000 สาย

<beans:description>
        Uses conversion service and collaborating channel adapters.
    </beans:description>

    <context:property-placeholder />

    <converter>
        <beans:bean class="org.springframework.integration.samples.tcpclientserver.ByteArrayToStringConverter" />
    </converter>

    <!-- Fastest Wire Protocol - takes a byte array with its length definied in the first x bytes-->
    <beans:bean id="fastestWireFormatSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer">
        <beans:constructor-arg value="1" />
    </beans:bean>

    <!-- Client side -->

    <gateway id="gw"
        service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
        default-request-channel="input" />

    <ip:tcp-connection-factory id="client"
        type="client"
        host="localhost"
        port="${availableServerSocket}"
        single-use="false"
        serializer="fastestWireFormatSerializer"
        deserializer="fastestWireFormatSerializer"
        so-timeout="10000" />

    <publish-subscribe-channel id="input" />

    <!-- scheduler - Thread used to restablish connection so the other threads aren't starved while waiting to re-establish connection -->
    <!-- client-mode - Automatically re-establishes the connection if lost -->
    <ip:tcp-outbound-channel-adapter id="outAdapter.client"
        order="2"
        channel="input"
        client-mode="true"              
        connection-factory="client" />  <!-- Collaborator -->



    <!-- Also send a copy to the custom aggregator for correlation and
         so this message's replyChannel will be transferred to the
         aggregated message.
         The order ensures this gets to the aggregator first -->
    <bridge input-channel="input" output-channel="toAggregator.client"
            order="1"/>

    <!-- Asynch receive reply -->
    <ip:tcp-inbound-channel-adapter id="inAdapter.client"
        channel="toAggregator.client"
        connection-factory="client" /> <!-- Collaborator -->

    <!-- dataType attribute invokes the conversion service, if necessary -->
    <channel id="toAggregator.client" datatype="java.lang.String" />

    <aggregator input-channel="toAggregator.client"
        output-channel="toTransformer.client"
        correlation-strategy-expression="payload.substring(0,3)"
        release-strategy-expression="size() == 2"
        expire-groups-upon-completion="true" />

    <transformer input-channel="toTransformer.client"
        expression="payload.get(1)"/> <!-- The response is always second -->

    <task:scheduler id="reconnectScheduler" pool-size="10"/>

และรหัสที่ใช้ในการทดสอบ:

        TaskExecutor executor = new SimpleAsyncTaskExecutor();
        final CountDownLatch latch = new CountDownLatch(100);
        final Set<Integer> results = new HashSet<Integer>();
        for (int i = 100; i < 1050; i++) {
            results.add(i);
            final int j = i;
            executor.execute(new Runnable() {
                public void run() {
                    String result = gateway.send(j + "Hello world!"); // first 3 bytes is correlationid
                    System.out.println("Test Result: " + result);
                    results.remove(j);
                    latch.countDown();
                }});
        }

person mad_fox    schedule 16.09.2015    source แหล่งที่มา


คำตอบ (1)


ฉันไม่เข้าใจว่าทำไมคุณถึงได้รับข้อยกเว้นนั้น แต่การทดสอบของคุณมีปัญหาหลายประการ

  1. สลักนับถอยหลังต้องเริ่มต้นที่ 950
  2. เนื่องจากคุณเกิน 999 เราจึงต้องเปลี่ยนความสัมพันธ์:

    payload.substring(0,4)

ด้วยการเปลี่ยนแปลงเหล่านั้น มันได้ผลสำหรับฉัน

ฉันจะพยายามหาคำตอบว่าทำไมเราถึงได้รับข้อยกเว้นนั้นเมื่อฉันมีเวลาเพิ่มขึ้นอีกเล็กน้อย

แก้ไข

ปัญหานี้เกิดจากรหัสความสัมพันธ์ที่ขัดแย้งกัน

50 ข้อความล่าสุดล้วนมีรหัสความสัมพันธ์ 100 ซึ่งหมายความว่าข้อความถูกเผยแพร่ในรูปแบบที่ไม่แน่นอน (เนื่องจากการปล่อยจะขึ้นอยู่กับขนาด) ในบางกรณี ข้อความอินพุตสองข้อความจะถูกปล่อยออกมา (ทำให้เกิดการตอบกลับกรณีทดสอบไม่ถูกต้อง) เมื่อมีการตอบกลับ 2 ครั้ง ไม่มีช่องสัญญาณออก

person Gary Russell    schedule 17.09.2015