Skip to content

Commit efd6565

Browse files
authored
Events which do not need destination should be allowed to continue (#25936)
* Support event which does not need destination * Addressed githar bot comments
1 parent e0cdf22 commit efd6565

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/changeEvent/AbstractEventConsumer.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import lombok.Getter;
3030
import lombok.Setter;
3131
import lombok.extern.slf4j.Slf4j;
32+
import org.openmetadata.schema.api.events.CreateEventSubscription;
3233
import org.openmetadata.schema.entity.events.AlertMetrics;
3334
import org.openmetadata.schema.entity.events.EventSubscription;
3435
import org.openmetadata.schema.entity.events.EventSubscriptionOffset;
@@ -106,19 +107,20 @@ private void init(JobExecutionContext context) {
106107
return;
107108
}
108109

109-
if (this.eventSubscription.getDestinations() == null
110-
|| this.eventSubscription.getDestinations().isEmpty()) {
111-
LOG.error(
112-
"EventSubscription {} has no destinations configured",
113-
this.eventSubscription.getName());
114-
return;
115-
}
116-
117110
EventSubscriptionOffset eventSubscriptionOffset = loadInitialOffset(context);
118111
this.offset = eventSubscriptionOffset.getCurrentOffset();
119112
this.startingOffset = eventSubscriptionOffset.getStartingOffset();
120113
this.alertMetrics = loadInitialMetrics();
121114
this.destinationMap = loadDestinationsMap(context);
115+
116+
// We do not log warning for custom alert type. eg: Reverse Metadata
117+
if (this.destinationMap.isEmpty()
118+
&& this.eventSubscription.getAlertType() != CreateEventSubscription.AlertType.CUSTOM) {
119+
LOG.warn(
120+
"EventSubscription {} has no destinations configured",
121+
this.eventSubscription.getName());
122+
}
123+
122124
this.doInit(context);
123125
} catch (Exception e) {
124126
LOG.error("Failed to initialize EventConsumer from JobDataMap", e);
@@ -204,6 +206,9 @@ private EventSubscriptionOffset loadInitialOffset(JobExecutionContext context) {
204206

205207
private Map<UUID, Destination<ChangeEvent>> loadDestinationsMap(JobExecutionContext context) {
206208
Map<UUID, Destination<ChangeEvent>> dMap = new HashMap<>();
209+
if (eventSubscription.getDestinations() == null) {
210+
return dMap;
211+
}
207212
for (SubscriptionDestination subscriptionDest : eventSubscription.getDestinations()) {
208213
dMap.put(
209214
subscriptionDest.getId(), AlertFactory.getAlert(eventSubscription, subscriptionDest));

0 commit comments

Comments
 (0)