Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active May 7, 2017 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garystafford/ba8d37eb4b9270beb4a376d547b7df30 to your computer and use it in GitHub Desktop.
Save garystafford/ba8d37eb4b9270beb4a376d547b7df30 to your computer and use it in GitHub Desktop.
public List<CandidateVoterView> getCandidatesMessageRpc(String election) {
logger.debug("Sending RPC request message for list of candidates...");
String requestMessage = election;
String candidates = (String) rabbitTemplate.convertSendAndReceive(
directExchange.getName(), "rpc", requestMessage);
TypeReference<Map<String, List<CandidateVoterView>>> mapType =
new TypeReference<Map<String, List<CandidateVoterView>>>() {};
ObjectMapper objectMapper = new ObjectMapper();
Map<String, List<CandidateVoterView>> candidatesMap = null;
try {
candidatesMap = objectMapper.readValue(candidates, mapType);
} catch (IOException e) {
logger.info(String.valueOf(e));
}
List<CandidateVoterView> candidatesList = candidatesMap.get("candidates");
logger.debug("List of {} candidates received...", candidatesList.size());
return candidatesList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment