Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Jira
serverONAP Jira
columnIdsissuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-989

Medium article

Issues & Decisions

#IssueNotes Decision
1


Overview

As specified in the Jira ticket the replacement of RestTemplate became neccessary due the fact that it is not under development anymore and also because it does not support basic function required in the modern dev world such as async calls.

...

Example async call with subscribing


Code Block
languagejava
titledeclaration
linenumberstrue
collapsetrue
public Mono<String> httpOperationWithJsonData(final HttpMethod httpMethod, 
												final String resourceUrl, 
												final String jsonData,
												final HttpHeaders httpHeaders) {

return webClient
 .get()
 .uri(resourceUrl)
 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
 .retrieve()
 .onStatus(HttpStatus::is4xxClientError,
 error -> Mono.error(new RuntimeException("API not found")))
 .onStatus(HttpStatus::is5xxServerError,
 error -> Mono.error(new RuntimeException("Server is not responding")))
 .bodyToMono(String.class);
}

...