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
3828efee
Commit
3828efee
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
2bfc2ecf
main
1 merge request
!9
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
+9
-8
...main/java/com/sphere/compentency/kafka/kafkaConsumer.java
with
9 additions
and
8 deletions
+9
-8
src/main/java/com/sphere/compentency/kafka/kafkaConsumer.java
+
9
−
8
View file @
3828efee
...
...
@@ -69,19 +69,20 @@ public class kafkaConsumer {
if
(
msg
!=
null
&&
!
msg
.
isEmpty
()
&&
!
msg
.
trim
().
isEmpty
())
{
JSONObject
json
=
new
JSONObject
(
record
.
value
());
JSONObject
edata
=
json
.
getJSONObject
(
"edata"
);
Object
userIdsObject
=
edata
.
get
(
"userIds"
);
String
userId
=
""
;
if
(
userIdsObject
instanceof
List
)
{
List
<
String
>
userIds
=
(
List
<
String
>)
userIdsObject
;
userId
=
userIds
.
get
(
0
);
JSONArray
userIdsArray
=
edata
.
getJSONArray
(
"userIds"
);
String
userId
=
""
;
if
(
userIdsArray
.
length
()
>
0
)
{
// Extract the first userId from the array
userId
=
userIdsArray
.
getString
(
0
);
}
else
{
userId
=
edata
.
getString
(
"userIds"
);
// Handle the case where the array is empty
logger
.
info
(
"No userIds found in the array"
);
}
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: {}"
,
userId
s
,
courseId
);
logger
.
info
(
"Processing Kafka message - userId: {}, courseId: {}"
,
userId
,
courseId
);
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