- eventFuture.addCallback(new ListenableFutureCallback<>() {
- @Override
- public void onFailure(final Throwable throwable) {
- log.error("Unable to publish event to topic : {} due to {}", topicName, throwable.getMessage());
+ /**
+ * Generic Event publisher.
+ *
+ * @param topicName valid topic name
+ * @param eventKey message key
+ * @param event message payload
+ * @deprecated Cloud events should be used. Will address soon as part of https://jira.onap.org/browse/CPS-1717
+ */
+ @Deprecated(forRemoval = true)
+ public void publishEvent(final String topicName, final String eventKey, final T event) {
+ final CompletableFuture<SendResult<String, T>> eventFuture =
+ legacyKafkaEventTemplate.send(topicName, eventKey, event);
+ eventFuture.whenComplete((result, e) -> {
+ if (e == null) {
+ log.debug("Successfully published event to topic : {} , Event : {}",
+ result.getRecordMetadata().topic(), result.getProducerRecord().value());
+ } else {
+ log.error("Unable to publish event to topic : {} due to {}", topicName, e.getMessage());