我试图得到一个UDP包的客户端IP和插座,并使用MEL代码如何在Mule ESB中通过UDP传输获取客户端IP?
#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]
但是这个变量总是空,我已经能够使它发挥它保存在一个Flowvar变量在TCP传输上,有没有人知道如何获得UDP中的远程客户端地址?
这是我的XML文件:
<mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:udp="http://www.mulesoft.org/schema/mule/udp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/udp http://www.mulesoft.org/schema/mule/udp/current/mule-udp.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
<udp:connector name="UDP" validateConnections="true" keepSendSocketOpen="true" doc:name="UDP" broadcast="true"/>
<flow name="udpFlow">
<udp:inbound-endpoint exchange-pattern="one-way" host="172.22.20.103" port="4040" connector-ref="UDP" responseTimeout="10000" doc:name="UDP" metadata:id="9260547c-3b58-4ebd-953e-fd3e7bb063f3"/>
<object-to-string-transformer doc:name="Object to String"/>
<set-variable variableName="source" value="#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]" metadata:id="6a72ad72-167f-44da-9f3d-75143c5c0a2f" doc:name="Variable"/>
<set-payload value="#[flowVars.source] dice #[payload]" doc:name="Set Payload"/>
<echo-component doc:name="Echo"/>
</flow>
</mule>
更新: 我解决地址问题与MEL代码
#[message.inboundProperties['packet.address']]: #[message.inboundProperties['packet.port']]
感谢David Dossot对他的帮助。
别谢我,我并没有意识到'udp'前缀没有前置到'packet.address'属性的名称,因为它通常是为其他其他的情况下运输,并给你一个错误的名字。你自己解决它:) –