Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/assimbly/runtime into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
skin27 committed Nov 29, 2024
2 parents 2d2d66d + 3737757 commit 25e0830
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
byte[] resourceData = newExchange.getContext().getTypeConverter().convertTo(byte[].class, resource.getBody());

String fileName = resource.getHeader(Exchange.FILE_NAME_CONSUMED, String.class);
if(fileName == null) {
fileName = resource.getHeader(Exchange.FILE_NAME, String.class);
}

ByteArrayOutputStream baos = new ByteArrayOutputStream();

Expand Down
1 change: 1 addition & 0 deletions dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ private void removeRouteConfiguration(String flowId) {
ModelCamelContext modelContext = (ModelCamelContext) context;

List<RouteConfigurationDefinition> routeConfigurationsToRemove = modelContext.getRouteConfigurationDefinitions().stream()
.filter(Objects::nonNull) // Exclude null entries
.filter(routeConfig -> routeConfig.getId().startsWith(flowId))
.toList(); // Collect into a new list to avoid modifying the original list during iteration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ public String startFlow(String id, long timeout) {
initFlowActionReport(id, "Start");

if(hasFlow(id)) {
stopFlow(id, timeout);
stopFlow(id, timeout, false);
}

boolean addFlow = false;
Expand Down Expand Up @@ -1352,13 +1352,12 @@ public String startFlow(String id, long timeout) {
if (!result.equals("loaded") && !result.equals("started")){
if(result.equalsIgnoreCase("error")){
String startReport = loadReport;
stopFlow(id, timeout);
stopFlow(id, timeout, false);
loadReport = startReport;
}else{
finishFlowActionReport(id, "error",result,"error");
}
}else if(result.equals("loaded")) {

List<Route> steps = getRoutesByFlowId(id);

log.info("Starting " + steps.size() + " steps");
Expand All @@ -1379,7 +1378,7 @@ public String startFlow(String id, long timeout) {

}catch (Exception e) {
if(context.isStarted()) {
stopFlow(id, stopTimeout);
stopFlow(id, stopTimeout, false);
finishFlowActionReport(id, "error","Start flow failed | error=" + e.getMessage(),"error");
log.error("Start flow failed. | flowid=" + id,e);
}else{
Expand Down Expand Up @@ -1432,14 +1431,7 @@ private ServiceStatus startStep(Route route){
public String restartFlow(String id, long timeout) {

try {

if(hasFlow(id)) {
stopFlow(id, timeout);
startFlow(id, timeout);
}else {
startFlow(id, timeout);
}

startFlow(id, timeout);
}catch (Exception e) {
log.error("Restart flow failed. | flowid=" + id,e);
finishFlowActionReport(id, "error", e.getMessage(),"error");
Expand All @@ -1450,8 +1442,14 @@ public String restartFlow(String id, long timeout) {
}

public String stopFlow(String id, long timeout) {
return stopFlow(id, timeout, true);
}

public String stopFlow(String id, long timeout, boolean enableReport) {

initFlowActionReport(id, "stop");
if(enableReport) {
initFlowActionReport(id, "stop");
}

try {

Expand All @@ -1473,10 +1471,14 @@ public String stopFlow(String id, long timeout) {

}

finishFlowActionReport(id, "stop","Stopped flow successfully","info");
if(enableReport) {
finishFlowActionReport(id, "stop", "Stopped flow successfully", "info");
}

}catch (Exception e) {
finishFlowActionReport(id, "error","Stop flow failed | error=" + e.getMessage(),"error");
if(enableReport) {
finishFlowActionReport(id, "error", "Stop flow failed | error=" + e.getMessage(), "error");
}
log.error("Stop flow failed. | flowid=" + id,e);
}

Expand Down

0 comments on commit 25e0830

Please sign in to comment.