Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
18.2. Using a JDBC Lock System
Overview 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The JDBC locking mechanism is intended for failover deployments where Red Hat JBoss Fuse instances exist on separate machines.
In this scenario, the master instance holds a lock on a locking table hosted on a database. If the master loses the lock, a waiting slave process gains access to the locking table and fully starts its container.
Adding the JDBC driver to the classpath 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
In a JDBC locking system, the JDBC driver needs to be on the classpath for each instance in the master/slave setup. Add the JDBC driver to the classpath as follows:
- Copy the JDBC driver JAR file to the
ESBInstallDir/lib
directory for each Red Hat JBoss Fuse instance. - Modify the
bin/karaf
start script so that it includes the JDBC driver JAR in itsCLASSPATH
variable.For example, given the JDBC JAR file,JDBCJarFile.jar
, you could modify the start script as follows (on a *NIX operating system):Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are adding a MySQL driver JAR or a PostgreSQL driver JAR, you must rename the driver JAR by prefixing it with thekaraf-
prefix. Otherwise, Apache Karaf will hang and the log will tell you that Apache Karaf was unable to find the driver.
Configuring a JDBC lock system 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To configure a JDBC lock system, update the
etc/system.properties
file for each instance in the master/slave deployment as shown
Example 18.2. JDBC Lock File Configuration
In the example, a database named sample will be created if it does not already exist. The first Red Hat JBoss Fuse instance to acquire the locking table is the master instance. If the connection to the database is lost, the master instance tries to gracefully shutdown, allowing a slave instance to become master when the database service is restored. The former master will require manual restart.
Configuring JDBC locking on Oracle 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
If you are using Oracle as your database in a JDBC locking scenario, the karaf.lock.class property in the
etc/system.properties
file must point to org.apache.karaf.main.OracleJDBCLock.
Otherwise, configure the
system.properties
file as normal for your setup, as shown:
Example 18.3. JDBC Lock File Configuration for Oracle
Note
The karaf.lock.jdbc.url requires an active Oracle system ID (SID). This means you must manually create a database instance before using this particular lock.
Configuring JDBC locking on Derby 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
If you are using Derby as your database in a JDBC locking scenario, the karaf.lock.class property in the
etc/system.properties
file should point to org.apache.karaf.main.DerbyJDBCLock. For example, you could configure the system.properties
file as shown:
Example 18.4. JDBC Lock File Configuration for Derby
Configuring JDBC locking on MySQL 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
If you are using MySQL as your database in a JDBC locking scenario, the karaf.lock.class property in the
etc/system.properties
file must point to org.apache.karaf.main.MySQLJDBCLock. For example, you could configure the system.properties
file as shown:
Example 18.5. JDBC Lock File Configuration for MySQL
Configuring JDBC locking on PostgreSQL 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
If you are using PostgreSQL as your database in a JDBC locking scenario, the karaf.lock.class property in the
etc/system.properties
file must point to org.apache.karaf.main.PostgreSQLJDBCLock. For example, you could configure the system.properties
file as shown:
Example 18.6. JDBC Lock File Configuration for PostgreSQL
JDBC lock classes 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The following JDBC lock classes are currently provided by Apache Karaf:
org.apache.karaf.main.DefaultJDBCLock org.apache.karaf.main.DerbyJDBCLock org.apache.karaf.main.MySQLJDBCLock org.apache.karaf.main.OracleJDBCLock org.apache.karaf.main.PostgreSQLJDBCLock
org.apache.karaf.main.DefaultJDBCLock
org.apache.karaf.main.DerbyJDBCLock
org.apache.karaf.main.MySQLJDBCLock
org.apache.karaf.main.OracleJDBCLock
org.apache.karaf.main.PostgreSQLJDBCLock