Feature event publishing (#884)
* refactored code to use EventPublisherHolder for publishing application events where possible Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * fixed comment Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
2b5b8b4a63
commit
c68c5a6f5b
@@ -63,6 +63,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.bus.BusProperties;
|
||||
import org.springframework.cloud.bus.ServiceMatcher;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -93,6 +94,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ServiceMatcher serviceMatcher;
|
||||
|
||||
@Autowired
|
||||
private BusProperties bus;
|
||||
|
||||
@@ -194,9 +198,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
result = FileStreamingUtil.writeFileResponse(file, artifact.getFilename(), artifact.getCreatedAt(),
|
||||
requestResponseContextHolder.getHttpServletResponse(),
|
||||
requestResponseContextHolder.getHttpServletRequest(),
|
||||
(length, shippedSinceLastEvent, total) -> eventPublisher
|
||||
.publishEvent(new DownloadProgressEvent(tenantAware.getCurrentTenant(), statusId,
|
||||
shippedSinceLastEvent, bus.getId())));
|
||||
(length, shippedSinceLastEvent,
|
||||
total) -> eventPublisher.publishEvent(new DownloadProgressEvent(
|
||||
tenantAware.getCurrentTenant(), statusId, shippedSinceLastEvent,
|
||||
serviceMatcher != null ? serviceMatcher.getServiceId() : bus.getId())));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user