By default the documentation for AMQ JDBC store , will specify to use the configuration as below
However once you configure your active-mq with just the above configuration , you are going to have a angry DBA call you in the middle of night complaining about a long running transaction to the database consuming resources and not letting the logs purge and as a consequence may be the replication using Golden Gate not able to run. You are in for a big trouble.
So let us first now understand what is happening and then let us get ourselves out of trouble.If you read the documentation for the JDBC store lock a little carefully now , you would find a few lines in the order of
"This locker opens a JDBC transaction against a database table (activemq_lock) that lasts as long as the broker remains alive. This locks the entire table and prevents another broker from accessing the store. In most cases this will be a fairly long running JDBC transaction which occupies resources on the database over time."
Let us see this from the database side
So the transaction is in idle state and will continue to be so till the broker is alive.
The solution is obtained by digging deep in to the documentation ,you find the answer , the lease locker ,
"The Lease Database Locker was created to solve the shortcomings of the Database Locker. The Lease Database Locker does not open a long running JDBC transaction. Instead it lets the master broker acquire a lock that's valid for a fixed (usually short) duration after which it expires. To retain the lock the master broker must periodically extend the lock's lease before it expires. Simultaneously the slave broker checks periodically to see if the lease has expired. If, for whatever reason, the master broker fails to update its lease on the lock the slave will take ownership of the lock becoming the new master in the process. The leased lock can survive a DB replica failover."
So the configuration now changes to
The simple rules are that
- Always configure lockAcquireSleepInterval > lockKeepAlivePeriod.
- Either the brokerName or leaseLockerId is always unique across the master and slaves.
Tada .. Your DBA is happy again.