有没有办法使用kafka主题中的所有消息并在此之后停止轮询?

时间:2018-11-29 11:36:40

标签: scala apache-kafka

我的主题中有1000条消息。我需要在 package zyatkov; import org.apache.synapse.MessageContext; import org.apache.synapse.mediators.AbstractMediator; public class HelloMediator extends AbstractMediator { public boolean mediate(MessageContext context) { // TODO Implement your mediation logic here System.out.println("I am custom mediator!!! Hello!!!"); return true; } } 中写一个 org.apache.axis2.deployment.DeploymentException: API deployment from the file : C:\Programs\WSO2\Enterprise_Integrator\6.4.0\tmp\carbonapps\-1234\1543490054959welltestCompositeApplication_1.0.0.car\welltestAPI_1.0.0\welltestAPI-1.0.0.xml : Failed. at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:219) at org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifactType(SynapseAppDeployer.java:1065) at org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:106) at org.wso2.carbon.application.deployer.internal.ApplicationManager.deployCarbonApp(ApplicationManager.java:272) at org.wso2.carbon.application.deployer.CappAxis2Deployer.deploy(CappAxis2Deployer.java:72) at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807) at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144) at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377) at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254) at org.apache.axis2.deployment.RepositoryListener.startListener(RepositoryListener.java:371) at org.apache.axis2.deployment.scheduler.SchedulerTask.checkRepository(SchedulerTask.java:59) at org.apache.axis2.deployment.scheduler.SchedulerTask.run(SchedulerTask.java:67) at org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.runAxisDeployment(CarbonDeploymentSchedulerTask.java:93) at org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.run(CarbonDeploymentSchedulerTask.java:138) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.runAndReset(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.axis2.deployment.DeploymentException: API deployment from the file : C:\Programs\WSO2\Enterprise_Integrator\6.4.0\tmp\carbonapps\-1234\1543490054959welltestCompositeApplication_1.0.0.car\welltestAPI_1.0.0\welltestAPI-1.0.0.xml : Failed. at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:207) ... 21 more Caused by: org.apache.synapse.deployers.SynapseArtifactDeploymentException: API deployment from the file : C:\Programs\WSO2\Enterprise_Integrator\6.4.0\tmp\carbonapps\-1234\1543490054959welltestCompositeApplication_1.0.0.car\welltestAPI_1.0.0\welltestAPI-1.0.0.xml : Failed. at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:480) at org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:71) at org.wso2.carbon.rest.api.ApiDeployer.deploySynapseArtifact(ApiDeployer.java:34) at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:197) ... 21 more Caused by: org.apache.synapse.SynapseException: Error loading class : zyatkov.HelloMediator - Class not found at org.apache.synapse.config.xml.ClassMediatorFactory.createSpecificMediator(ClassMediatorFactory.java:105) at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:94) at org.apache.synapse.config.xml.MediatorFactoryFinder.getMediator(MediatorFactoryFinder.java:223) at org.apache.synapse.config.xml.AbstractListMediatorFactory.addChildren(AbstractListMediatorFactory.java:46) at org.apache.synapse.config.xml.SequenceMediatorFactory.createAnonymousSequence(SequenceMediatorFactory.java:70) at org.apache.synapse.config.xml.rest.ResourceFactory.configureSequences(ResourceFactory.java:107) at org.apache.synapse.config.xml.rest.ResourceFactory.createResource(ResourceFactory.java:50) at org.apache.synapse.config.xml.rest.APIFactory.createAPI(APIFactory.java:88) at org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:47) ... 23 more Caused by: java.lang.ClassNotFoundException: zyatkov.HelloMediator cannot be found by synapse-core_2.1.7.wso2v80 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(Unknown Source) at org.apache.synapse.config.xml.ClassMediatorFactory.createSpecificMediator(ClassMediatorFactory.java:100) ... 31 more 使用者以获取1000条消息,以便可以开始处理1000条消息。

kafka

但是发生的是循环永远不会结束,我在日志中收到以下消息。

scala

2 个答案:

答案 0 :(得分:0)

为什么records.size()为零时不退出?

答案 1 :(得分:0)

另一种方法是一旦record.size()为零就关闭使用者