我正在尝试获取UDP包的客户端IP和套接字,并使用MEL代码将其保存在Flowvar变量中
#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]
但是这个变量总是为null,我已经能够使它在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的帮助。
答案 0 :(得分:1)
使用:
#[message.inboundProperties['packet.address']]