This commit is contained in:
Clebert Suconic 2021-02-04 15:32:52 -05:00
commit 337df5286c
4 changed files with 13 additions and 11 deletions

View File

@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.jdbc.store.drivers;
import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
import org.apache.commons.beanutils.PropertyUtils;
import org.jboss.logging.Logger;
import javax.sql.DataSource;
import java.util.Map;
@ -25,13 +25,12 @@ import java.util.stream.Collectors;
public class JDBCDataSourceUtils {
private static final Logger logger = Logger.getLogger(JDBCDataSourceUtils.class);
public static DataSource getDataSource(String dataSourceClassName, Map<String, Object> dataSourceProperties) {
logger.info(new StringBuilder("Initialising JDBC data source: ").append(dataSourceClassName).append(" ")
.append(dataSourceProperties.keySet().stream()
.map(key -> key + "=" + dataSourceProperties.get(key))
.collect(Collectors.joining(", ", "{", "}"))));
ActiveMQJournalLogger.LOGGER.initializingJdbcDataSource(dataSourceClassName, dataSourceProperties
.keySet()
.stream()
.map(key -> key + "=" + dataSourceProperties.get(key))
.collect(Collectors.joining(", ", "{", "}")));
try {
DataSource dataSource = (DataSource) Class.forName(dataSourceClassName).newInstance();
for (Map.Entry<String, Object> entry : dataSourceProperties.entrySet()) {

View File

@ -85,6 +85,10 @@ public interface ActiveMQJournalLogger extends BasicLogger {
@Message(id = 141009, value = "A Free File is less than the maximum data", format = Message.Format.MESSAGE_FORMAT)
void fileTooSmall();
@LogMessage(level = Logger.Level.INFO)
@Message(id = 141010, value = "Initialising JDBC data source {0} with properties {1}", format = Message.Format.MESSAGE_FORMAT)
void initializingJdbcDataSource(String dataSourceClassName, String dataSourceProperties);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 142000, value = "You have a native library with a different version than expected", format = Message.Format.MESSAGE_FORMAT)
void incompatibleNativeLibrary();

View File

@ -1739,13 +1739,12 @@ public class ConfigurationImpl implements Configuration, Serializable {
sb.append("clustered=").append(isClustered()).append(",");
if (isJDBC()) {
DatabaseStorageConfiguration dsc = (DatabaseStorageConfiguration) getStoreConfiguration();
sb.append("jdbcDriverClassName=").append(dsc.getJdbcDriverClassName()).append(",");
sb.append("jdbcConnectionUrl=").append(dsc.getJdbcConnectionUrl()).append(",");
sb.append("jdbcDriverClassName=").append(dsc.getDataSourceProperty("driverClassName")).append(",");
sb.append("jdbcConnectionUrl=").append(dsc.getDataSourceProperty("url")).append(",");
sb.append("messageTableName=").append(dsc.getMessageTableName()).append(",");
sb.append("bindingsTableName=").append(dsc.getBindingsTableName()).append(",");
sb.append("largeMessageTableName=").append(dsc.getLargeMessageTableName()).append(",");
sb.append("pageStoreTableName=").append(dsc.getPageStoreTableName()).append(",");
} else {
sb.append("journalDirectory=").append(journalDirectory).append(",");
sb.append("bindingsDirectory=").append(bindingsDirectory).append(",");

View File

@ -1740,7 +1740,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
DatabaseStorageConfiguration conf = new DatabaseStorageConfiguration();
conf.setBindingsTableName(getString(storeNode, "bindings-table-name", conf.getBindingsTableName(), Validators.NO_CHECK));
conf.setMessageTableName(getString(storeNode, "message-table-name", conf.getMessageTableName(), Validators.NO_CHECK));
conf.setLargeMessageTableName(getString(storeNode, "large-message-table-name", conf.getJdbcConnectionUrl(), Validators.NO_CHECK));
conf.setLargeMessageTableName(getString(storeNode, "large-message-table-name", conf.getLargeMessageTableName(), Validators.NO_CHECK));
conf.setPageStoreTableName(getString(storeNode, "page-store-table-name", conf.getPageStoreTableName(), Validators.NO_CHECK));
conf.setNodeManagerStoreTableName(getString(storeNode, "node-manager-store-table-name", conf.getNodeManagerStoreTableName(), Validators.NO_CHECK));
conf.setJdbcConnectionUrl(getString(storeNode, "jdbc-connection-url", conf.getJdbcConnectionUrl(), Validators.NO_CHECK));