当前位置: 首页>>代码示例>>Java>>正文


Java SendResult类代码示例

本文整理汇总了Java中org.springframework.kafka.support.SendResult的典型用法代码示例。如果您正苦于以下问题:Java SendResult类的具体用法?Java SendResult怎么用?Java SendResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SendResult类属于org.springframework.kafka.support包,在下文中一共展示了SendResult类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public void send(String topic, LifecycleEvent message) {
    // the KafkaTemplate provides asynchronous send methods returning a Future
    ListenableFuture<SendResult<String, Object>> future = kafkaTemplate.send(topic, message);

    // register a callback with the listener to receive the result of the send asynchronously
    future.addCallback(new ListenableFutureCallback<SendResult<String, Object>>() {

        @Override
        public void onSuccess(SendResult<String, Object> result) {
            LOGGER.info("sent message='{}' with offset={}", message,
                    result.getRecordMetadata().offset());
        }

        @Override
        public void onFailure(Throwable ex) {
            LOGGER.error("unable to send message='{}'", message, ex);
        }
    });
}
 
开发者ID:corydissinger,项目名称:mtgo-best-bot,代码行数:20,代码来源:LifecycleEventSender.java

示例2: createCell

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET, path = "/createCell")
public void createCell(@NotNull @RequestParam String name, @NotNull @RequestParam CellType cellType) throws ExecutionException, InterruptedException {
    JSONObject cell = new JSONObject();
    cell.put("name", name);
    cell.put("type", cellType);

    ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, cell.toString());
    future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
        @Override
        public void onSuccess(SendResult<String, String> result) {
            System.out.println("success");
        }

        @Override
        public void onFailure(Throwable ex) {
            System.out.println("failed");
        }
    });
}
 
开发者ID:Chabane,项目名称:mitosis-microservice-spring-reactor,代码行数:20,代码来源:SpringBootKafkaController.java

示例3: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public void send(String topic, String data) {
    ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, data);
    future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
        @Override
        public void onSuccess(SendResult<String, String> result) {
            logger.info("Success on sending message \"" + data + "\" to topic " + topic);
        }

        @Override
        public void onFailure(Throwable ex) {
            logger.error("Error on sending message \"" + data + "\", stacktrace " + ex.getMessage());
        }
    });
}
 
开发者ID:Arquisoft,项目名称:participationSystem3b,代码行数:15,代码来源:KafkaProducer.java

示例4: sendMessage

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public void sendMessage(String topic, String message) {
	// the KafkaTemplate provides asynchronous send methods returning a
	// Future
	ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, message);

	// you can register a callback with the listener to receive the result
	// of the send asynchronously
	future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {

		@Override
		public void onSuccess(SendResult<String, String> result) {
			logger.info("sent message='{}' with offset={}", message, result.getRecordMetadata().offset());
		}

		@Override
		public void onFailure(Throwable ex) {
			logger.error("unable to send message='{}'", message, ex);
		}
	});

	// alternatively, to block the sending thread, to await the result,
	// invoke the future’s get() method
}
 
开发者ID:oscm,项目名称:web,代码行数:24,代码来源:Producer.java

示例5: sendMessage

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public void sendMessage(Student student) {

		ListenableFuture<SendResult<String, Student>> future = kafkaTemplate
				.send(env.getProperty("kafka.topics"), student);

		future.addCallback(new ListenableFutureCallback<SendResult<String, Student>>() {

			@Override
			public void onFailure(Throwable ex) {
				LOGGER.error("Inside Exception");

			}

			@Override
			public void onSuccess(SendResult<String, Student> result) {
				LOGGER.info("Inside Success");

			}
		});

	}
 
开发者ID:sarojrout,项目名称:spring-tutorial,代码行数:22,代码来源:KafkaEventProducer.java

示例6: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
/**
 * Metodo funndamental para la informacion en Kafka.
 * @param topic Topico de Kafka.
 * @param data Datos a enviar.
 */
public void send(String topic, String data) {
    ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, data); //Valido por si solo para el manejo de la informacion.
    future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
        @Override
        public void onSuccess(SendResult<String, String> result) {
            logger.info("Success on sending message \"" + data + "\" to topic " + topic);
        }

        @Override
        public void onFailure(Throwable ex) {
            logger.error("Error on sending message \"" + data + "\", stacktrace " + ex.getMessage());
        }
    });
}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:20,代码来源:KafkaProducer.java

示例7: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public void send(String topic, String data) {
    ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, data);
    future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
        @Override
        public void onSuccess(SendResult<String, String> result) {
            logger.info(result);
            logger.info("Success on sending message \"" + data + "\" to topic " + topic);
        }

        @Override
        public void onFailure(Throwable ex) {
            logger.error("Error on sending message \"" + data + "\", stacktrace " + ex.getMessage());
        }
    });
}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:16,代码来源:KafkaProducer.java

示例8: onSuccess

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
/**
 * Called when the {@link ListenableFuture} completes with success.
 * <p>Note that Exceptions raised by this method are ignored.
 *
 * @param result the result
 */
@Override
public void onSuccess(SendResult<String, String> result) {
    log.info("sent message='{}' with offset={}", result.getProducerRecord(),
            result.getRecordMetadata().offset());
    onCompleted(result);
}
 
开发者ID:iotoasis,项目名称:SO,代码行数:13,代码来源:AProducerHandler.java

示例9: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
public ListenableFuture<SendResult<String, Event>> send(Event event, String topic) {
	LOGGER.info("Event payload='{}'", event);
	return kafkaTemplate.send(topic, event);
}
 
开发者ID:italia,项目名称:daf-replicate-ingestion,代码行数:5,代码来源:Sender.java

示例10: send

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
/**
 * send message to kafka.<BR/>
 *
 * @param topic   topic
 * @param key     key
 * @param message value
 */
public void send(String topic, K key, V message, ListenableFutureCallback<SendResult<K, V>> callback) {
    ListenableFuture<SendResult<K, V>> future = kafkaTemplate.send(topic, key, message);
    if (callback != null)
        future.addCallback(callback);
}
 
开发者ID:iotoasis,项目名称:SO,代码行数:13,代码来源:AProducerHandler.java

示例11: onCompleted

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
/**
 * Called after super.onSuccess().<BR/>
 *
 * @param result the result
 */
abstract public void onCompleted(SendResult<String, String> result);
 
开发者ID:iotoasis,项目名称:SO,代码行数:7,代码来源:AProducerHandler.java

示例12: onCompleted

import org.springframework.kafka.support.SendResult; //导入依赖的package包/类
/**
 * Called after super.onSuccess().<BR/>
 *
 * @param result the result
 */
@Override
public void onCompleted(SendResult<String, String> result) {

}
 
开发者ID:iotoasis,项目名称:SO,代码行数:10,代码来源:SpringKafkaContextModelProducerHandler.java


注:本文中的org.springframework.kafka.support.SendResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。