Merge pull request #259 from pymma/kafka

Add TransactionID in the swimming pool example
This commit is contained in:
Nicolas Héron 2021-05-11 13:58:55 +02:00 committed by GitHub
commit 67265e2548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -83,6 +83,12 @@ public class QuoteController {
return clientHttpRequest -> { return clientHttpRequest -> {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(clientHttpRequest.getBody(), updatedInstance); mapper.writeValue(clientHttpRequest.getBody(), updatedInstance);
if (updatedInstance.getSessionLogging()!= null &&
updatedInstance.getSessionLogging().length()>0){
clientHttpRequest.getHeaders().add(
"transactionId", updatedInstance.getSessionLogging());
}
clientHttpRequest.getHeaders().add( clientHttpRequest.getHeaders().add(
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
clientHttpRequest.getHeaders().add( clientHttpRequest.getHeaders().add(

View file

@ -177,6 +177,11 @@
<td>Subscription price :</td> <td>Subscription price :</td>
<td>{{quoteResult.subscription.price}}</td> <td>{{quoteResult.subscription.price}}</td>
</tr> </tr>
<tr>
<td>TransactionID :</td>
<td>{{quoteResult.sessionLogging}}</td>
</tr>
</table> </table>
</div> </div>

View file

@ -107,6 +107,7 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
$scope.calculatePrice = function () { $scope.calculatePrice = function () {
var myQuote = $scope.quote; var myQuote = $scope.quote;
myQuote.sessionLogging=uuidv4();
$http.put(urlBase + "/quote/calculate/" + $scope.containerid + "/", myQuote).success(function (data) { $http.put(urlBase + "/quote/calculate/" + $scope.containerid + "/", myQuote).success(function (data) {
$scope.quoteResult = data; $scope.quoteResult = data;
$scope.allSessionExecutionDetails = JSON.parse(data.sessionLogging); $scope.allSessionExecutionDetails = JSON.parse(data.sessionLogging);
@ -114,7 +115,12 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
// $scope.sessionLogging=data.sessionLogging; // $scope.sessionLogging=data.sessionLogging;
}) })
} }
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
}); });