All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.brihaspathee.zeus.producer.FileInfoProducer Maven / Gradle / Ivy

The newest version!
package com.brihaspathee.zeus.producer;

import com.brihaspathee.zeus.dto.transaction.FileDetailDto;
import com.brihaspathee.zeus.message.MessageMetadata;
import com.brihaspathee.zeus.message.ZeusMessagePayload;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

/**
 * Created in Intellij IDEA
 * User: Balaji Varadharajan
 * Date: 15, March 2022
 * Time: 2:48 PM
 * Project: Zeus
 * Package Name: com.brihaspathee.zeus.producer
 * To change this template use File | Settings | File and Code Template
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class FileInfoProducer {

    private final KafkaTemplate kafkaTemplate;

    private final ObjectMapper objectMapper;

    public void sendFileInfo(FileDetailDto fileDetailDto) throws JsonProcessingException {
        log.info("About to send the file information");
        ZeusMessagePayload filePayload = ZeusMessagePayload.builder()
                .payload(fileDetailDto)
                .messageMetadata(MessageMetadata.builder()
                        .messageSource("FILE-MGMT")
                        .messageDestination(new String[] {"FILE-STORE", "TRANS-ORIG"})
                        .build())
                .build();
        //fileDetailDto.setFileData("Test File Data");
        //String fileInfoAsString = objectMapper.writeValueAsString(fileDetailDto);
        kafkaTemplate.send("ZEUS.FILE.STORAGE.TOPIC", "Test String");
        //kafkaTemplate.send("ZEUS.TRANS.ORIG.TOPIC", "Test String");

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy