我試圖得到一個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'屬性的名稱,因爲它通常是爲其他其他的情況下運輸,並給你一個錯誤的名字。你自己解決它:) –