我是mule和Java的新手,并尝试编写一个通用流程,它将使用我在组件级别设置的流量变量的值来转换有效负载。在我的流程片段下面。如何将表达式变换器用作通用的。也就是说它应该执行存储在流变量中的值并操纵有效负载。
<flow name="process_incoming__eflow_messagesFlow1" doc:name="process_incoming__eflow_messagesFlow1">
<vm:inbound-endpoint exchange-pattern="request-response" path="TransformToBod" doc:name="Transfor to BOD VM"/>
<logger message="message received from BOD VM #[payload]" level="INFO" doc:name="Logger"/>
<component class="com.efi.radius.components.GetMessageType" doc:name="Java - Get the type of BOD comming into Payload"/>
<logger message="The BOD class to trasform is #[flowVars.messageType]" level="INFO" doc:name="Logger"/>
<custom-transformer class="com.efi.radius.transformers.XMLToBODTransformer" doc:name="Java - XML to BOD Transformer">
</custom-transformer>
<logger message="The Data Area to map is #[flowVars.messageBODType]" level="INFO" doc:name="Logger"/>
<logger message="The payload now is #[payload]" level="INFO" doc:name="Logger"/>
<expression-transformer expression="#[flowVars['messageBODType']]" doc:name="Expression - Extract the Data Area"/>
</flow>
我设置流变量
的GetMessageType.Java片段 if (payload.indexOf("<ProcessCustomerPartyMaster") != -1) {
// Set the message type to customer
eventContext.getMessage().setInvocationProperty("messageType", "com.efi.radius.models.bod.ProcessCustomerPartyMasterType");
eventContext.getMessage().setInvocationProperty("messageBODType", "#[message.payload.getDataArea().getCustomerPartyMaster().get(0)]");
}
我还写了一个自定义变换器,我收到&#34; messageType&#34;的值。正确并转换如下。
XMLToBODTransformer.java的片段 bodClassName = message.getInvocationProperty(&#34; messageType&#34;);
这很好用。
如果我直接写#message.payload.getDataArea()。getCustomerPartyMaster()。get(0)]&#34;在表达式变换器中,它按预期工作,但我想让它变得通用。有没有办法做到这一点?
添加错误日志。
#[flowVars.messageBODType]的值是&#34;#[message.payload.getDataArea()。getCustomerPartyMaster()。get(0)]&#34;我在GetMessageType.Java中设置如上所示
运行后请找到控制台的代码段。 INFO [[iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:197) - trasform的BOD类是com.efi.radius.models.bod.ProcessCustomerPartyMasterType com.efi.radius.models.bod.ProcessCustomerPartyMasterType INFO [ [iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:197) - 要映射的数据区是#[message.payload.getDataArea()。getCustomerPartyMaster()。get(0)] INFO [[iQuoteIntegration] .process_iquote_job .stage1.02](DispatchingLogger.java:197) - 现在的有效负载是com.efi.radius.models.bod.ProcessCustomerPartyMasterType@3dcc579c INFO [[iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:197) - BOD对象转换后的有效负载为#[message.payload.getDataArea()。getCustomerPartyMaster()。get(0)] INFO [[iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:197) - 初始化:&# 39; connector.VM.mule.default.dispatcher.1280679149&#39 ;.对象是:VMMessageDispatcher INFO [[iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:197) - 开始:&#39; connector.VM.mule.default.dispatcher.1280679149&#39;。对象是:VMMessageDispatcher ERROR [[iQuoteIntegration] .process_iquote_job.stage1.02](DispatchingLogger.java:341) -
消息:无法找到组件的入口点,以下解析器已尝试但失败:[ReflectionEntryPointResolver:在对象上找到了太多可能的方法&#34; com.efi.radius.transformers.EFlowJobToRadiusJob&#34;接受参数&#34; {class java.lang.String}&#34;,匹配的方法是&#34; [public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object抛出org.mule.api.transformer.TransformerException,public void org.mule.transformer.AbstractTransformer.setName(java.lang.String),public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String), public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String)throws javax.activation.MimeTypeParseException]&#34; AnnotatedEntryPointResolver:Component:EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39;}, sourceTypes = []}没有任何带注释的方法,跳过。 CallableEntryPointResolver:Object&#34; EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39 ;},sourceTypes = []}&#34;没有实现所需的接口&#34;接口org.mule.api.lifecycle.Callable&#34; MethodHeaderPropertyEntryPointResolver:必需的属性&#34;方法&#34;未在事件中设置]代码:MULE_ERROR-321
异常堆栈是:1。无法找到组件的入口点,以下解析器尝试但失败:[ReflectionEntryPointResolver:在对象上发现了太多可能的方法&#34; com.efi.radius.transformers.EFlowJobToRadiusJob&#34;接受参数&#34; {class java.lang.String}&#34;,匹配的方法是&#34; [public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object抛出org.mule.api.transformer.TransformerException,public void org.mule.transformer.AbstractTransformer.setName(java.lang.String),public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String), public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String)throws javax.activation.MimeTypeParseException]&#34; AnnotatedEntryPointResolver:Component:EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39;}, sourceTypes = []}没有任何带注释的方法,跳过。 CallableEntryPointResolver:Object&#34; EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39 ;},sourceTypes = []}&#34;没有实现所需的接口&#34;接口org.mule.api.lifecycle.Callable&#34; MethodHeaderPropertyEntryPointResolver:必需的属性&#34;方法&#34;没有在事件上设置](org.mule.model.resolvers.EntryPointNotFoundException)
org.mule.model.resolvers.DefaultEntryPointResolverSet:52(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/model/resolvers/EntryPointNotFoundException.html)
Root异常堆栈跟踪:org.mule.model.resolvers.EntryPointNotFoundException:无法找到组件的入口点,尝试了以下解析器但失败了:[ReflectionEntryPointResolver:在对象上发现了太多可能的方法&#34; com.efi .radius.transformers.EFlowJobToRadiusJob&#34;接受参数&#34; {class java.lang.String}&#34;,匹配的方法是&#34; [public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object抛出org.mule.api.transformer.TransformerException,public void org.mule.transformer.AbstractTransformer.setName(java.lang.String),public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String), public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String)throws javax.activation.MimeTypeParseException]&#34; AnnotatedEntryPointResolver:Component:EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39;}, sourceTypes = []}没有任何带注释的方法,跳过。 CallableEntryPointResolver:Object&#34; EFlowJobToRadiusJob {this = b72e07f,name =&#39; null&#39 ;, ignoreBadInput = false,returnClass = SimpleDataType {type = java.lang.Object,mimeType =&#39; /&#39 ;},sourceTypes = []}&#34;没有实现所需的接口&#34;接口org.mule.api.lifecycle.Callable&#34; MethodHeaderPropertyEntryPointResolver:必需的属性&#34;方法&#34;未在事件中设置]
答案 0 :(得分:0)
你想要实现的目标,至少不是这样。 你看,如果你正在做什么工作没有什么会阻止某人发送,让我们说一个MEL表达式作为http请求中的有效负载,并让它在你的代码中执行,就像MEL注入一样,如果你愿意的话。
我建议你缩小你想要的内容,或者将这样的表达式存储在文件中,并使用你的另一个消息值来选择要执行的文件。
HTH