2013-04-29 66 views
0

我做了一個例子Using Mule Studio to read Data from database我想保存在一個文件,從數據庫中的所有記錄(從數據庫中讀取)

我沒有任何問題或錯誤,但我想改變這個計劃。 這個程序創建了大量的文件,並讀取一個記錄,並保存在文件 和騾程序創建並創建了很多文件,直到我終止我的程序 我想保存在一個文件中的所有記錄,並完成程序(不再繼續)。 我離開了我的xml文件中添加後

<jdbc:mysql-data-source name="MySQL_Data_Source" user="roor" password="1234" url="jdbc:mysql://localhost:3306/readdata" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source"/> 
<jdbc:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/> 
<flow name="DBC-PostgreSQL-Mule-ExperimentFlow1" doc:name="DBC-PostgreSQL-Mule-ExperimentFlow1"> 
    <jdbc:inbound-endpoint queryKey="selectplayers" queryTimeout="-1" pollingFrequency="1000" connector-ref="Database" doc:name="Database"> 
     <jdbc:transaction action="NONE"/> 
     <jdbc:query key="selectplayers" value="Select * From Players;"/> 
    </jdbc:inbound-endpoint> 
    <mulexml:object-to-xml-transformer doc:name="Object to XML"/> 
    <file:outbound-endpoint path="E:\me\Mule\sample\1" responseTimeout="10000" doc:name="File" outputPattern="#[function:dateStamp].txt"/> 
</flow> 

錯誤:http://www.mulesoft.org/documentation/display/current/Routing+Message+Processors#RoutingMessageProcessors-CollectionAggregator

你的情況,你必須:

xception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jdbc:inbound-endpoint'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor, "http://www.mulesoft.org/schema/mule/core":response}' is expected. 
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:220) 
    at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64) 
    at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:46) 
    at org.mule.tooling.server.application.ApplicationDeployer.run(ApplicationDeployer.java:56) 
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:88) 
Caused by: org.mule.api.config.ConfigurationException: Line 16 in XML document from URL [file:/E:/program/MuleStudio/.mule/apps/dbc-postgresql-mule-experiment/DBC-PostgreSQL-Mule-Experiment.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jdbc:inbound-endpoint'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor, "http://www.mulesoft.org/schema/mule/core":response}' is expected. (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException) 
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52) 
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78) 
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:80) 
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:208) 
    ... 4 more 

enter image description here

回答

1

這是通過使用收藏彙集實現設置與您的選擇相匹配的關聯ID和組大小,以便Mule在寫入之前等待合適的記錄數量他們到一個單一的文件。

+0

請細節 – maryam 2013-05-04 06:08:35

1

您可以使用不同的入站端點來觸發jdbc數據提取(Quartz,VM等)。這樣,所有記錄都存儲在一個單獨的mule消息中,最後存儲在單個文件中。

<flow name="DBC-PostgreSQL-Mule-ExperimentFlow1" doc:name="DBC-PostgreSQL-Mule-ExperimentFlow1"> 
    <quartz:inbound-endpoint jobName="start" repeatInterval="60000"> 
     <quartz:event-generator-job/> 
    </quartz:inbound-endpoint> 
    <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="selectplayers" queryTimeout="-1" connector-ref="Database" doc:name="Database"> 
     <jdbc:transaction action="NONE"/> 
     <jdbc:query key="selectplayers" value="Select * From Players;"/> 
    </jdbc:outbound-endpoint> 
    <mulexml:object-to-xml-transformer doc:name="Object to XML"/> 
    <file:outbound-endpoint path="E:\me\Mule\sample\1" responseTimeout="10000" doc:name="File" outputPattern="#[function:dateStamp].txt"/> 
</flow> 

問候

+0

感謝replye我就將此解釋在沒有任何流動configureation但我有錯誤,我離開我的控制檯問題請多解釋一下,謝謝 – maryam 2013-04-30 08:45:55

+0

看到我的回答,你還必須將'jdbc:inbound-endpoint'改爲'jdbc:outbound-endpoint'並添加'exchange-pattern =「request-response」' – Daniel 2013-04-30 12:35:34

+0

我在你的程序中複製了你的代碼,但是我有錯誤:屬性'pollingFrequency'不允許出現在元素'jdbc:outbound-endpoint'中。我清理pollingFrequency屬性我沒有錯誤,但我的程序沒有創建任何文件,pollingFrequency是爲 maryam 2013-05-04 06:07:17

相關問題