2013-04-29 63 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

相关问题