spring集成kafkaproducermessagehandler元数据发送超时异常

zrfyljdw  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(302)

我试图通过spring集成和docker上的kafka实现以下场景:
轮询http端点,结果为字符串
将结果发送给Kafka
轮询工作正常,我的应用程序设置似乎是正确的,因为应用程序启动时没有任何连接异常。
正如您在输出中看到的,kafkaproducermessagehandler接收消息,但挂起“trying to send metadata request to node-1”一分钟以上,然后抛出timeoutexception。
以下是链接所需的输出和代码:
输出
kafka-broker.log文件
Zookeeper.log
这里是我的应用程序设置:
docker-compose.yml公司
应用程序.yml
kafkaintegration.java文件
Kafka形象主义者为基础的Kafka形象https://github.com/spring-projects/spring-integration-samples Kafka码头集装箱https://github.com/wurstmeister/kafka-docker.
谢谢你的意见和建议!!!!

gtlvzcf8

gtlvzcf81#

我真傻!
我的 Docker 是:

kafka:
    image: wurstmeister/kafka
    ports:
        - "9092:9092"
    links:
        - zookeeper:zk
    environment:
        KAFKA_ADVERTISED_HOST_NAME: 192.168.59.103
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock

其中192.168.59.103是我的ip。我不得不把它改成localhost,现在看起来很好。

17:25:26.797 DEBUG 25436 --- [ask-scheduler-9] o.s.integration.channel.DirectChannel    : preSend on channel 'kafkaChannel', message: GenericMessage [payload={"login":"markuslamm","id":1075906,"avatar_url":"https://avatars.githubusercontent.com/u/1075906?v=3","gravatar_id":"","url":"https://api.github.com/users/markuslamm","html_url":"https://github.com/markuslamm","followers_url":"https://api.github.com/users/markuslamm/followers","following_url":"https://api.github.com/users/markuslamm/following{/other_user}","gists_url":"https://api.github.com/users/markuslamm/gists{/gist_id}","starred_url":"https://api.github.com/users/markuslamm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuslamm/subscriptions","organizations_url":"https://api.github.com/users/markuslamm/orgs","repos_url":"https://api.github.com/users/markuslamm/repos","events_url":"https://api.github.com/users/markuslamm/events{/privacy}","received_events_url":"https://api.github.com/users/markuslamm/received_events","type":"User","site_admin":false,"name":"Markus Lamm","company":null,"blog":null,"location":null,"email":null,"hireable":null,"bio":null,"public_repos":21,"public_gists":0,"followers":0,"following":0,"created_at":"2011-09-24T07:04:34Z","updated_at":"2016-01-26T15:19:00Z"}, headers={Server=GitHub.com, Cache-Control=public, max-age=60, s-maxage=60, ETag="c06cdef5b902bb019cced50412d4b913", Vary=[Accept, Accept-Encoding], Last-Modified=1453821540000, id=6bffbe99-0e6d-55a5-65a1-208c7be7542d, Content-Length=1135, contentType=application/json;charset=utf-8, http_statusCode=200, Date=1453825526000, timestamp=1453825526797}]
2016-01-26 17:25:26.797 DEBUG 25436 --- [ask-scheduler-9] ssor$ReplyProducingMessageHandlerWrapper : kafkaIntegration.kafkaHandler.serviceActivator.handler received message: GenericMessage [payload={"login":"markuslamm","id":1075906,"avatar_url":"https://avatars.githubusercontent.com/u/1075906?v=3","gravatar_id":"","url":"https://api.github.com/users/markuslamm","html_url":"https://github.com/markuslamm","followers_url":"https://api.github.com/users/markuslamm/followers","following_url":"https://api.github.com/users/markuslamm/following{/other_user}","gists_url":"https://api.github.com/users/markuslamm/gists{/gist_id}","starred_url":"https://api.github.com/users/markuslamm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuslamm/subscriptions","organizations_url":"https://api.github.com/users/markuslamm/orgs","repos_url":"https://api.github.com/users/markuslamm/repos","events_url":"https://api.github.com/users/markuslamm/events{/privacy}","received_events_url":"https://api.github.com/users/markuslamm/received_events","type":"User","site_admin":false,"name":"Markus Lamm","company":null,"blog":null,"location":null,"email":null,"hireable":null,"bio":null,"public_repos":21,"public_gists":0,"followers":0,"following":0,"created_at":"2011-09-24T07:04:34Z","updated_at":"2016-01-26T15:19:00Z"}, headers={Server=GitHub.com, Cache-Control=public, max-age=60, s-maxage=60, ETag="c06cdef5b902bb019cced50412d4b913", Vary=[Accept, Accept-Encoding], Last-Modified=1453821540000, id=6bffbe99-0e6d-55a5-65a1-208c7be7542d, Content-Length=1135, contentType=application/json;charset=utf-8, http_statusCode=200, Date=1453825526000, timestamp=1453825526797}]
2016-01-26 17:25:26.797 DEBUG 25436 --- [ask-scheduler-9] o.s.i.k.o.KafkaProducerMessageHandler    : kafkaHandler received message: GenericMessage [payload={"login":"markuslamm","id":1075906,"avatar_url":"https://avatars.githubusercontent.com/u/1075906?v=3","gravatar_id":"","url":"https://api.github.com/users/markuslamm","html_url":"https://github.com/markuslamm","followers_url":"https://api.github.com/users/markuslamm/followers","following_url":"https://api.github.com/users/markuslamm/following{/other_user}","gists_url":"https://api.github.com/users/markuslamm/gists{/gist_id}","starred_url":"https://api.github.com/users/markuslamm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuslamm/subscriptions","organizations_url":"https://api.github.com/users/markuslamm/orgs","repos_url":"https://api.github.com/users/markuslamm/repos","events_url":"https://api.github.com/users/markuslamm/events{/privacy}","received_events_url":"https://api.github.com/users/markuslamm/received_events","type":"User","site_admin":false,"name":"Markus Lamm","company":null,"blog":null,"location":null,"email":null,"hireable":null,"bio":null,"public_repos":21,"public_gists":0,"followers":0,"following":0,"created_at":"2011-09-24T07:04:34Z","updated_at":"2016-01-26T15:19:00Z"}, headers={Server=GitHub.com, Cache-Control=public, max-age=60, s-maxage=60, ETag="c06cdef5b902bb019cced50412d4b913", Vary=[Accept, Accept-Encoding], Last-Modified=1453821540000, id=6bffbe99-0e6d-55a5-65a1-208c7be7542d, Content-Length=1135, contentType=application/json;charset=utf-8, http_statusCode=200, Date=1453825526000, timestamp=1453825526797}]
2016-01-26 17:25:26.798 DEBUG 25436 --- [ask-scheduler-9] ssor$ReplyProducingMessageHandlerWrapper : handler 'kafkaIntegration.kafkaHandler.serviceActivator.handler' produced no reply for request Message: GenericMessage [payload={"login":"markuslamm","id":1075906,"avatar_url":"https://avatars.githubusercontent.com/u/1075906?v=3","gravatar_id":"","url":"https://api.github.com/users/markuslamm","html_url":"https://github.com/markuslamm","followers_url":"https://api.github.com/users/markuslamm/followers","following_url":"https://api.github.com/users/markuslamm/following{/other_user}","gists_url":"https://api.github.com/users/markuslamm/gists{/gist_id}","starred_url":"https://api.github.com/users/markuslamm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuslamm/subscriptions","organizations_url":"https://api.github.com/users/markuslamm/orgs","repos_url":"https://api.github.com/users/markuslamm/repos","events_url":"https://api.github.com/users/markuslamm/events{/privacy}","received_events_url":"https://api.github.com/users/markuslamm/received_events","type":"User","site_admin":false,"name":"Markus Lamm","company":null,"blog":null,"location":null,"email":null,"hireable":null,"bio":null,"public_repos":21,"public_gists":0,"followers":0,"following":0,"created_at":"2011-09-24T07:04:34Z","updated_at":"2016-01-26T15:19:00Z"}, headers={Server=GitHub.com, Cache-Control=public, max-age=60, s-maxage=60, ETag="c06cdef5b902bb019cced50412d4b913", Vary=[Accept, Accept-Encoding], Last-Modified=1453821540000, id=6bffbe99-0e6d-55a5-65a1-208c7be7542d, Content-Length=1135, contentType=application/json;charset=utf-8, http_statusCode=200, Date=1453825526000, timestamp=1453825526797}]
2016-01-26 17:25:26.798 DEBUG 25436 --- [ask-scheduler-9] o.s.integration.channel.DirectChannel    : postSend (sent=true) on channel 'kafkaChannel', message: GenericMessage [payload={"login":"markuslamm","id":1075906,"avatar_url":"https://avatars.githubusercontent.com/u/1075906?v=3","gravatar_id":"","url":"https://api.github.com/users/markuslamm","html_url":"https://github.com/markuslamm","followers_url":"https://api.github.com/users/markuslamm/followers","following_url":"https://api.github.com/users/markuslamm/following{/other_user}","gists_url":"https://api.github.com/users/markuslamm/gists{/gist_id}","starred_url":"https://api.github.com/users/markuslamm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuslamm/subscriptions","organizations_url":"https://api.github.com/users/markuslamm/orgs","repos_url":"https://api.github.com/users/markuslamm/repos","events_url":"https://api.github.com/users/markuslamm/events{/privacy}","received_events_url":"https://api.github.com/users/markuslamm/received_events","type":"User","site_admin":false,"name":"Markus Lamm","company":null,"blog":null,"location":null,"email":null,"hireable":null,"bio":null,"public_repos":21,"public_gists":0,"followers":0,"following":0,"created_at":"2011-09-24T07:04:34Z","updated_at":"2016-01-26T15:19:00Z"}, headers={Server=GitHub.com, Cache-Control=public, max-age=60, s-maxage=60, ETag="c06cdef5b902bb019cced50412d4b913", Vary=[Accept, Accept-Encoding], Last-Modified=1453821540000, id=6bffbe99-0e6d-55a5-65a1-208c7be7542d, Content-Length=1135, contentType=application/json;charset=utf-8, http_statusCode=200, Date=1453825526000, timestamp=1453825526797}]
2016-01-26 17:25:26.799 DEBUG 25436 --- [ask-scheduler-9] o.s.integration.channel.DirectChannel    : postSend (sent=true) on channel 'httpPollChannel', message: GenericMessage [payload=, headers={id=55aecfc4-ea57-d769-4275-801b39a0416d, timestamp=1453825526420}]
qxgroojn

qxgroojn2#

我们在您的日志中看到类似的内容:

227 --- [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient   : Sending metadata request ClientRequest(expectResponse=true, payload=null, request=RequestSend(header={api_key=3,api_version=0,correlation_id=23,client_id=producer-1}, body={topics=[test.topic]})) to node -1
2016-01-26 15:22:24.986 DEBUG 4227 --- [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient   : Trying to send metadata request to node -1

看来你真的应该检查一下代理日志。
首先可能是:

kafka.common.InvalidTopicException: topic name TOPIC= is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'

https://issues.apache.org/jira/browse/kafka-1884
所以 . 在你的主题名称中是非法的。您可能会在客户端使用不兼容的kafka版本。Spring集成Kafka1.3基于Kafka-0.8.2.2。
另一方面可能是网络问题:kafka 0.8.2.2-无法发布消息

相关问题