Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
order-processing-api
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
Balasubrahmanyam Gudavalli
order-processing-api
Commits
7c67492e
Commit
7c67492e
authored
May 31, 2023
by
Balasubrahmanyam Gudavalli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: read from multiple collections async
parent
d59f426e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
OrderController.java
.../nisum/orderprocessingapi/controller/OrderController.java
+9
-0
OrderProcessingService.java
...um/orderprocessingapi/service/OrderProcessingService.java
+30
-0
No files found.
src/main/java/com/nisum/orderprocessingapi/controller/OrderController.java
View file @
7c67492e
...
...
@@ -101,6 +101,15 @@ public class OrderController {
}
@GetMapping
(
"/get/async/{id}"
)
public
Mono
<
OrderDto
>
readAsyncOrderEvent
(
@PathVariable
String
id
)
throws
InterruptedException
{
log
.
info
(
"Order id Received for retrieval : {}"
,
id
);
return
orderProcessingService
.
readAsync
(
id
);
}
}
src/main/java/com/nisum/orderprocessingapi/service/OrderProcessingService.java
View file @
7c67492e
...
...
@@ -202,4 +202,34 @@ public class OrderProcessingService {
}
public
Mono
<
OrderDto
>
readAsync
(
String
id
)
{
return
reactiveOps
.
findById
(
id
,
Order
.
class
)
.
map
(
order
->
OrderMapper
.
INSTANCE
.
orderEntityToDto
(
order
))
.
log
(
"Awaiting to fetch all order information"
)
.
doOnNext
(
orderDto
->
{
reactiveOps
.
findById
(
id
,
ShippingAddress
.
class
)
.
toFuture
().
whenCompleteAsync
((
shippingAddress
,
throwable1
)
->
{
orderDto
.
setShippingAddress
(
OrderMapper
.
INSTANCE
.
shippingAddressEntityToDTO
(
shippingAddress
));
}).
join
();
reactiveOps
.
findById
(
id
,
BuyerInfo
.
class
)
.
toFuture
().
whenCompleteAsync
((
buyerInfo
,
throwable2
)
->
{
orderDto
.
setBuyerInfo
(
OrderMapper
.
INSTANCE
.
buyerInfoEntityToDto
(
buyerInfo
));
}).
join
();
reactiveOps
.
findById
(
id
,
BuyerTaxInfo
.
class
)
.
toFuture
().
whenCompleteAsync
((
buyerTaxInfo
,
throwable3
)
->
{
orderDto
.
getBuyerInfo
().
setBuyerTaxInfo
(
OrderMapper
.
INSTANCE
.
buyerTaxInfoEntityToDto
(
buyerTaxInfo
));
}).
join
();
}).
doOnSuccess
(
orderDto
->
log
.
info
(
"Final Order Information : {}"
,
orderDto
));
}
}
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