我的配置如下
<context:component-scan base-package="com.base.service" />
<int-kafka:inbound-channel-adapter auto-startup="false"
id="kafkaInboundChannelAdapter" kafka-consumer-context-ref="consumerContext"
channel="inputFromKafka">
<poller fixed-delay="20" time-unit="MILLISECONDS" />
</int-kafka:inbound-channel-adapter>
<int-kafka:consumer-context id="consumerContext"
consumer-timeout="4000" zookeeper-connect="zookeeperConnect"
consumer-properties="consumerProperties">
<int-kafka:consumer-configurations>
<int-kafka:consumer-configuration group-id="test-group" max-messages="5000">
<int-kafka:topic id="test" streams="4" />
</int-kafka:consumer-configuration>
</int-kafka:consumer-configurations>
</int-kafka:consumer-context>
<int-kafka:zookeeper-connect id="zookeeperConnect"
zk-connect="localhost:2181" zk-connection-timeout="6000"
zk-session-timeout="6000" zk-sync-time="2000" />
<channel id="inputFromKafka"/>
<service-activator input-channel="inputFromKafka" ref="messageService" />
<beans:import resource="appCtxKafkaBeans.xml"/>
我的服务激活者是:
@Service("messageService")
public class MessageService {
private static Logger log = LogManager.getRootLogger();
@ServiceActivator
public void processMsg(String msg) {
log.info("msg is :"+msg);
}
}
当我运行订阅者时,我正在丢失消息,但是无法在服务激活器中看到消息。
另一个问题,我们是否有kafkaMessageDrivenChannelAdapter的任何xml配置示例?
请咨询
08:20:37,781 [AbstractApplicationContext] - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@14899482: startup date [Sun Apr 19 08:20:37 EDT 2015]; root of context hierarchy
08:20:37,843 [XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [appCtxJms_kafkaint.xml]
08:20:38,218 [PropertiesLoaderSupport] - Loading properties file from URL [jar:file:/C:/Users/Sudarsana/.m2/repository/org/springframework/integration/spring-integration-core/4.0.6.RELEASE/spring-integration-core-4.0.6.RELEASE.jar!/META-INF/spring.integration.default.properties]
08:20:38,218 [IntegrationRegistrar] - No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
08:20:38,281 [XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [appCtxKafkaBeans.xml]
08:20:38,406 [DefaultConfiguringBeanFactoryPostProcessor] - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
08:20:38,410 [DefaultConfiguringBeanFactoryPostProcessor] - No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2015-04-19 08:20:38,660 ERROR RollingFile contains an invalid element or attribute "target"
08:20:38,785 [PropertiesLoaderSupport] - Loading properties file from URL [jar:file:/C:/Users/Sudarsana/.m2/repository/org/springframework/integration/spring-integration-core/4.0.6.RELEASE/spring-integration-core-4.0.6.RELEASE.jar!/META-INF/spring.integration.default.properties]
08:20:38,925 [ExecutorConfigurationSupport] - Initializing ExecutorService 'taskScheduler'
08:20:39,144 [ConsumerConfigFactoryBean] - Using consumer properties => {group.id=test-group, fetch.message.max.bytes=5242880, consumer.timeout.ms=4000, auto.offset.reset=smallest, zookeeper.sync.time.ms=2000, zookeeper.session.timeout.ms=6000, zookeeper.connect=localhost:2181, socket.receive.buffer.bytes=10485760, auto.commit.interval.ms=1000}
08:20:39,175 [Logging$class] - Verifying properties
08:20:39,207 [Logging$class] - Property auto.commit.interval.ms is overridden to 1000
08:20:39,207 [Logging$class] - Property auto.offset.reset is overridden to smallest
08:20:39,207 [Logging$class] - Property consumer.timeout.ms is overridden to 4000
08:20:39,207 [Logging$class] - Property fetch.message.max.bytes is overridden to 5242880
08:20:39,222 [Logging$class] - Property group.id is overridden to test-group
08:20:39,222 [Logging$class] - Property socket.receive.buffer.bytes is overridden to 10485760
08:20:39,222 [Logging$class] - Property zookeeper.connect is overridden to localhost:2181
08:20:39,222 [Logging$class] - Property zookeeper.session.timeout.ms is overridden to 6000
08:20:39,222 [Logging$class] - Property zookeeper.sync.time.ms is overridden to 2000
08:20:39,300 [DefaultLifecycleProcessor$LifecycleGroup] - Starting beans in phase -2147483648
08:20:39,300 [DefaultLifecycleProcessor$LifecycleGroup] - Starting beans in phase 0
08:20:39,300 [AbstractEndpoint] - started kafkaInboundChannelAdapter
08:20:39,300 [EventDrivenConsumer] - Adding {service-activator} as a subscriber to the 'inputFromKafka' channel
08:20:39,300 [AbstractSubscribableChannel] - Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@14899482.inputFromKafka' has 1 subscriber(s).
08:20:39,300 [AbstractEndpoint] - started org.springframework.integration.config.ConsumerEndpointFactoryBean#0
08:20:39,300 [EventDrivenConsumer] - Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
08:20:39,300 [AbstractSubscribableChannel] - Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@14899482.errorChannel' has 1 subscriber(s).
08:20:39,300 [AbstractEndpoint] - started _org.springframework.integration.errorLogger
08:20:39,316 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Connecting to zookeeper instance at localhost:2181
08:20:39,316 [ZkEventThread] - Starting ZkClient event thread.
08:20:39,332 [Environment] - Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT
08:20:39,332 [Environment] - Client environment:host.name=192.168.1.6
08:20:39,332 [Environment] - Client environment:java.version=1.8.0_40
08:20:39,332 [Environment] - Client environment:java.vendor=Oracle Corporation
08:20:39,332 [Environment] - Client environment:java.home=C:\Program Files\Java\jre1.8.0_40
08:20:39,332 [Environment] - Client environment:java.class.path=C:\data\programs\workspace\springitegration-samples\target\classes;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-core\4.0.6.RELEASE\spring-integration-core-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-jms\4.0.6.RELEASE\spring-integration-jms-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-stream\4.0.6.RELEASE\spring-integration-stream-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-jdbc\4.0.6.RELEASE\spring-integration-jdbc-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\com\google\guava\guava\16.0.1\guava-16.0.1.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-jmx\4.0.6.RELEASE\spring-integration-jmx-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-mail\4.0.6.RELEASE\spring-integration-mail-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-beans\4.1.1.RELEASE\spring-beans-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-core\4.1.1.RELEASE\spring-core-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-aop\4.1.1.RELEASE\spring-aop-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-jdbc\4.1.1.RELEASE\spring-jdbc-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-tx\4.1.1.RELEASE\spring-tx-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-orm\4.1.1.RELEASE\spring-orm-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-context\4.1.1.RELEASE\spring-context-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-context-support\4.1.1.RELEASE\spring-context-support-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-aspects\4.1.1.RELEASE\spring-aspects-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\aspectj\aspectjweaver\1.8.2\aspectjweaver-1.8.2.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-expression\4.1.1.RELEASE\spring-expression-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-jms\4.1.1.RELEASE\spring-jms-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-ftp\4.0.6.RELEASE\spring-integration-ftp-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-file\4.0.6.RELEASE\spring-integration-file-4.0.6.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\spring-messaging\4.1.1.RELEASE\spring-messaging-4.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\hsqldb\hsqldb\1.8.0.10\hsqldb-1.8.0.10.jar;C:\Users\Sudarsana\.m2\repository\org\hamcrest\hamcrest-all\1.3\hamcrest-all-1.3.jar;C:\Users\Sudarsana\.m2\repository\com\ibm\com.ibm.mq\7.0.1.2\com.ibm.mq-7.0.1.2.jar;C:\Users\Sudarsana\.m2\repository\com\ibm\com.ibm.mqjms\7.0.1.2\com.ibm.mqjms-7.0.1.2.jar;C:\Users\Sudarsana\.m2\repository\org\apache\activemq\activemq-broker\5.9.0\activemq-broker-5.9.0.jar;C:\Users\Sudarsana\.m2\repository\org\apache\activemq\activemq-client\5.9.0\activemq-client-5.9.0.jar;C:\Users\Sudarsana\.m2\repository\org\apache\geronimo\specs\geronimo-jms_1.1_spec\1.1.1\geronimo-jms_1.1_spec-1.1.1.jar;C:\Users\Sudarsana\.m2\repository\org\fusesource\hawtbuf\hawtbuf\1.9\hawtbuf-1.9.jar;C:\Users\Sudarsana\.m2\repository\org\apache\activemq\activemq-openwire-legacy\5.9.0\activemq-openwire-legacy-5.9.0.jar;C:\Users\Sudarsana\.m2\repository\org\apache\activemq\activemq-kahadb-store\5.9.0\activemq-kahadb-store-5.9.0.jar;C:\Users\Sudarsana\.m2\repository\org\apache\activemq\protobuf\activemq-protobuf\1.1\activemq-protobuf-1.1.jar;C:\Users\Sudarsana\.m2\repository\org\apache\geronimo\specs\geronimo-j2ee-management_1.1_spec\1.0.1\geronimo-j2ee-management_1.1_spec-1.0.1.jar;C:\Users\Sudarsana\.m2\repository\oracle\ojdbc5\11\ojdbc5-11.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\integration\spring-integration-kafka\1.1.1.RELEASE\spring-integration-kafka-1.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\org\apache\avro\avro-compiler\1.7.6\avro-compiler-1.7.6.jar;C:\Users\Sudarsana\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\Sudarsana\.m2\repository\org\apache\velocity\velocity\1.7\velocity-1.7.jar;C:\Users\Sudarsana\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;C:\Users\Sudarsana\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.9.13\jackson-core-asl-1.9.13.jar;C:\Users\Sudarsana\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.13\jackson-mapper-asl-1.9.13.jar;C:\Users\Sudarsana\.m2\repository\org\apache\avro\avro\1.7.6\avro-1.7.6.jar;C:\Users\Sudarsana\.m2\repository\com\thoughtworks\paranamer\paranamer\2.3\paranamer-2.3.jar;C:\Users\Sudarsana\.m2\repository\org\apache\commons\commons-compress\1.4.1\commons-compress-1.4.1.jar;C:\Users\Sudarsana\.m2\repository\org\tukaani\xz\1.0\xz-1.0.jar;C:\Users\Sudarsana\.m2\repository\com\yammer\metrics\metrics-annotation\2.2.0\metrics-annotation-2.2.0.jar;C:\Users\Sudarsana\.m2\repository\com\yammer\metrics\metrics-core\2.2.0\metrics-core-2.2.0.jar;C:\Users\Sudarsana\.m2\repository\com\goldmansachs\gs-collections\5.0.0\gs-collections-5.0.0.jar;C:\Users\Sudarsana\.m2\repository\com\goldmansachs\gs-collections-api\5.0.0\gs-collections-api-5.0.0.jar;C:\Users\Sudarsana\.m2\repository\org\apache\kafka\kafka_2.10\0.8.1.1\kafka_2.10-0.8.1.1.jar;C:\Users\Sudarsana\.m2\repository\org\xerial\snappy\snappy-java\1.0.5\snappy-java-1.0.5.jar;C:\Users\Sudarsana\.m2\repository\org\apache\zookeeper\zookeeper\3.3.4\zookeeper-3.3.4.jar;C:\Users\Sudarsana\.m2\repository\log4j\log4j\1.2.15\log4j-1.2.15.jar;C:\Users\Sudarsana\.m2\repository\jline\jline\0.9.94\jline-0.9.94.jar;C:\Users\Sudarsana\.m2\repository\net\sf\jopt-simple\jopt-simple\3.2\jopt-simple-3.2.jar;C:\Users\Sudarsana\.m2\repository\org\scala-lang\scala-library\2.10.1\scala-library-2.10.1.jar;C:\Users\Sudarsana\.m2\repository\com\101tec\zkclient\0.3\zkclient-0.3.jar;C:\Users\Sudarsana\.m2\repository\javax\jms\jms\1.1\jms-1.1.jar;C:\Users\Sudarsana\.m2\repository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar;C:\Users\Sudarsana\.m2\repository\commons-pool\commons-pool\1.3\commons-pool-1.3.jar;C:\Users\Sudarsana\.m2\repository\mysql\mysql-connector-java\5.1.6\mysql-connector-java-5.1.6.jar;C:\Users\Sudarsana\.m2\repository\org\springframework\retry\spring-retry\1.1.1.RELEASE\spring-retry-1.1.1.RELEASE.jar;C:\Users\Sudarsana\.m2\repository\commons-net\commons-net\3.3\commons-net-3.3.jar;C:\Users\Sudarsana\.m2\repository\org\apache\servicemix\bundles\org.apache.servicemix.bundles.quickfix\1.5.2_1\org.apache.servicemix.bundles.quickfix-1.5.2_1.jar;C:\Users\Sudarsana\.m2\repository\org\apache\logging\log4j\log4j-api\2.1\log4j-api-2.1.jar;C:\Users\Sudarsana\.m2\repository\org\apache\logging\log4j\log4j-core\2.1\log4j-core-2.1.jar;C:\Users\Sudarsana\.m2\repository\org\apache\logging\log4j\log4j-slf4j-impl\2.1\log4j-slf4j-impl-2.1.jar;C:\Users\Sudarsana\.m2\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\Users\Sudarsana\.m2\repository\javax\mail\mail\1.4.5\mail-1.4.5.jar;C:\Users\Sudarsana\.m2\repository\javax\activation\activation\1.1\activation-1.1.jar
08:20:39,332 [Environment] - Client environment:java.library.path=C:\Program Files\Java\jre1.8.0_40\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre1.8.0_40/bin/server;C:/Program Files/Java/jre1.8.0_40/bin;C:/Program Files/Java/jre1.8.0_40/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Lenovo\FusionEngine;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\Program Files (x86)\Skype\Phone;C:\apache-maven-3.3.1\bin;C:\mongodb-win32-x86_64-2.4.13\bin;C:\sts-bundle\sts-3.6.4.RELEASE;;.
08:20:39,347 [Environment] - Client environment:java.io.tmpdir=C:\Users\SUDARS~1\AppData\Local\Temp\
08:20:39,347 [Environment] - Client environment:java.compiler=<NA>
08:20:39,347 [Environment] - Client environment:os.name=Windows 8.1
08:20:39,347 [Environment] - Client environment:os.arch=amd64
08:20:39,347 [Environment] - Client environment:os.version=6.3
08:20:39,347 [Environment] - Client environment:user.name=Sudarsana
08:20:39,347 [Environment] - Client environment:user.home=C:\Users\Sudarsana
08:20:39,347 [Environment] - Client environment:user.dir=C:\data\programs\workspace\springitegration-samples
08:20:39,347 [ZooKeeper] - Initiating client connection, connectString=localhost:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@63d6c00d
08:20:39,519 [ClientCnxn$SendThread] - Opening socket connection to server localhost/127.0.0.1:2181
08:20:39,528 [ClientCnxn$SendThread] - Socket connection established to localhost/127.0.0.1:2181, initiating session
08:20:39,544 [ClientCnxn$SendThread] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14ccc0d6f9d005e, negotiated timeout = 6000
08:20:39,544 [ZkClient] - zookeeper state changed (SyncConnected)
08:20:39,575 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], starting auto committer every 1000 ms
08:20:39,607 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], begin registering consumer test-group_Bhavya-PC-1429446039316-36f90a8b in ZK
08:20:39,638 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], end registering consumer test-group_Bhavya-PC-1429446039316-36f90a8b in ZK
08:20:39,638 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], starting watcher executor thread for consumer test-group_Bhavya-PC-1429446039316-36f90a8b
08:20:39,669 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], begin rebalancing consumer test-group_Bhavya-PC-1429446039316-36f90a8b try #0
08:20:39,794 [Logging$class] - [ConsumerFetcherManager-1429446039544] Stopping leader finder thread
08:20:39,794 [Logging$class] - [ConsumerFetcherManager-1429446039544] Stopping all fetchers
08:20:39,794 [Logging$class] - [ConsumerFetcherManager-1429446039544] All connections stopped
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Cleared all relevant queues for this fetcher
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Cleared the data chunks in all the consumer message iterators
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Committing all offsets after clearing the fetcher queues
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Releasing partition ownership
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Consumer test-group_Bhavya-PC-1429446039316-36f90a8b rebalancing the following partitions: ArrayBuffer(0) for topic test with consumers: List(test-group_Bhavya-PC-1429446039316-36f90a8b-0, test-group_Bhavya-PC-1429446039316-36f90a8b-1, test-group_Bhavya-PC-1429446039316-36f90a8b-2, test-group_Bhavya-PC-1429446039316-36f90a8b-3)
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], No broker partitions consumed by consumer thread test-group_Bhavya-PC-1429446039316-36f90a8b-2 for topic test
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], No broker partitions consumed by consumer thread test-group_Bhavya-PC-1429446039316-36f90a8b-3 for topic test
08:20:39,794 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], test-group_Bhavya-PC-1429446039316-36f90a8b-0 attempting to claim partition 0
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], No broker partitions consumed by consumer thread test-group_Bhavya-PC-1429446039316-36f90a8b-1 for topic test
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], test-group_Bhavya-PC-1429446039316-36f90a8b-0 successfully owned partition 0 for topic test
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Updating the cache
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], Consumer test-group_Bhavya-PC-1429446039316-36f90a8b selected partitions : test:0: fetched offset = 1002040: consumed offset = 1002040
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b-leader-finder-thread], Starting
08:20:39,810 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], end rebalancing consumer test-group_Bhavya-PC-1429446039316-36f90a8b try #0
08:20:39,825 [Logging$class] - Verifying properties
08:20:39,825 [Logging$class] - Property client.id is overridden to test-group
08:20:39,825 [Logging$class] - Property metadata.broker.list is overridden to 192.168.1.6:9092
08:20:39,825 [Logging$class] - Property request.timeout.ms is overridden to 30000
08:20:39,841 [Logging$class] - Fetching metadata from broker id:0,host:192.168.1.6,port:9092 with correlation id 0 for 1 topic(s) Set(test)
08:20:39,841 [Logging$class] - Connected to 192.168.1.6:9092 for producing
08:20:39,872 [Logging$class] - Disconnecting from 192.168.1.6:9092
08:20:39,888 [Logging$class] - [ConsumerFetcherThread-test-group_Bhavya-PC-1429446039316-36f90a8b-0-0], Starting
08:20:39,888 [Logging$class] - [ConsumerFetcherManager-1429446039544] Added fetcher for partitions ArrayBuffer([[test,0], initOffset 1002040 to broker id:0,host:192.168.1.6,port:9092] )
08:20:42,304 [DefaultLifecycleProcessor$LifecycleGroup] - Stopping beans in phase 0
08:20:42,308 [AbstractEndpoint] - stopped kafkaInboundChannelAdapter
08:20:42,308 [EventDrivenConsumer] - Removing {service-activator} as a subscriber to the 'inputFromKafka' channel
08:20:42,308 [AbstractSubscribableChannel] - Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@14899482.inputFromKafka' has 0 subscriber(s).
08:20:42,308 [AbstractEndpoint] - stopped org.springframework.integration.config.ConsumerEndpointFactoryBean#0
08:20:42,308 [EventDrivenConsumer] - Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
08:20:42,308 [AbstractSubscribableChannel] - Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@14899482.errorChannel' has 0 subscriber(s).
08:20:42,308 [AbstractEndpoint] - stopped _org.springframework.integration.errorLogger
08:20:42,308 [DefaultLifecycleProcessor$LifecycleGroup] - Stopping beans in phase -2147483648
08:20:42,308 [AbstractApplicationContext] - Closing org.springframework.context.support.ClassPathXmlApplicationContext@14899482: startup date [Sun Apr 19 08:20:37 EDT 2015]; root of context hierarchy
08:20:42,308 [DefaultLifecycleProcessor$LifecycleGroup] - Stopping beans in phase 0
08:20:42,308 [DefaultLifecycleProcessor$LifecycleGroup] - Stopping beans in phase -2147483648
08:20:42,308 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], ZKConsumerConnector shutting down
08:20:42,323 [Logging$class] - [ConsumerFetcherManager-1429446039544] Stopping leader finder thread
08:20:42,323 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b-leader-finder-thread], Shutting down
08:20:42,323 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b-leader-finder-thread], Stopped
08:20:42,323 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b-leader-finder-thread], Shutdown completed
08:20:42,323 [Logging$class] - [ConsumerFetcherManager-1429446039544] Stopping all fetchers
08:20:42,323 [Logging$class] - [ConsumerFetcherThread-test-group_Bhavya-PC-1429446039316-36f90a8b-0-0], Shutting down
08:20:42,323 [Logging$class] - Reconnect due to socket error: null
08:20:42,323 [Logging$class] - [ConsumerFetcherThread-test-group_Bhavya-PC-1429446039316-36f90a8b-0-0], Stopped
08:20:42,323 [Logging$class] - [ConsumerFetcherThread-test-group_Bhavya-PC-1429446039316-36f90a8b-0-0], Shutdown completed
08:20:42,323 [Logging$class] - [ConsumerFetcherManager-1429446039544] All connections stopped
08:20:42,339 [ZkEventThread] - Terminate ZkClient event thread.
08:20:42,339 [ZooKeeper] - Session: 0x14ccc0d6f9d005e closed
08:20:42,339 [ClientCnxn$EventThread] - EventThread shut down
08:20:42,355 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], ZKConsumerConnector shut down completed
08:20:42,355 [ExecutorConfigurationSupport] - Shutting down ExecutorService 'taskScheduler'
08:20:42,667 [Logging$class] - [test-group_Bhavya-PC-1429446039316-36f90a8b], stopping watcher executor thread for consumer test-group_Bhavya-PC-1429446039316-36f90a8b
<int-kafka:message-driven-channel-adapter
id="kafkaListener"
auto-startup="true"
phase="100"
send-timeout="5000"
channel="inputFromKafka"
error-channel="errorChannel"
error-handler="errorHandler"
connection-factory="connectionFactory"
key-decoder="keyDecoder"
payload-decoder="payloadDecoder"
offset-manager="offsetManager"
task-executor="executor"
stop-timeout="${stop.timeout:5000}"
queue-size="${queue.size:1024}"
concurrency="${concurrency:10}"
max-fetch="${max.fetch:1000}"
topics="${topics:test}" />
答案 0 :(得分:0)
启用org.springframework.integration
的DEBUG日志记录以监控邮件活动。有关配置示例,请参阅test cases。
答案 1 :(得分:0)
现在,我能够看到消息流向服务激活器。
<context:component-scan base-package="com.base.service" />
<int-kafka:inbound-channel-adapter auto-startup="true"
id="kafkaInboundChannelAdapter" kafka-consumer-context-ref="consumerContext"
channel="inputFromKafka">
<poller fixed-delay="2000" id="poll" time-unit="MILLISECONDS" />
</int-kafka:inbound-channel-adapter>
<int-kafka:consumer-context id="consumerContext"
consumer-timeout="4000" zookeeper-connect="zookeeperConnect"
consumer-properties="consumerProperties">
<int-kafka:consumer-configurations>
<int-kafka:consumer-configuration group-id="test-group" max-messages="5000">
<int-kafka:topic id="test" streams="4" />
</int-kafka:consumer-configuration>
</int-kafka:consumer-configurations>
</int-kafka:consumer-context>
<int-kafka:zookeeper-connect id="zookeeperConnect"
zk-connect="localhost:2181" zk-connection-timeout="6000"
zk-session-timeout="6000" zk-sync-time="2000" />
<channel id="inputFromKafka"/>
<service-activator input-channel="inputFromKafka" ref="messageService" method="processMsg" />
<beans:import resource="appCtxKafkaBeans.xml"/>
这是服务激活码
@ServiceActivator
public void processMsg(HashMap<Object, Object> msg) {
for(Entry<Object, Object> entry : msg.entrySet()) {
log.info("key is :"+entry.getKey()+ " , value:"+entry.getValue());
ConcurrentHashMap<Integer,List<byte[]>> messages = (ConcurrentHashMap<Integer,List<byte[]>>)entry.getValue();
Collection<List<byte[]>> values = messages.values();
for (Iterator<List<byte[]>> iterator = values.iterator(); iterator.hasNext();) {
List<byte[]> list = iterator.next();
for (byte[] object : list) {
String message = new String(object);
log.info("\tMessage: " + message);
}
}
}
}