Apache camel Camel Kafka序列化错误

Apache camel Camel Kafka序列化错误,apache-camel,apache-kafka,Apache Camel,Apache Kafka,我不熟悉骆驼和卡夫卡。 我将Camel 2.18.2与Kafka 0.10.1.1一起使用 我收到这个错误,不明白为什么: org.apache.kafka.common.errors.SerializationException:无法将类[B]的值转换为value.serializer中指定的类org.apache.kafka.common.serialization.StringSerializer 我有以下路线: from("direct://toEnrichEmail") .route

我不熟悉骆驼和卡夫卡。 我将Camel 2.18.2与Kafka 0.10.1.1一起使用

我收到这个错误,不明白为什么:

org.apache.kafka.common.errors.SerializationException:无法将类[B]的值转换为value.serializer中指定的类org.apache.kafka.common.serialization.StringSerializer

我有以下路线:

from("direct://toEnrichEmail") 
.routeId(routeId).marshal().json(JsonLibrary.Jackson, Map.class) 
.log(LoggingLevel.INFO, "Sending to Kafka: ${body}") 
.to("kafka:localhost:9092?topic=enrich-email&requestRequiredAcks=-1"); 
实际发送到路由的代码:

ProducerTemplate template = kafkaProducerFactory.getProducerTemplate(); 
            logger.debug("Sending message type: {}, to uri: {}, route: {}", wimsConfiguration.getMessageType(), 
                            wimsConfiguration.getDirectUri(), wimsConfiguration.getRouteName()); 
            Map<String,Object>headers = new HashMap<>(); // added because the examples do 
            headers.put(KafkaConstants.PARTITION_KEY, 0); 
            headers.put(KafkaConstants.KEY, "1"); 
            template.sendBodyAndHeaders(wimsConfiguration.getDirectUri(), wimsConfiguration.getWimsMessage(), headers); 
ProducerTemplate=kafkaProducerFactory.getProducerTemplate();
debug(“发送消息类型:{},到uri:{},路由:{}”,wimsConfiguration.getMessageType(),
wimsConfiguration.getDirectUri(),wimsConfiguration.getRouteName();
Mapheaders=new HashMap();//添加了,因为示例
headers.put(KafkaConstants.PARTITION_KEY,0);
headers.put(KafkaConstants.KEY,“1”);
template.sendboyandheaders(wimsConfiguration.getDirectUri(),wimsConfiguration.getWimsMessage(),headers);
路由中的日志消息显示消息是正确的JSON字符串,默认序列化程序是字符串,那么为什么它抱怨它无法序列化呢

我查看了camel-kafka组件测试用例,这看起来应该是可行的

以下是Camel/kafka日志的输出示例:

16:32:20967信息[toEnrichEmail](默认任务-12)发送给卡夫卡:{“messageType”:“orderCreate”,“regionCode”:“IN”,“regionLanguage”:[“en”],“orderHeader”:{“order”:“3001357952”,“salesOrg”:“2123”,“soldTo”:“2035266752”,“currency”:“INR”,“documentType”:“TA”,“validFrom”:null,“validTo”:null,“contactName”:“UI IN”,“contactPhone”:“contactEmail”:“contactPhone”:“contactEmail”:””傅。bar@baz.com“},”shipTo:“{”客户编号“:”2035266752“,”公司名称“:”EOU的互联网价格“,”城市名称“:”班加罗尔“,”地区“,”邮政编码“,”街道名称“,”门牌号“:”建筑“,”楼层“:”房间号“:”国家名称“:”印度“,”地区名称“:”卡纳塔克邦“,”billTo:{”客户编号“:”2035266752“,”公司名称“:”EOU的互联网价格“,”城市名称“:”印度“,”地区“:”邮政编码“,”街道名称“,”房屋编号“,”楼层“,”房间编号“,”国家名称“,”印度“,”地区名称“,”卡纳塔克邦“,”付款信息“:”{”付款方式“:”PO“,”采购订单“:”1234567“,”请购单编号“,”信用卡号“,”付款条款“,”国际贸易术语“,”订单摘要“,”订单汇总“{”订单小计“,”“6479.52”,“折扣”:“0”,“发货运输”:“0”,“销售税”:“1187.92”,“dutyTotal”:“1712.56”,“orderTotal”:“9380”},“orderItems”:[{“quoteNumber”:null,“quoteItemNumber”:“000010”,“TotalReservedQuantity”:null,“remainingReservedQuantity”:null,“lineItemNo”:“000010”,“itemCategory”:“TAN”,“Quantity”:“1”,“material”:“T6066-1KG”,“product”:“T6066”,“brandId”:”SIGMA,“描述”:“TRIZMA(R)基地,生物性能认证&”,“yourRef”:“yourPrice”:“8192.08”,“listPrice”:“8192.08”}] 16:32:21008错误[org.apache.camel.processor.DefaultErrorHandler](默认任务-12)传递失败(ExchangeId:ID-stldepx06-sial-com-49604-148650665312-1-1上的MessageId:ID-stldepx06-sial-com-49604-1486506685312-1-2).delivery尝试后耗尽:1捕获:org.apache.kafka.common.errors.SerializationException:无法将类[B]的值转换为value.serializer中指定的类org.apache.kafka.common.serialization.StringSerializer

大宗报价

消息历史记录 RouteId ProcessorId处理器已用时间(毫秒) [toEnrichEmail][toEnrichEmail][direct://toEnrichEmail ] [ 57] [toEnrichEmail][marshall 1][marshal[org.apache.camel.model.dataformat。JsonDataFormat@142a2fec] ] [ 10] [电邮][log4][log][15] [toEnrichEmail][to3][kafka:localhost:9092?topic=enrich email&requestRequiredAcks=-1][25]

堆栈跟踪 ---------------------------------------------------------------------------------------------------------------------------------------:org.apache.kafka.common.errors.SerializationException:无法将类[B]的值转换为value.serializer中指定的类org.apache.kafka.common.serialization.StringSerializer

16:32:21011信息[stdout](默认任务-12)2017-02-07T16:32:21010信息com.sial.notifications.common.rest.NotificationExceptionResponseMapper-映射异常org.apache.camel.cameleExecutionException:在exchange上执行时发生异常:exchange[ID-stldepx06-sial-com-49604-1486506685312-1-2] 16:32:21021信息[stdout](默认任务-12)2017-02-07T16:32:21014错误com.sial.notifications.common.rest.NotificationExceptionResponseMapper-映射异常org.apache.camel.cameleExecutionException:在exchange上执行时发生异常:exchange[ID-stldepx06-sial-com-49604-1486506685312-1-2] 16:32:21021信息[stdout](默认任务-12)org.apache.camel.CamelExecutionException:在exchange上执行时发生异常:exchange[ID-STLDephX06-sial-com-49604-1486506685312-1-2] 16:32:21021信息[stdout](默认任务-12)位于org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1779)~[camel-core-2.18.2.jar:2.18.2] 16:32:21021信息[stdout](默认任务-12)位于org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:677)~[camel-core-2.18.2.jar:2.18.2] 16:32:21021信息[stdout](默认任务-12)位于org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:515)~[camel-core-2.18.2.jar:2.18.2] 16:32:21021信息[stdout](默认任务-12)位于org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:511)~[camel-core-2.18.2.jar:2.18.2] 16:32:21021信息[stdout](默认任务-12)位于