-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
003ce89
commit 5a29c4a
Showing
11 changed files
with
178 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/config/utils/AnnotationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package co.com.bancolombia.commons.jms.mq.config.utils; | ||
|
||
import co.com.bancolombia.commons.jms.mq.config.MQProperties; | ||
import org.springframework.util.StringUtils; | ||
|
||
public class AnnotationUtils { | ||
|
||
public static int resolveRetries(String maxRetriesStr) { | ||
try { | ||
int maxRetries = Integer.parseInt(maxRetriesStr); | ||
if (maxRetries < 0) { | ||
maxRetries = -1; | ||
} | ||
return maxRetries; | ||
} catch (Exception ignored) { | ||
return MQProperties.DEFAULT_MAX_RETRIES; | ||
} | ||
} | ||
|
||
public static int resolveConcurrency(int concurrencyAnnotation, int concurrencyProperties) { | ||
if (concurrencyAnnotation > 0) { | ||
return concurrencyAnnotation; | ||
} | ||
if (concurrencyProperties > 0) { | ||
return concurrencyProperties; | ||
} | ||
return MQProperties.DEFAULT_CONCURRENCY; | ||
} | ||
|
||
public static String resolveQueue(String primaryAnnotation, String secondaryValue, String queueProperties) { | ||
if (StringUtils.hasText(primaryAnnotation)) { | ||
return primaryAnnotation; | ||
} | ||
if (!StringUtils.hasText(secondaryValue) && StringUtils.hasText(queueProperties)) { | ||
return queueProperties; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...-mq/src/test/java/co/com/bancolombia/commons/jms/mq/config/utils/AnnotationUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package co.com.bancolombia.commons.jms.mq.config.utils; | ||
|
||
import co.com.bancolombia.commons.jms.mq.config.MQProperties; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
public class AnnotationUtilsTest { | ||
|
||
@Test | ||
void shouldResolveRetries() { | ||
assertEquals(1, AnnotationUtils.resolveRetries("1")); | ||
assertEquals(0, AnnotationUtils.resolveRetries("0")); | ||
assertEquals(-1, AnnotationUtils.resolveRetries("-10")); | ||
assertEquals(20, AnnotationUtils.resolveRetries("20")); | ||
assertEquals(MQProperties.DEFAULT_MAX_RETRIES, AnnotationUtils.resolveRetries("NO")); | ||
assertEquals(MQProperties.DEFAULT_MAX_RETRIES, AnnotationUtils.resolveRetries("")); | ||
} | ||
|
||
@Test | ||
void shouldResolveConcurrency() { | ||
assertEquals(1, AnnotationUtils.resolveConcurrency(1, -1)); | ||
assertEquals(2, AnnotationUtils.resolveConcurrency(0, 2)); | ||
assertEquals(MQProperties.DEFAULT_CONCURRENCY, AnnotationUtils.resolveConcurrency(0, 0)); | ||
} | ||
|
||
@Test | ||
void shouldResolveQueue() { | ||
assertEquals("Q1", AnnotationUtils.resolveQueue("Q1", "Q2", "Q3")); | ||
assertNull(AnnotationUtils.resolveQueue("", "Q2", "Q3")); | ||
assertNull(AnnotationUtils.resolveQueue("", "", "")); | ||
assertEquals("Q3", AnnotationUtils.resolveQueue("", "", "Q3")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=0.0.4 | ||
version=0.0.5 | ||
springBootVersion=2.4.8 | ||
gradleVersionsVersion=0.28.0 | ||
mqJMSVersion=2.5.0 | ||
|