Commit 305ddbc1 authored by Ramakrushna Sahoo's avatar Ramakrushna Sahoo

update file with some changes

parent 729b415f
* text=auto
*.java text eol=lf
*.properties text eol=lf
*.csv text eol=lf
......@@ -2,6 +2,5 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/employee-consumer-app" vcs="Git" />
</component>
</project>
\ No newline at end of file
[{"id":1,"email":"sam@gmail.com","deptId":112
[{"id":7,"email":"olivia@example.com","deptId":114,"ename":"olivia"},{"id":8,"email":"noah@example.com","deptId":114,"ename":"noah"},{"id":9,"email":"ava@example.com","deptId":114,"ename":"ava"},{"id":10,"email":"ethan@example.com","deptId":114,"ename":"ethan"},{"id":11,"email":"ram@gmail.com","deptId":114,"ename":"Ram"}]
......@@ -2,8 +2,10 @@ package rks;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.kafka.annotation.EnableKafka;
@SpringBootApplication
@EnableKafka
public class EmployeeConsumerApplication {
public static void main(String[] args) {
......
......@@ -32,19 +32,17 @@ public class EmployeeConsumer implements CommandLineRunner {
// Here you can parse the message to create an Employee object
// Assuming message is a CSV string, you can split it or use a library like Jackson to convert it
log.info("Employee data read from kafka : {}", message);
// String[] parts = message.split(",");
// Employee employee = new Employee(parts[0], parts[1], parts[2]);
// log.info("Employee data read from kafka : {}", employee);
//
// // Write to CSV
// writeEmployeeToCSV(employee);
// Write to CSV
writeEmployeeToCSV(message.value());
}
private void writeEmployeeToCSV(Employee employee) {
private void writeEmployeeToCSV(String message) {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, true))) {
writer.write(employee.toString());
writer.write(message);
writer.newLine();
log.info("data written in csv file");
log.info("data written in csv file : {}", message);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -6,9 +6,7 @@ spring.r2dbc.url=r2dbc:mysql://root:root@localhost:3306/database1
spring.r2dbc.username=root
spring.r2dbc.password=root
# Optional: R2DBC pool configuration (if you want to enable connection pooling)
spring.r2dbc.pool.initial-size=5
spring.r2dbc.pool.max-size=20
# Enable R2DBC logging (optional)
logging.level.io.r2dbc.spi=DEBUG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment