Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
competency-passbook
Commits
2bfc2ecf
Commit
2bfc2ecf
authored
1 year ago
by
Reshmi
Browse files
Options
Download
Patches
Plain Diff
Fixing type casting issue for userId while reading from kafka event
parent
6d9fcf34
main
1 merge request
!8
Fixing type casting issue for userId while reading from kafka event
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/sphere/compentency/kafka/kafkaConsumer.java
+11
-2
...main/java/com/sphere/compentency/kafka/kafkaConsumer.java
with
11 additions
and
2 deletions
+11
-2
src/main/java/com/sphere/compentency/kafka/kafkaConsumer.java
+
11
−
2
View file @
2bfc2ecf
...
...
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
import
java.io.IOException
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Properties
;
@Component
public
class
kafkaConsumer
{
...
...
@@ -68,12 +69,20 @@ public class kafkaConsumer {
if
(
msg
!=
null
&&
!
msg
.
isEmpty
()
&&
!
msg
.
trim
().
isEmpty
())
{
JSONObject
json
=
new
JSONObject
(
record
.
value
());
JSONObject
edata
=
json
.
getJSONObject
(
"edata"
);
String
userIds
=
edata
.
getString
(
"userIds"
);
Object
userIdsObject
=
edata
.
get
(
"userIds"
);
String
userId
=
""
;
if
(
userIdsObject
instanceof
List
)
{
List
<
String
>
userIds
=
(
List
<
String
>)
userIdsObject
;
userId
=
userIds
.
get
(
0
);
}
else
{
userId
=
edata
.
getString
(
"userIds"
);
}
List
<
String
>
userIds
=
(
List
<
String
>)
edata
.
get
(
"userIds"
);
// Now, you can pass userIds to your method
JSONObject
relatedObject
=
json
.
getJSONObject
(
"edata"
).
getJSONObject
(
"related"
);
String
courseId
=
relatedObject
.
getString
(
"courseId"
);
//do_1139628834519941121286,do_11394806141846323211
logger
.
info
(
"Processing Kafka message - userId: {}, courseId: {}"
,
userIds
,
courseId
);
api_services
.
get_hierarchy
(
courseId
,
userId
s
);
api_services
.
get_hierarchy
(
courseId
,
userId
);
}
else
{
logger
.
warn
(
"Received empty or null message from Kafka"
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets