简体   繁体   English

ule子message.getInvocationProperty无法从Java方法中解析

[英]mule message.getInvocationProperty cannot be resolved from within Java method

I'm trying to access a mule flowVar from within a Java class: 我正在尝试从Java类中访问m子flowVar:

In the mule processor: flowVars.rootFilePath="c:\\test" 在ule子处理器中: flowVars.rootFilePath =“ c:\\ test”

From within the mule processor, I'm calling the java method renameFile(oldFile, newFile) : 从the子处理器内部,我正在调用java方法namedFile(oldFile,newFile)

package com.rename; 包com.rename;

import java.io.File; 导入java.io.File; import org.mule.api.MuleMessage; 导入org.mule.api.MuleMessage;

public class FileRename { 公共类FileRename {

public String renameFile(String oldFile, String newFile) {
    File file1 = new File(message.getInvocationProperty("rootFilePath") + oldFile);
    File file2 = new File(message.getInvocationProperty("rootFilePath") + newFile);
    file1.renameTo(file2);
    return "Renaming " + oldFile + " to: " + newFile;
}

} }

However, I'm receiving the error " message cannot be resolved". 但是,我收到错误“ 消息无法解析”。 What am I missing here? 我在这里想念什么? Your help is very much appreciated! 非常感激你的帮助!

Why can't you use onCall Method to do this? 为什么不能使用onCall方法来执行此操作?

You can use below code as a sample to access message. 您可以使用以下代码作为示例来访问消息。

public class MyComponent implements Callable {
 @Override
    public Object onCall(MuleEventContext eventContext) throws Exception {
     String oldFile = eventContext.getMessage().getProperty('');
      return "Renaming " + oldFile + " to: " + newFile;";
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM