0

我做了一个例子 ,使用 Mule Studio 从数据库中读取数据

我没有任何问题或错误,但我想更改此程序。该程序创建大量文件并读取一条记录并保存到文件中,并且骡程序创建并创建大量文件,直到我终止我的程序我想将所有记录保存在一个文件中并完成程序(不再继续)。我留下了我的 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>

添加后的错误:

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

在此处输入图像描述

4

2 回答 2

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>

问候

于 2013-04-29T20:24:02.920 回答
1

这是通过使用集合聚合来实现的:http: //www.mulesoft.org/documentation/display/current/Routing+Message+Processors#RoutingMessageProcessors-CollectionAggregator

在您的情况下,您必须设置与您的选择相匹配的相关 ID 和组大小,以便 Mule 将等待正确数量的记录聚合,然后再将它们写入单个文件。

于 2013-04-29T16:59:19.013 回答