嘗試使用Mule XML流功能來處理非常大的xml文件。遵循文檔,文檔沒有具體的例子。Mule XML Streaming - (Mule xmltoxmltransformation)
當我檢查有效負載時,我得到了XMLUtils類,而不是文檔中所述的XMLStreamReader類。
流程如下有一個文件連接器,它將有效載荷傳遞給一個自定義變換器,變換器將數據傳遞給將要基於事件處理的spring bean。
春豆。在運行時,spring bean獲取XMLUtils類而不是XMLStreamReader類。
騾子 - 配置:
<spring:beans>
<spring:bean id="OracleCDMMapper" class="oraclecdmstream.OracleCDMMapper">
</spring:bean>
<spring:bean id = "OraclePaySlip" class="com.nect.transform.OracleCDMPaySlip" ></spring:bean>
</spring:beans>
<flow name="mulefileconnectorexampleFlow1" >
<file:inbound-endpoint path="C:/c-OracleCloud/src/main/resources" pollingFrequency="600000" moveToDirectory="C:/c-OracleCloud/src/main/resources/back" doc:name="File Input" >
<!-- <file:filename-regex-filter pattern="(^*.xml$)" caseSensitive="false"/>
--> <file:filename-wildcard-filter pattern="*.xml"></file:filename-wildcard-filter>
</file:inbound-endpoint>
<logger message="Transferring file : #[message.inboundProperties['originalFilename']]" level="INFO" doc:name="Logger"/>
<logger message ="Logger 1 " level="INFO" doc:name ="Logger1" />
<!-- Call the XMLSTREAMER -->
**<custom-transformer name="XmlToXSR" class="org.mule.module.xml.transformer.XmlToXMLStreamReader" doc:name="XMLTOORACLE">**
</custom-transformer>
<component doc:name="Java">
<spring-object bean="OracleCDMMapper"/>
</component>
-->
<logger message ="I am Complete " level="INFO" doc:name ="LoggerMurali" />
</flow>
</mule>
這裏是Javacode:
Spring Bean
public class OracleCDMMapper implements Callable {
private final Logger logger = LoggerFactory.getLogger(OracleCDMMapper.class);
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
// TODO Auto-generated method stub
MuleMessage muleMessage = eventContext.getMessage();
logger.info("In the Spring Component");
logger.info(muleMessage.getPayload().getClass().toString());
**javax.xml.stream.XMLStreamReader xsr = (XMLStreamReader) muleMessage.getPayload(javax.xml.stream.XMLStreamReader.class);**
任何幫助將非常感激
您確定您正在獲取XMLUtils的實例嗎?在源代碼中有幾個地方我發現它會返回一個確實實現XMLStreamReader的匿名內部類。如果你在類上使用toStriing(),這將看起來像XMLUtils $ 2。也許還可以嘗試記錄getClass()。getName()或getFullName()。 –