Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
orders-monitoring-dashboard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramakanth Dhane
orders-monitoring-dashboard
Commits
e3240eac
Commit
e3240eac
authored
Apr 27, 2020
by
Nagarjuna Reddy Pothi Reddy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed Changes to Configure Producer and Integration with Order Generator
parent
c9f374b7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
166 additions
and
65 deletions
+166
-65
pom.xml
omd-checkout-service/pom.xml
+75
-65
OrderGenerator.java
...t-service/src/main/java/com/nisum/omd/OrderGenerator.java
+6
-0
OmdProducerConfig.java
...src/main/java/com/nisum/omd/config/OmdProducerConfig.java
+39
-0
OmdProducerService.java
...c/main/java/com/nisum/omd/service/OmdProducerService.java
+41
-0
application.properties
...heckout-service/src/main/resources/application.properties
+5
-0
No files found.
omd-checkout-service/pom.xml
View file @
e3240eac
...
...
@@ -28,6 +28,16 @@
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.kafka
</groupId>
<artifactId>
spring-kafka
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-simple
</artifactId>
<version>
1.7.30
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
...
...
@@ -43,7 +53,7 @@
<groupId>
com.github.javafaker
</groupId>
<artifactId>
javafaker
</artifactId>
<version>
1.0.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
omd-checkout-service/src/main/java/com/nisum/omd/OrderGenerator.java
View file @
e3240eac
...
...
@@ -2,6 +2,7 @@ package com.nisum.omd;
import
java.time.LocalDateTime
;
import
com.nisum.omd.service.OmdProducerService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,6 +20,10 @@ public class OrderGenerator implements CommandLineRunner{
RandomDataGeneratorImpl
rdg
;
@Autowired
Order
order
;
@Autowired
OmdProducerService
omdProducerService
;
Boolean
orderGenerateFlag
=
true
;
public
Boolean
getOrderGenerateFlag
()
{
...
...
@@ -33,6 +38,7 @@ public class OrderGenerator implements CommandLineRunner{
while
(
orderGenerateFlag
){
order
=
getObjectData
(
order
);
omdProducerService
.
sendMessage
(
order
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
registerModule
(
new
JavaTimeModule
());
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
...
...
omd-checkout-service/src/main/java/com/nisum/omd/config/OmdProducerConfig.java
0 → 100644
View file @
e3240eac
package
com
.
nisum
.
omd
.
config
;
import
com.nisum.omd.domain.Order
;
import
org.apache.kafka.clients.producer.ProducerConfig
;
import
org.apache.kafka.common.serialization.StringSerializer
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.kafka.core.DefaultKafkaProducerFactory
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.kafka.core.ProducerFactory
;
import
org.springframework.kafka.support.serializer.JsonSerializer
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
public
class
OmdProducerConfig
{
@Value
(
"${bootstrap-server}"
)
private
String
bootstrapServer
;
@Bean
public
ProducerFactory
<
String
,
Order
>
producerFactory
(){
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
config
.
put
(
ProducerConfig
.
BOOTSTRAP_SERVERS_CONFIG
,
bootstrapServer
);
config
.
put
(
ProducerConfig
.
KEY_SERIALIZER_CLASS_CONFIG
,
StringSerializer
.
class
);
config
.
put
(
ProducerConfig
.
VALUE_SERIALIZER_CLASS_CONFIG
,
JsonSerializer
.
class
);
return
new
DefaultKafkaProducerFactory
<>(
config
);
}
@Bean
public
KafkaTemplate
<
String
,
Order
>
kafkaTemplate
(){
return
new
KafkaTemplate
<>(
producerFactory
());
}
}
omd-checkout-service/src/main/java/com/nisum/omd/service/OmdProducerService.java
0 → 100644
View file @
e3240eac
package
com
.
nisum
.
omd
.
service
;
import
com.nisum.omd.domain.Order
;
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.Service
;
import
org.springframework.util.concurrent.ListenableFuture
;
import
org.springframework.util.concurrent.ListenableFutureCallback
;
@Service
public
class
OmdProducerService
{
@Autowired
private
KafkaTemplate
<
String
,
Order
>
kafkaTemplate
;
@Value
(
"${topic-name}"
)
private
String
topic
;
Logger
logger
=
LoggerFactory
.
getLogger
(
OmdProducerService
.
class
);
public
void
sendMessage
(
Order
order
)
{
ListenableFuture
<
SendResult
<
String
,
Order
>>
future
=
kafkaTemplate
.
send
(
topic
,
order
);
future
.
addCallback
(
new
ListenableFutureCallback
<
SendResult
<
String
,
Order
>>()
{
@Override
public
void
onSuccess
(
SendResult
<
String
,
Order
>
result
)
{
logger
.
info
(
" Published Order Data with Order Number :"
+
order
.
getOrderNum
()
+
" In Topic :"
+
result
.
getRecordMetadata
().
topic
());
}
@Override
public
void
onFailure
(
Throwable
ex
)
{
logger
.
error
(
"Unable to Publish the Order Data, Due to: "
,
ex
.
getMessage
());
}
});
}
}
omd-checkout-service/src/main/resources/application.properties
View file @
e3240eac
...
...
@@ -67,3 +67,8 @@ app.paymentMethod.paymentStatus=AUTH
app.paymentMethod.paymentDetail.TransactionId
=
021361475199
app.paymentMethod.paymentDetail.ProcessedAmount
=
1000.00
app.paymentMethod.paymentDetail.RequestAmount
=
1000.00
#Kafka Properties
bootstrap-server
=
localhost:9092
topic-name
=
TOPIC_OMD_ORDER_DATA
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment