ule子的http-proxy不能在流中使用吗? [英] mule's http-proxy cannot be used in flow?

查看:66
本文介绍了ule子的http-proxy不能在流中使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为后端休息服务做一个代理,但是在将请求转发给后端之前,我需要做一些检查.我检查了文档,有一个http-proxy可以用来做代理,但是当我放入流程中时,有例外.如果我使用http:outbound-endpoint,则该方法不能是动态MEL表达式(其余方法可以是POST,GET,PUT,DELTE等).

I would like to do a proxy for backend rest service, but before I forward the request to backend, I need to do some checks. I checked the docments, there is a http-proxy can be used to do the proxy, but when I put into the flow, there are exceptions. If I use the http:outbound-endpoint the method cannot be a dynamic MEL expression(rest method could be POST, GET, PUT, DELTE etc).

你能给我一个建议吗?一个例子会更好,非常感谢. 我的配置:

Could you give me a suggestion? An example will be better, Thanks a lot. My Configuration:

<flow name="demo.routerFlow1" doc:name="demo.routerFlow1">
  <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="HTTP" />
  <logger
    message="Method: #[message.inboundProperties['http.method']], URI: #[message.inboundProperties['http.request.path']], Params: #[message.inboundProperties['http.query.params']]"
    level="INFO" doc:name="Logger" />
  <http:body-to-parameter-map-transformer doc:name="Body to Parameter Map" />
  <choice doc:name="Choice">
    <when expression="(payload['timestamp'] == null || payload['nonce'] == null)">
      <expression-component doc:name="Check Required Params"><![CDATA[payload="{\"code\":\"PA001\", \"message\":\"missing required parameter timestamp and nonce\"}"]]>
      </expression-component>
    </when>
    <otherwise>
      <choice doc:name="Choice">
        <when expression="!replayAttackCheck.validate(payload)" evaluator="groovy">
          <expression-component doc:name="Check Required Params"><![CDATA[payload="{\"code\":\"PA002\", \"message\":\"timestamp or nonce is illegal\"}"]]>
          </expression-component>
        </when>
        <otherwise>
          <processor-chain doc:name="Processor Chain">
            <pattern:http-proxy name="http-proxy-sample"> <!--line 38-->
              <http:inbound-endpoint address="http://localhost:8080/"></http:inbound-endpoint>
              <http:outbound-endpoint address="http://localhost:8081/"></http:outbound-endpoint>
            </pattern:http-proxy>
          </processor-chain>
        </otherwise>
      </choice>
    </otherwise>
  </choice>
</flow>

错误:

Caused by: org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 31; cvc-complex-type.2.4.b: The content of element 'processor-chain' is not complete. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

推荐答案

配置模式是独立的,并且与任何流分开,并且不能在一个流中进行配置.它们是常见方案的预定义集成模式.流程是用来滚动自己的流程的.参见此处: http://www.mulesoft.org/文档/显示/当前/选择+在+流程+和+模式之间

Configuration patterns are standalone and separate from any flow and cannot be configured within one. They are predefined integration patterns for common scenarios. Flows are for rolling your own. See here: http://www.mulesoft.org/documentation/display/current/Choosing+Between+Flows+and+Patterns

请注意:您已经在localhost:8080上进行侦听,所以我认为您只想在运行8081的服务上使用http:outbound-endpoint

As a side note: Your already listening on localhost:8080, so I think you just want a http:outbound-endpoint to the service your running on 8081

<http:outbound-endpoint address="http://localhost:8081/" />

这篇关于ule子的http-proxy不能在流中使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆