-
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
cc632c4
commit 47aa8be
Showing
12 changed files
with
160 additions
and
31 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
30 changes: 30 additions & 0 deletions
30
...ancolombia/commons/jms/internal/listener/selector/strategy/ContextPerMessageStrategy.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,30 @@ | ||
package co.com.bancolombia.commons.jms.internal.listener.selector.strategy; | ||
|
||
import co.com.bancolombia.commons.jms.api.exceptions.ReceiveTimeoutException; | ||
import jakarta.jms.ConnectionFactory; | ||
import jakarta.jms.Destination; | ||
import jakarta.jms.JMSConsumer; | ||
import jakarta.jms.JMSContext; | ||
import jakarta.jms.Message; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Log4j2 | ||
@AllArgsConstructor | ||
public class ContextPerMessageStrategy implements SelectorStrategy { | ||
private final ConnectionFactory factory; | ||
|
||
@Override | ||
public Message getMessageBySelector(String selector, long timeout, Destination destination) { | ||
try (JMSContext context = factory.createContext()) { | ||
try (JMSConsumer consumer = context.createConsumer(destination, selector)) { | ||
log.info("Waiting message with selector {}", selector); | ||
Message message = consumer.receive(timeout); | ||
if (message == null) { | ||
throw new ReceiveTimeoutException("Message not received in " + timeout); | ||
} | ||
return message; | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...om/bancolombia/commons/jms/internal/listener/selector/strategy/ContextSharedStrategy.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,27 @@ | ||
package co.com.bancolombia.commons.jms.internal.listener.selector.strategy; | ||
|
||
import co.com.bancolombia.commons.jms.api.exceptions.ReceiveTimeoutException; | ||
import jakarta.jms.Destination; | ||
import jakarta.jms.JMSConsumer; | ||
import jakarta.jms.JMSContext; | ||
import jakarta.jms.Message; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Log4j2 | ||
@AllArgsConstructor | ||
public class ContextSharedStrategy implements SelectorStrategy { | ||
private final JMSContext context; | ||
|
||
@Override | ||
public Message getMessageBySelector(String selector, long timeout, Destination destination) { | ||
try (JMSConsumer consumer = context.createConsumer(destination, selector)) { | ||
log.info("Waiting message with selector {}", selector); | ||
Message message = consumer.receive(timeout); | ||
if (message == null) { | ||
throw new ReceiveTimeoutException("Message not received in " + timeout); | ||
} | ||
return message; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...com/bancolombia/commons/jms/internal/listener/selector/strategy/SelectorModeProvider.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,12 @@ | ||
package co.com.bancolombia.commons.jms.internal.listener.selector.strategy; | ||
|
||
import jakarta.jms.ConnectionFactory; | ||
import jakarta.jms.JMSContext; | ||
|
||
public interface SelectorModeProvider { | ||
SelectorStrategy get(ConnectionFactory factory, JMSContext context); | ||
|
||
static SelectorModeProvider defaultSelector(){ | ||
return (factory, context) -> new ContextSharedStrategy(context); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../co/com/bancolombia/commons/jms/internal/listener/selector/strategy/SelectorStrategy.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,8 @@ | ||
package co.com.bancolombia.commons.jms.internal.listener.selector.strategy; | ||
|
||
import jakarta.jms.Destination; | ||
import jakarta.jms.Message; | ||
|
||
public interface SelectorStrategy { | ||
Message getMessageBySelector(String selector, long timeout, Destination destination); | ||
} |
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