Skip to content

Commit

Permalink
Merge pull request #2144 from DedunuKarunarathne/master
Browse files Browse the repository at this point in the history
Fix analytics data of template endpoints publishing twice
  • Loading branch information
DedunuKarunarathne authored Feb 16, 2024
2 parents b85102a + 0d3f0c9 commit 29370ba
Showing 1 changed file with 7 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,14 @@ public class TemplateEndpoint extends AbstractEndpoint {

@Override
public void send(MessageContext synCtx) {
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
Integer currentIndex = null;
if (getDefinition() != null) {
currentIndex = OpenEventCollector.reportChildEntryEvent(synCtx, getReportingName(),
ComponentType.ENDPOINT, getDefinition().getAspectConfiguration(), true);
}
try {
sendMessage(synCtx);
} finally {
if (currentIndex != null) {
CloseEventCollector.closeEntryEvent(synCtx, getReportingName(), ComponentType.MEDIATOR,
currentIndex, false);
}
}
reLoadAndInitEndpoint(synCtx.getEnvironment());

if (realEndpoint != null) {
realEndpoint.send(synCtx);
} else {
sendMessage(synCtx);
informFailure(synCtx, SynapseConstants.ENDPOINT_IN_DIRECT_NOT_READY,
"Couldn't find the endpoint with the name " + getName() +
" & template : " + template);
}
}

Expand All @@ -80,18 +72,6 @@ protected void createJsonRepresentation() {
endpointJson.put("template", getTemplate());
}

public void sendMessage(MessageContext synCtx) {
reLoadAndInitEndpoint(synCtx.getEnvironment());

if (realEndpoint != null) {
realEndpoint.send(synCtx);
} else {
informFailure(synCtx, SynapseConstants.ENDPOINT_IN_DIRECT_NOT_READY,
"Couldn't find the endpoint with the name " + getName() +
" & template : " + template);
}
}

public Map<String, String> getParameters() {
return parameters;
}
Expand Down

0 comments on commit 29370ba

Please sign in to comment.