package com.mns.returns.producer; import org.slf4j.Logger; import…
- User
package com.mns.returns.producer;
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.SendResult; import org.springframework.stereotype.Component; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureCallback;
@Component public class KafkaProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(KafkaProducer.class); @Value("${kafka.topic.omsapi.wismr}") String topic; @Autowired KafkaTemplate<String, String> kafkaTemplate; public String sendCommunicationMessageToKafkaTopic(String message) { String responseStatus = "Not Sent"; try { LOGGER.info("Publishing communication message to KAFKA Topic---->{} ", topic); ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, message); future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() { @Override public void onSuccess(SendResult<String, String> result) { LOGGER.debug( "Sent message=[" + message + "] with partition [" + result.getRecordMetadata().partition() + "] offset=[" + result.getRecordMetadata().offset() + "]"); } @Override public void onFailure(Throwable ex) { System.out.println("Unable to send message=[" + message + "] due to : " + ex.getMessage()); } }); LOGGER.info("Published communication message to KAFKA Topic::: " + topic); responseStatus = "Sent"; } catch (Exception ex) { LOGGER.info("Error in publishing communication message to KAFKA ::: " + ex); LOGGER.info("Error in publishing communication message to KAFKA ::: " + ex.getMessage()); LOGGER.info("Error in publishing communication message to KAFKA ::: " + ex.getLocalizedMessage()); } return responseStatus; }}
this is the issue.....com.mns.oms.batch.writer.KafkaBatchWriter is not abstract and does not override abstract method write(org.springframework.batch.item.Chunk<? extends com.mns.oms.batch.model.BeamDataDTO>) in org.springframework.batch.item.ItemWriter......explain and fix
this is the issue.....com.mns.oms.batch.writer.KafkaBatchWriter is not abstract and does not override abstract method write(org.springframework.batch.item.Chunk<? extends com.mns.oms.batch.model.BeamDataDTO>) in org.springframework.batch.item.ItemWriter......explain and fix
- Assistant
The error message is indicating that the class
KafkaBatchWriteris not implementing the abstract methodwritefrom the interfaceItemWriter. In order to fix this issue, you need to implement thewritemethod in yourKafkaBatchWriterclass.Here is an example of how you can implement the
writemethod in theKafkaBatchWriterclass:package com.mns.oms.batch.writer; import org.springframework.batch.item.ItemWriter; import java.util.List; public class KafkaBatchWriter implements ItemWriter<BeamDataDTO> { @Override public void write(List<? extends BeamDataDTO> items) throws Exception { // Write your implementation here to process the list of items } }In the
writemethod, you can write your implementation to process the list of items that are passed to the method. Make sure to replaceBeamDataDTOwith the actual type of your item class.After implementing the
writemethod in yourKafkaBatchWriterclass, the error should be resolved.