This is an automated email from the ASF dual-hosted git repository.

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 5cf817a77ad CAMEL-27013: camel-sql-starter - 
JdbcOrphanLockAwareIdempotentRepositoryTest checks the keep-alive from another 
instance
5cf817a77ad is described below

commit 5cf817a77adc809604ded1b2efda756e35d3a757
Author: croway <[email protected]>
AuthorDate: Tue Nov 17 11:49:42 2026 +0100

    CAMEL-27013: camel-sql-starter - 
JdbcOrphanLockAwareIdempotentRepositoryTest checks the keep-alive from another 
instance
    
    Since CAMEL-27013 a JdbcOrphanLockAwareIdempotentRepository never treats a 
key
    it holds as an orphan, whatever the age of its lease. testLockKeepAliveWorks
    waited for the instance to see its own aged key as absent, so it timed out.
    
    Check the lease from a second repository instance, as the test in camel-sql
    does: it sees the aged key as an orphan, and as held again after the
    keep-alive of the first instance.
---
 .../JdbcOrphanLockAwareIdempotentRepositoryTest.java    | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/components-starter/camel-sql-starter/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcOrphanLockAwareIdempotentRepositoryTest.java
 
b/components-starter/camel-sql-starter/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcOrphanLockAwareIdempotentRepositoryTest.java
index ca23088ce00..a374d98fcc6 100644
--- 
a/components-starter/camel-sql-starter/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcOrphanLockAwareIdempotentRepositoryTest.java
+++ 
b/components-starter/camel-sql-starter/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcOrphanLockAwareIdempotentRepositoryTest.java
@@ -33,9 +33,7 @@ import 
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 import java.sql.Timestamp;
-import java.util.concurrent.TimeUnit;
 
-import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -74,7 +72,7 @@ public class JdbcOrphanLockAwareIdempotentRepositoryTest 
extends BaseSql {
     }
 
     @Test
-    public void testLockKeepAliveWorks() {
+    public void testLockKeepAliveWorks() throws Exception {
         assertFalse(jdbcMessageIdRepository.contains("FILE_4"));
         jdbcMessageIdRepository.insert("FILE_4");
         assertTrue(jdbcMessageIdRepository.contains("FILE_4"));
@@ -83,9 +81,18 @@ public class JdbcOrphanLockAwareIdempotentRepositoryTest 
extends BaseSql {
         template.update("UPDATE CAMEL_MESSAGEPROCESSED SET createdAT = ? WHERE 
processorName = ? AND messageId = ?",
                 timestamp, APP_NAME, "FILE_4");
 
-        await().atMost(5, TimeUnit.SECONDS).until(() -> 
!jdbcMessageIdRepository.contains("FILE_4"));
-        jdbcMessageIdRepository.keepAlive();
+        // the lease is older than the lock max age: another instance takes it 
for an orphan, while this instance, which
+        // holds the key, does not
+        JdbcOrphanLockAwareIdempotentRepository otherInstance = new 
JdbcOrphanLockAwareIdempotentRepository(dataSource,
+                APP_NAME, new DefaultCamelContext());
+        otherInstance.setLockMaxAgeMillis(3000_00L);
+        otherInstance.setLockKeepAliveIntervalMillis(3000L);
+        otherInstance.doInit();
+        assertFalse(otherInstance.contains("FILE_4"));
         assertTrue(jdbcMessageIdRepository.contains("FILE_4"));
+
+        jdbcMessageIdRepository.keepAlive();
+        assertTrue(otherInstance.contains("FILE_4"));
     }
 
     @Test

Reply via email to