这是我在Mule中的xml的一部分。 >
<flow name="CatalogueFlow_BC" doc:name="CatalogueFlow_BC">
< wmq:inbound-endpoint queue="${wmq.queue.nameCT_BC}" connector-ref="WMQ" doc:name="WMQ"/>
< object-to-string-transformer doc:name="File Mapping"/>
< custom-transformer class="catalogue.ServiceController_BC" doc:name="Java"/>
<logger message="******************Entered Catalogue SOAP File with Province Name BC is Processed*********" level="INFO" category="Audit_LogCAT" doc:name="CAT Logger"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
logger message="*******************************Entered Catalogue SOAP File with Province Name BC is having error: #[exception.causeException]****************" level="INFO" category="Audit_LogCAT" doc:name="CAT Exception Logger"/>
/catch-exception-strategy>
</flow>
我的java代码正在将即将发布的SOAP消息从队列转换为文本文件。它的设计方式是2个SOAp消息将生成1个带有2个SOAP记录的文本文件。 问题是,当我运行我的骡子流,并将消息逐个放入队列时,一切都很好。但是如果我直接在队列中放入2条消息,即首先我将2条消息放入队列然后运行我的流程,它只采用第一个SOAP,并且在java转换之后,First SOAP的结果在文本文件中打印2次。
public class IPController_BC extends AbstractMessageTransformer{
TimeOut timeOut = TimeOut.getInstance();
@SuppressWarnings({ "unused" })
public Object transformMessage(MuleMessage message, String outputEncoding)throws TransformerException {
String flagGetPayload = null;
String intermediateFile = null;
String invoiceFile = null;
try {
// Get the payload from the mule message and store in the flagGetPayload
flagGetPayload= (String) message.getPayload();
try{
Properties prop = new Properties();
prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("path_config.properties"));
intermediateFile = prop.getProperty("INTERMEDIATEIP_LOCATION");
invoiceFile=prop.getProperty("INVOICEIP_LOCATION");
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error("IOException",e1);
}
//WRITING MESSAGE INTO A FILE FROM flagGetPayload
File file = new File(intermediateFile+"/soap.xml");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(flagGetPayload);
bw.close();
//
String ProvinceName="BC";
InterchangeablePriority ip=new InterchangeablePriority();
System.out.println("start operation");
ip.startOperationIP(ProvinceName);
//ip.deleteFile();
}
catch (Exception e) {
logger.error("Exception",e);
}
File folder = new File(invoiceFile);
File[] listOfFiles = folder.listFiles();
for (File file : listOfFiles){
}
String file = null;
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
file= listOfFiles[i].getAbsolutePath();
} else if (listOfFiles[i].isDirectory()) {
}
}
return file;
}
public TimeOut setTimer() {
timeOut.schedule(30);
return timeOut;
}
}
这是附加的java类。在这个java类中,正在调用更多函数。
答案 0 :(得分:0)
您的方法存在许多问题:
file:outbound-endpoint
。InterchangeablePriority
的调用可能应该在一个组件中完成。如果线程安全,则只创建一个带有Spring bean的对象,并在组件中使用它。timeOut
的意图。ProvinceName
=&gt; provinceName
(Java编码标准)。