Skip to content
Open
Show file tree
Hide file tree
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 @@ -5,6 +5,8 @@
import org.apache.camel.builder.DeadLetterChannelBuilder;
import org.apache.commons.lang3.StringUtils;
import org.assimbly.dil.blocks.processors.FailureProcessor;
import org.assimbly.dil.blocks.processors.LastFailureProcessor;

import java.util.TreeMap;


Expand Down Expand Up @@ -46,6 +48,8 @@ public DeadLetterChannelBuilder configure() {
.logExhaustedMessageBody(true)
.logExhaustedMessageHistory(true);

deadLetterChannelBuilder.onExceptionOccurred(new LastFailureProcessor());

if(failureProcessorEnabled) {
Processor failureProcessor = new FailureProcessor();
deadLetterChannelBuilder.onExceptionOccurred(failureProcessor);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.assimbly.dil.blocks.processors;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.commons.lang3.StringUtils;
import org.assimbly.dil.event.domain.FlowEvent;

import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;

public class LastFailureProcessor implements Processor {

public static final ConcurrentHashMap<String, Long> lastFailureTimestamp = new ConcurrentHashMap<>();

@Override
public void process(Exchange exchange) throws Exception {
Date date = new Date();
FlowEvent flowEvent = new FlowEvent(exchange.getFromRouteId(), date, exchange.getException().getMessage());

String flowId;
if(!flowEvent.getFlowId().contains("-")){
flowId = flowEvent.getFlowId();
}else{
flowId = StringUtils.substringBefore(flowEvent.getFlowId(),"-");
}

lastFailureTimestamp.put(flowId, System.currentTimeMillis());
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.assimbly.integration.impl.manager;

import javax.management.*;
import java.util.*;

import com.codahale.metrics.MetricRegistry;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
Expand All @@ -21,18 +18,22 @@
import org.apache.camel.health.HealthCheckRepository;
import org.apache.camel.support.CamelContextHelper;
import org.apache.commons.lang3.StringUtils;
import org.assimbly.dil.blocks.processors.LastFailureProcessor;
import org.assimbly.dil.event.collect.MicrometerTimestampRoutePolicyFactory;
import org.assimbly.docconverter.DocConverter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.JMX;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import java.lang.management.ThreadInfo;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ConcurrentMap;

public class StatsManager {
Expand Down Expand Up @@ -170,7 +171,9 @@ private FlowStatistics calculateFlowStatistics(String flowId, boolean fullStats)
if (fullStats) {
stats.uptimeMillis = managedRouteGroup.getUptimeMillis();
stats.uptime = managedRouteGroup.getUptime();
stats.lastFailed = managedRouteGroup.getLastExchangeFailureTimestamp() != null ? managedRouteGroup.getLastExchangeFailureTimestamp().getTime() : 0L;
stats.lastFailed = failed > 0 && LastFailureProcessor.lastFailureTimestamp.containsKey(flowId)
? LastFailureProcessor.lastFailureTimestamp.get(flowId)
: 0L;
stats.lastCompleted = managedRouteGroup.getLastExchangeCompletedTimestamp() != null ? managedRouteGroup.getLastExchangeCompletedTimestamp().getTime() : 0L;
}

Expand Down