热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.kafka.common.header.Headers.iterator()方法的使用及代码示例

本文整理了Java中org.apache.kafka.common.header.Headers.iterator()方法的一些代码示例,展示了Header

本文整理了Java中org.apache.kafka.common.header.Headers.iterator()方法的一些代码示例,展示了Headers.iterator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Headers.iterator()方法的具体详情如下:
包路径:org.apache.kafka.common.header.Headers
类名称:Headers
方法名:iterator

Headers.iterator介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

void clearHeaders(Headers headers) {
// Headers::remove creates and consumes an iterator each time. This does one loop instead.
for (Iterator i = headers.iterator(); i.hasNext(); ) {
Header next = i.next();
if (propagationKeys.contains(next.key())) i.remove();
}
}

代码示例来源:origin: apache/kafka

private int getCount(Headers headers) {
int count = 0;
Iterator headerIterator = headers.iterator();
while (headerIterator.hasNext()) {
headerIterator.next();
count++;
}
return count;
}

代码示例来源:origin: apache/kafka

@Test
public void testRemove() {
Headers headers = new RecordHeaders();
headers.add(new RecordHeader("key", "value".getBytes()));
assertTrue(headers.iterator().hasNext());
headers.remove("key");
assertFalse(headers.iterator().hasNext());
}

代码示例来源:origin: QNJR-GROUP/EasyTransaction

Headers headers = consumeRecord.headers();
HashMap headerMap = new HashMap<>(8);
Iterator iterator = headers.iterator();
while (iterator.hasNext()) {
Header next = iterator.next();

代码示例来源:origin: QNJR-GROUP/EasyTransaction

Iterator iterator = headers.iterator();
Integer retryCount = -1;
boolean hasOrignalHeader = false;

代码示例来源:origin: apache/kafka

@Test
public void testAdd() {
Headers headers = new RecordHeaders();
headers.add(new RecordHeader("key", "value".getBytes()));
Header header = headers.iterator().next();
assertHeader("key", "value", header);
headers.add(new RecordHeader("key2", "value2".getBytes()));
assertHeader("key2", "value2", headers.lastHeader("key2"));
assertEquals(2, getCount(headers));
}

代码示例来源:origin: apache/kafka

headers.add(new RecordHeader("key2", "value2".getBytes()));
assertTrue(headers.iterator().hasNext());
assertFalse(headers.iterator().hasNext());

代码示例来源:origin: spring-projects/spring-kafka

@SuppressWarnings("unchecked")
@Nullable
private Map decodeJsonTypes(Headers source) {
Map types = null;
Iterator iterator = source.iterator();
ObjectMapper headerObjectMapper = getObjectMapper();
while (iterator.hasNext()) {
Header next = iterator.next();
if (next.key().equals(JSON_TYPES)) {
try {
types = headerObjectMapper.readValue(next.value(), Map.class);
}
catch (IOException e) {
logger.error("Could not decode json types: " + new String(next.value()), e);
}
break;
}
}
return types;
}

代码示例来源:origin: spring-projects/spring-kafka

@Override
public void onMessage(List> data) {
data.forEach(record -> {
Iterator iterator = record.headers().iterator();
CorrelationKey correlatiOnId= null;
while (correlatiOnId== null && iterator.hasNext()) {

代码示例来源:origin: spring-projects/spring-kafka

@SuppressWarnings("unchecked")
@Override
public ListenableFuture> send(Message message) {
ProducerRecord producerRecord = this.messageConverter.fromMessage(message, this.defaultTopic);
if (!producerRecord.headers().iterator().hasNext()) { // possibly no Jackson
byte[] correlatiOnId= message.getHeaders().get(KafkaHeaders.CORRELATION_ID, byte[].class);
if (correlationId != null) {
producerRecord.headers().add(KafkaHeaders.CORRELATION_ID, correlationId);
}
}
return doSend((ProducerRecord) producerRecord);
}

代码示例来源:origin: spring-projects/spring-kafka

@Test
public void testNoMapper() {
BatchMessagingMessageConverter batchMessageCOnverter= new BatchMessagingMessageConverter();
batchMessageConverter.setHeaderMapper(null);
MessageHeaders headers = testGuts(batchMessageConverter);
@SuppressWarnings("unchecked")
List natives = (List) headers.get(KafkaHeaders.NATIVE_HEADERS);
assertThat(natives).hasSize(3);
Iterator iterator = natives.get(0).iterator();
assertThat(iterator.hasNext()).isEqualTo(true);
Header next = iterator.next();
assertThat(next.key()).isEqualTo("foo");
assertThat(new String(next.value())).isEqualTo("bar");
}

代码示例来源:origin: spring-projects/spring-kafka

boolean hasReplyTopic = false;
Headers headers = record.headers();
Iterator iterator = headers.iterator();
while (iterator.hasNext() && !hasReplyTopic) {
if (iterator.next().key().equals(KafkaHeaders.REPLY_TOPIC)) {

代码示例来源:origin: spring-projects/spring-kafka

container.stop();
this.logger.info("Stop JSON2");
assertThat(received.get().headers().iterator().hasNext()).isFalse();

代码示例来源:origin: spring-projects/spring-kafka

Iterator iterator = r1.headers().iterator();
assertThat(iterator.hasNext()).isTrue();
Header next = iterator.next();

代码示例来源:origin: io.zipkin.brave/brave-instrumentation-kafka-clients

void clearHeaders(Headers headers) {
// Headers::remove creates and consumes an iterator each time. This does one loop instead.
for (Iterator i = headers.iterator(); i.hasNext(); ) {
Header next = i.next();
if (propagationKeys.contains(next.key())) i.remove();
}
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-stream-binder-kafka

@SuppressWarnings("unchecked")
@Nullable
private Map decodeJsonTypes(Headers source) {
Map types = null;
Iterator iterator = source.iterator();
while (iterator.hasNext()) {
Header next = iterator.next();
if (next.key().equals(JSON_TYPES)) {
try {
types = getObjectMapper().readValue(next.value(), Map.class);
}
catch (IOException e) {
logger.error("Could not decode json types: " + new String(next.value()), e);
}
break;
}
}
return types;
}

代码示例来源:origin: spring-cloud/spring-cloud-stream-binder-kafka

@SuppressWarnings("unchecked")
@Nullable
private Map decodeJsonTypes(Headers source) {
Map types = null;
Iterator iterator = source.iterator();
while (iterator.hasNext()) {
Header next = iterator.next();
if (next.key().equals(JSON_TYPES)) {
try {
types = getObjectMapper().readValue(next.value(), Map.class);
}
catch (IOException e) {
logger.error("Could not decode json types: " + new String(next.value()), e);
}
break;
}
}
return types;
}

推荐阅读
author-avatar
蒯曼荷学_936
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有