I dont think the problem is the code. It is same code. Anyways, I dont see the error above anymore but now the getMessage method in Consumer throws 401 UNAUTHORIZED when I call
ResponseEntity<Hat> response = restTemplate.exchange("http://localhost:" + producerPort + "/hat/{hatId}", HttpMethod.GET, requestEntity, Hat.class, personId);
Also, above, I think personId should probably be hatId but that is unrelated to error I am getting.