【问题标题】:Inbound channel adapter throwing "no output-channel or replyChannel header available" error入站通道适配器抛出“没有可用的输出通道或回复通道标头”错误
【发布时间】:2019-07-22 14:59:32
【问题描述】:

我想从 JMS 获取消息并将其作为 HTTP 请求发送,如果失败,请再次将其排队到 JMS。

我尝试使用入站消息适配器和消息驱动通道适配器,但它失败了,因为我得到“ChannelResolutionException:没有可用的输出通道或replyChannel 标头”异常,但因为我不想回复inbound-message-adapter,不知道为什么要包含一个replyChannel 标头


    <jms:outbound-channel-adapter id="outboundJMSAdaptor" jms-template="jmsTemplate"
            channel="jmsOutChannel"
            destination="requestQueue"/>
    <int:channel id="jmsInChannel" />

    <jms:message-driven-channel-adapter
            channel="jmsInChannel" destination="requestQueue"
            connection-factory="jmsConnectionFactory" message-converter="jmsMessageConverter"/>

    <int:header-enricher input-channel="jmsInChannel" output-channel="header_enriched_request">
        <int:header name="addressId" expression="payload.getId()"/>
        <int:header name="Accept-Language" value="en_GB"/>
        <int:header name="X-Source-CountryCode" value="GB"/>
        <int:header name="X-Source-Operator" value="Enterprise"/>
        <int:header name="X-Source-Division" value="CustomerManagement"/>
        <int:header name="X-Source-System" value="${sapwebservices.http.header.source.system}"/>
        <int:header name="X-Source-Timestamp" expression="new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(new java.util.Date())"/>
        <int:header name="Accept" value="application/json"/>
        <int:header name="Content-Type" value="application/json;charset=UTF-8"/>
    </int:header-enricher>

    <int:object-to-json-transformer input-channel="header_enriched_request"
            output-channel="update_customer_shipping_address_outbound_gateway"
            object-mapper="nonNullObjectMapper"/>

    <http:outbound-gateway mapped-request-headers="Accept*, Content-Type, X-*, HTTP_REQUEST_HEADERS"
            request-channel="update_customer_shipping_address_outbound_gateway"
            reply-channel="print_payload_update_shipping"
            url="${sapwebservices.ws.uri.updatecustomershippingaddress}"
            http-method="PUT"
            expected-response-type="java.lang.String"
            charset="UTF-8"
            request-factory="updateCustomerAccountRequestFactory">
        <http:uri-variable name="id" expression="headers['addressId']"/>
    </http:outbound-gateway>
    <int:service-activator input-channel="print_payload_update_shipping" output-channel="clean_no_print_char_update_customershippingaddress" ref="sapPrintPayload"/>
    <int:transformer input-channel="clean_no_print_char_update_customershippingaddress" output-channel="resp_mapping_json_to_jsonobj_updatecustomershippingaddress">
        <bean class="util.CleanNoPrintCharTransformer"/>
    </int:transformer>
    <int:json-to-object-transformer input-channel="resp_mapping_json_to_jsonobj_updatecustomershippingaddress"
                                    output-channel="clean_no_print_char_update_customershippingaddress"
                                    type="customer_shipping_address_response.json.CustomerShippingAddressResponse"/>
    <int:transformer input-channel="clean_no_print_char_update_customershippingaddress" output-channel="">
        <bean class="transformer.CreateCustomerShippingAddressPostTransformer"/>
    </int:transformer>

我希望在正常运行中成功,但出现错误

org.springframework.integration.dispatcher.AggregateMessageDeliveryException: All attempts to deliver Message to MessageHandlers failed. Multiple causes:
    All attempts to deliver Message to MessageHandlers failed. Multiple causes:
    no output-channel or replyChannel header available
    org.springframework.integration.MessageHandlingException: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method transform(rest.bbr.customer_shipping_address_response.json.CustomerShippingAddressResponse) cannot be found on bbr.sap.util.CleanNoPrintCharTransformer type
See below for the stacktrace of the first cause.
    org.springframework.integration.MessageHandlingException: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method transform(java.lang.String) cannot be found on bbr.sap.transformer.CreateCustomerShippingAddressPostTransformer type
See below for the stacktrace of the first cause.

此外,如果 http:outbound-gateway 响应为 null 或第 3 方服务已关闭,则希望将消息再次排入 jms 队列。

【问题讨论】:

    标签: spring spring-integration spring-jms spring-integration-amqp


    【解决方案1】:
    <int:transformer input-channel="clean_no_print_char_update_customershippingaddress" 
            output-channel="">
    

    变压器上不能有空的输出通道。

    转换某些东西然后丢弃转换后的结果并没有什么意义,但如果这是您真正想要做的,请将其发送到nullChannel

    <int:transformer input-channel="clean_no_print_char_update_customershippingaddress" 
            output-channel="nullChannel">
    

    【讨论】:

    • 谢谢加里。如果响应为空或第 3 方服务器已关闭,您知道如何将相同的原始请求消息重新排入队列吗?
    • 你真的不应该在 cmets 中问补充问题;它不能帮助人们找到问题/答案。使用消息驱动适配器时,如果抛出异常,它将自动重新入队,只要您只使用可订阅通道(默认),以便流程在容器线程上运行。
    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 2022-01-17
    • 2016-05-28
    • 2018-06-12
    • 2018-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多