Example usage for org.springframework.jms.core JmsTemplate browse

List of usage examples for org.springframework.jms.core JmsTemplate browse

Introduction

In this page you can find the example usage for org.springframework.jms.core JmsTemplate browse.

Prototype

@Override
    @Nullable
    public <T> T browse(BrowserCallback<T> action) throws JmsException 

Source Link

Usage

From source file:se.inera.intyg.rehabstod.service.monitoring.HealthCheckServiceImpl.java

private HealthStatus checkQueueDepth(JmsTemplate tpl) {
    long queueDepth = 0;
    boolean status = false;

    try {//from ww  w  .j ava 2s  .c o  m
        queueDepth = tpl.browse((session, browser) -> {
            Enumeration<?> enumeration = browser.getEnumeration();
            long qd = 0;
            while (enumeration.hasMoreElements()) {
                enumeration.nextElement();
                qd++;
            }
            return qd;
        });

        status = true;

    } catch (Exception e) {
        LOG.warn("Error when checking queue depth", e);
        queueDepth = BAD_HEALTHSTATUS_MEASUREMNET;
    }

    return new HealthStatus(queueDepth, status);
}