|
24 | 24 | import org.apache.kafka.streams.state.KeyValueStore;
|
25 | 25 | import org.apache.kafka.streams.state.StoreBuilder;
|
26 | 26 | import org.apache.kafka.streams.state.Stores;
|
| 27 | +import org.springframework.web.client.RestTemplate; |
27 | 28 |
|
28 | 29 | import java.util.Collections;
|
29 | 30 | import java.util.HashMap;
|
@@ -89,10 +90,22 @@ public static void main(String[] args)
|
89 | 90 | System.out.println("orderKTable.value: " + order);
|
90 | 91 | CustomerOrder customerOrder = new CustomerOrder();
|
91 | 92 | customerOrder.setCustomerId(order.getCustomerId());
|
92 |
| - customerOrder.setFirstName(""); |
93 |
| - customerOrder.setLastName(""); |
94 |
| - customerOrder.setEmail(""); |
95 |
| - customerOrder.setPhone(""); |
| 93 | + Customer customer=getCustomerInformation(order.getCustomerId()); |
| 94 | + if(customer == null) |
| 95 | + { |
| 96 | + customerOrder.setFirstName(""); |
| 97 | + customerOrder.setLastName(""); |
| 98 | + customerOrder.setEmail(""); |
| 99 | + customerOrder.setPhone(""); |
| 100 | + } |
| 101 | + else |
| 102 | + { |
| 103 | + customerOrder.setFirstName(customer.getFirstName()); |
| 104 | + customerOrder.setLastName(customer.getLastName()); |
| 105 | + customerOrder.setEmail(customer.getEmail()); |
| 106 | + customerOrder.setPhone(customer.getPhone()); |
| 107 | + } |
| 108 | + |
96 | 109 | customerOrder.setOrderId(order.getOrderId());
|
97 | 110 | customerOrder.setOrderItemName(order.getOrderItemName());
|
98 | 111 | customerOrder.setOrderPlace(order.getOrderPlace());
|
@@ -135,6 +148,12 @@ public void run()
|
135 | 148 | System.exit(0);
|
136 | 149 | }
|
137 | 150 |
|
| 151 | + private static Customer getCustomerInformation(CharSequence customerId) |
| 152 | + { |
| 153 | + RestTemplate restTemplate=new RestTemplate(); |
| 154 | + return restTemplate.getForObject("http://localhost:8095/store/customer/"+customerId,Customer.class); |
| 155 | + } |
| 156 | + |
138 | 157 |
|
139 | 158 | private static <VT extends SpecificRecord> SpecificAvroSerde<VT> createSerde(String schemaRegistryUrl)
|
140 | 159 | {
|
|
0 commit comments