Frage

I'm building a Mule application that connects to an external database to retrieve some information that is injected into several of my flows. I've tested this locally with a MySQL database, configured using a <jdbc:mysql-data-source> connector.

The issue I have is that this app is being deployed to several environments (testing, production etc) and in each of those environments, the database type for this lookup database differs - for example, in one I am connecting to an Oracle database, and another a MySQL database.

Is there a way I can configure an environment-specific database connector in Mule - so for one environment I may use <jdbc:mysql-data-source>, and in another I may use <jdbc:oracle-data-source>? For info, I'm building my app using Maven. Thanks in advance.

War es hilfreich?

Lösung

there are several options

1) You can use two different files for each of the jdbc connectors.

You can configure in mule-deploy.properties for test environment: config.resources=mule-config.xml,test-jdbc-config.xml And for production environment config.resources=mule-config.xml,prod-jdbc-config.xml

In each of those files you can define your database dependant connector (with the same name), and in mule-config you will reference the connector from your endpoints.

With this approach you will need two different applications for test and prod, because you need these two different mule-deploy.properties files.

Take a look at this docs: http://www.mulesoft.org/documentation/display/current/Deployment+Descriptor

2) You can use a generic jdbc connector referencing a bean where you define the JDBC URL (possible configuring it in a properties file or configuring it as a system property)

3) Create different Spring profiles for defining the beans for JDBC URL as explained here: http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/

Regards.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top