如何在 Mule ESB 中从 UDP 传输中获取客户端 IP



我正在尝试获取 UDP 包的客户端 IP 和套接字,并使用 MEL 代码将其保存在 Flowvar 变量中

#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]

但是这个变量总是空的,我已经能够让它在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']]

感谢大卫·多索的帮助。

使用:

#[message.inboundProperties['packet.address']]

最新更新