Commit 5e5d25aa authored by Ramakanth Dhane's avatar Ramakanth Dhane

OMD-04 - Generate random orders-Bug Fixes

parent fb36840a
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.nisum.omd</groupId>
<artifactId>omd-checkout-service</artifactId>
......@@ -33,10 +34,18 @@
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -6,10 +6,8 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -20,11 +18,12 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.nisum.omd.domain.Order;
import com.nisum.omd.service.OmdProducerService;
import com.nisum.omd.service.RandomDataGenerator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Component
@RestController
public class OrderGenerator {
private static final Logger logger = LogManager.getLogger(OrderGenerator.class);
@Autowired
private RandomDataGenerator randomDataGenerator;
@Autowired
......@@ -48,11 +47,12 @@ public class OrderGenerator {
while(true) {
if (orderGenerateFlag) {
order = getObjectData(order);
omdProducerService.sendMessage(order);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String jsonOrderStr = objectMapper.writeValueAsString(order);
System.out.println(jsonOrderStr);
logger.info(jsonOrderStr);
Thread.sleep((long)(getRandomInterval(intervalList) * 1000));
}
}
......
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