gpt4 book ai didi

java - 如何在 Mule 3.4 ESB 中使用 Datamapper 映射数据库中的 Excel 文件

转载 作者:搜寻专家 更新时间:2023-11-01 03:39:12 26 4
gpt4 key购买 nike

大家早上好

我对 Mule ESB 中的 Datamapper 组件有一个大问题。我正在尝试将 Excel 文件 (xlsx) 映射到 oracle 数据库的表中。为此,我创建了一个带有 Oracle DataSource 及其所有内容的 JDBC 连接器,但是当我转到 DataMapper 向导创建映射时,我无法选择创建的连接器,因为连接器列表中没有项目(在输出数据映射器向导标签中)。[下面是我的问题的屏幕截图]

Screenshot of the DataMapper Wizard

我真的不明白为什么,你可以帮帮我吗?

此外,我有一个问题要问你:我需要在数据库中插入除了 xls 文件提供的字段之外的其他字段,如 MuleMessageID、xls 文件名和 Oracle SYSDATE。可能吗?

为了向您提供尽可能多的信息,我将发布我的骡子项目

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
<spring:beans>
<spring:bean id="SettingProperty" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" scope="singleton">
<spring:property name="locations">
<spring:list>
<spring:value>classpath:pilot.properties</spring:value>
</spring:list>
</spring:property>
</spring:bean>
</spring:beans>

<http:connector name="HTTPConnector"
cookieSpec="netscape"
doc:name="HTTP\HTTPS">
<service-overrides messageFactory="it.aizoon.http.customHttpMultipart.MyHttpMultipartMuleMessageFactory"/>
</http:connector>

<file:endpoint path="${file.output}" name="XSLXFile" responseTimeout="10000" doc:name="File"/>

<jdbc-ee:oracle-data-source name="Oracle_Data_Source" user="${db.user}" password="${db.password}" url="${db.url}" doc:name="Oracle Data Source" transactionIsolation="UNSPECIFIED"/>
<jdbc-ee:connector name="JdbcConnector" dataSource-ref="Oracle_Data_Source" validateConnections="true" queryTimeout="-1" doc:name="Database" pollingFrequency="0">
<jdbc-ee:query key="storedProc" value="CALL ${db.storedProc}" />
</jdbc-ee:connector>
<data-mapper:config name="xls_to_db_grf" transformationGraphPath="xls_to_db.grf" doc:name="xls_to_db_grf"/>

<!-- Starting Flow Declaration -->
<flow name="zonal_imbalance_1.0Flow1" doc:name="zonal_imbalance_1.0Flow1">
<http:inbound-endpoint
address="http://${conn.host}:${conn.port}/${conn.path}"
connector-ref="HTTPConnector" doc:name="HTTP" exchange-pattern="request-response"/>
<wildcard-filter pattern="*/${conn.path}*" caseSensitive="true" doc:name="Wildcard"/>
<file:outbound-endpoint responseTimeout="10000" doc:name="Store XSLX File" path="C:\Users\paride.letizia\MuleStudio\workspace_ee\zonal_imbalance_1.0\src\test\resources\outputFolder"/>
<data-mapper:transform doc:name="DataMapper"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryTimeout="-1" doc:name="ORACLE Database" queryKey="example" connector-ref="JdbcConnector">
<jdbc-ee:query key="example" value="SELECT * FROM prova;"/>
</jdbc-ee:outbound-endpoint>
</flow>
</mule>

在此先非常感谢大家。我期待着您的来信。

最佳答案

我不确切地知道他们为什么决定添加 JDBC“连接器”,但它们的行为实际上并不像连接器。连接器旨在通过特殊 API 与非标准服务建立连接,因此要与 Oracle DB 建立连接,只需按照标准方式即可。

有关详细信息,请参阅 Anypoint 文档,特别是名为“端点和连接器”的段落:

Connectors function like endpoints by sending and receiving data over a transport. However, while endpoints are generic for a widely-used protocol (such as JDBC, FTP, HTTP, POP3, etc) each connector is built to optimize the connection with a specific third-party API, such as Salesforce or Twitter.

Endpoints serve your needs in most cases in which you are connecting to an external resource that has a standard format or protocol. For example, if you are connecting to an Oracle database or a MS SQL database, you can use the Database endpoint, because those databases output their data in a standard format; there is no need for an Oracle or MS SQL connector. Similarly, you don't need a connector for a particular kind of file, like a .csv file. The File endpoint can be configured to input and output data to any kind of text file format, including .csv, so there is no need for a csv connector.

相关:Difference between Mule Connectors and Transports

关于java - 如何在 Mule 3.4 ESB 中使用 Datamapper 映射数据库中的 Excel 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19586901/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com