Java Code Examples for org.springframework.util.concurrent.FailureCallback

Following code examples demonstrate how to use org.springframework.util.concurrent.FailureCallbackfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.util.concurrent.FailureCallbackand various code implementation of this class.

	public FailureCallback failureCallback(T o) {
		return new FailureCallback() {
			@Override
			public void onFailure(Throwable ex) {
				logger.error("Error in producing Mseeage to Kafka!", ex);
			}

		};
	} 


			public void onSuccess(ResponseEntity<Student> result) {
				log.info(result.getBody().getName());
				log.info("A");
			} 

  public void sendGreeting(Greeting greeting, Span span) {
    kafkaSender.send(TOPIC, TYPE, UUID.randomUUID().toString(), 1, greeting, span,
        successCallback,
        failureCallback);
  } 

    public Future<?> process() {
        AsyncRestTemplate template = new AsyncRestTemplate();
        SuccessCallback onSuccess = r -> System.out.println("Success");
        FailureCallback onFailure = e -> System.out.println("Failure");
        ListenableFuture<?> response = template.getForEntity(
                ExamplesCollection.class
        );

        response.addCallback(onSuccess, onFailure);

        return response;
    } 

			public void onSuccess(Object arg0) {
				if (callBack != null)
					callBack.succeed(arg0);
			} 

    public void sendToKafka(Transaction transactions, SuccessCallback successCallback, FailureCallback failureCallback) {
        transactions.getTransactions().stream()
                .map(tran -> kafkaTemplate.sendDefault(null, tran.toString()))
                .forEach(future -> future.addCallback(successCallback, failureCallback));
    
        kafkaTemplate.flush();
    } 

Advertisement
Advertisement