为什么此代码允许某人在消息处理器(如 Java 组件)中创建入站消息属性
message.setProperty("myProperty", PropertyScope.INBOUND" );
但这并不
<set-property value="100" propertyName="myProperty" />
根据文档,只有消息源应该能够创建入站属性,那么为什么 Java 组件能够设置入站消息属性?
最佳答案
您是对的 - 这确实违反了入站属性的记录行为。此外,证明您是否尝试使用表达式组件设置入站属性:
<expression-component>
message.inboundProperties['foo'] = 'bar'
</exporession-component>
运行时会抛出以下错误:
Exception stack is:
1. The inbound message property "foo" cannot be added, updated or removed
because inbound message properties are immutable (java.lang.UnsupportedOperationException)
org.mule.el.context.MessagePropertyMapContext:47 (null)
但是 setProperty 的 Javadoc说:
Set a property on the message. End-users should prefer more scope-specific methods for readability. This one is more intended for programmatic scope manipulation and Mule internal use.
所以要点是 setProperty 是供 Mule 内部使用的,你应该使用 setInitationProperty、setOutboundProperty 或 setSessionProperty。这很有趣,因为我确信我以前使用过 setProperty。
关于java - 入站属性骡子创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21584859/