Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.IllegalStateException;

public class JmsInOnlyDisableTimeToLiveTest extends AbstractJMSTest {

private static final Logger LOG = LoggerFactory.getLogger(JmsInOnlyDisableTimeToLiveTest.class);

@Order(2)
@RegisterExtension
public static CamelContextExtension camelContextExtension = new DefaultCamelContextExtension();
Expand Down Expand Up @@ -144,17 +149,25 @@ public void someBusinessLogic() {
// loop to empty queue
while (true) {
// receive the message from the queue, wait at most 2 sec
String msg = consumer.receiveBody("activemq:JmsInOnlyDisableTimeToLiveTest.in", 2000, String.class);
if (msg == null) {
// no more messages in queue
break;
try {
String msg = consumer.receiveBody("activemq:JmsInOnlyDisableTimeToLiveTest.in", 2000, String.class);
if (msg == null) {
// no more messages in queue
break;
}
// do something with body
msg = "Hello " + msg;

// send it to the next queue
producer.sendBodyAndHeader("activemq:JmsInOnlyDisableTimeToLiveTest.out", msg, "number", count++);
} catch (IllegalStateException e) {
if (e.getCause() instanceof jakarta.jms.IllegalStateException) {
// session is closed
LOG.warn("JMS Session is closed");
break;
}
}

// do something with body
msg = "Hello " + msg;

// send it to the next queue
producer.sendBodyAndHeader("activemq:JmsInOnlyDisableTimeToLiveTest.out", msg, "number", count++);
}
}
}
Expand Down