public JMSMailQueue(ConnectionFactory connectionFactory, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, String queueName, MetricFactory metricFactory, GaugeRegistry gaugeRegistry) { try { connection = connectionFactory.createConnection(); connection.start(); } catch (JMSException e) { throw new RuntimeException(e); } this.mailQueueItemDecoratorFactory = mailQueueItemDecoratorFactory; this.queueName = queueName; this.metricFactory = metricFactory; this.enqueuedMailsMetric = metricFactory.generate(ENQUEUED_METRIC_NAME_PREFIX + queueName); this.dequeuedMailsMetric = metricFactory.generate(DEQUEUED_METRIC_NAME_PREFIX + queueName); this.gaugeRegistry = gaugeRegistry; this.gaugeRegistry.register(QUEUE_SIZE_METRIC_NAME_PREFIX + queueName, queueSizeGauge()); this.joiner = Joiner.on(JAMES_MAIL_SEPARATOR).skipNulls(); this.splitter = Splitter.on(JAMES_MAIL_SEPARATOR) .omitEmptyStrings() // ignore null values. See JAMES-1294 .trimResults(); try { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); queue = session.createQueue(queueName); producer = session.createProducer(queue); } catch (JMSException e) { throw new RuntimeException(e); } }
public void recordStats(GaugeRegistry gaugeRegistry) { gaugeRegistry .register( "textExtractor.cache.hit.rate", () -> cache.stats().hitRate()) .register( "textExtractor.cache.hit.count", () -> cache.stats().hitCount()); gaugeRegistry.register( "textExtractor.cache.load.count", () -> cache.stats().loadCount()) .register( "textExtractor.cache.eviction.count", () -> cache.stats().evictionCount()) .register( "textExtractor.cache.load.exception.rate", () -> cache.stats().loadExceptionRate()) .register( "textExtractor.cache.load.miss.rate", () -> cache.stats().missRate()) .register( "textExtractor.cache.load.miss.count", () -> cache.stats().missCount()) .register( "textExtractor.cache.size", cache::size); }