title: How do I get the result of an RetryTemplate.execute in Spring java?
body: <p>I'm fairly new to java and spring and I'm trying to figure out how to receive the result of an <code>RetryTemplate.execute</code> command. I would like to return a <code>false</code> if the execute command fails, and a <code>true</code> if it succeeds. I've tried assigning the values of res in the <code>execute</code> function but all i got was an error saying that <code>java: local variables referenced from a lambda expression must be final or effectively final</code></p>
  
  <p>heres my code:</p>
  
  <pre><code>private boolean forward(String message) {
          boolean res;
          retryTemplate.execute(retryCallback -&gt; {
              HttpHeaders headers = new HttpHeaders();
              headers.setContentType(MediaType.APPLICATION_JSON);
  
              ResponseEntity&lt;String&gt; responses = restTemplate.postForEntity(kafkaForwarderSetting.getUrlEndpoint(),
                      new HttpEntity&lt;&gt;(message, headers), String.class);
  
              if (responses.getStatusCodeValue() &gt; 300) {
                  throw new ForwarderException("Error occurred while forwarding message to endpoint!",
                          retryCallback.getLastThrowable());
              }
              // SET res to true
              return true;
          }, recoveryCallback -&gt; {
  
              // SET res to false
              return false;
          });
  
          return res;
      }
  </code></pre>
  
  <p>From the documentation, it seems that <code>execute</code> returns <code>&lt;T, E extends Throwable&gt;</code> on the <code>retryTemplate</code> and whenever I return the value (such as the <code>return true;</code> on line 12), I should be able to access that very value. </p>
  
  <p>However I don't know how to get it and printing out the <code>retryTemplate</code> itself gives me <code>org.springframework.retry.support.RetryTemplate@5d65976d</code></p>