我有一个Kafka应用程序,它有一个producer向主题生成消息的人。Aconsumer然后从主题中获取消息,对给定的消息执行一些逻辑,然后将它们生成到另一个主题。我正在使用ProducerRecord和ConsumerRecords。
我希望我的应用程序创建 2compacted topics然后使用它们。如果compacted topics已经存在,只显示一条消息并继续。
我的SimpleProducer班级:
package com.kafkatest.demo;
import java.util.*;
import org.apache.kafka.clients.producer.*;
public class SimpleProducer extends Thread{
public static void main(String[] args) throws Exception{
String topicName = "nodesTopic";
String key = "Key1";
String value = "Value-1";
String key1 = "Key2";
String value1 = "Value-2";
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092,localhost:9093");
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
Producer<String, String> producer = new KafkaProducer <>(props);
ProducerRecord<String, String> record …Run Code Online (Sandbox Code Playgroud) 我有一个supervisor问题docker。我使用supervisor来启动 4 个脚本.sh:datagrid.sh、ml.sh和startmap.sh。dirwatcher.sh
当我打开容器,导航到脚本目录并尝试手动启动脚本时,一切正常,脚本全部启动,但它们不会在启动时间启动。我认为问题出在主管身上。谢谢。
错误:
2018-08-08 12:28:08,512 INFO spawned: 'datagrid' with pid 171
2018-08-08 12:28:08,514 INFO spawned: 'dirwatcher' with pid 172
2018-08-08 12:28:08,517 INFO spawned: 'startmap' with pid 173
2018-08-08 12:28:08,519 INFO spawned: 'ml' with pid 175
2018-08-08 12:28:08,520 INFO exited: datagrid (exit status 0; not expected)
2018-08-08 12:28:08,520 INFO exited: dirwatcher (exit status 0; not expected)
2018-08-08 12:28:08,520 INFO exited: startmap (exit status 0; …Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 8 项目,我用来ngrx在状态存储中存储对象数组。我设法做到了这一点,但现在,我想使用post request状态存储中的数据创建服务器。
this.dataService.postData(this.store.pipe(select('dataStore')));
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试的代码,但它不起作用。谢谢
我已经在 python 上编写了一个更复杂的程序,但我一直试图找出列表是否包含给定的字符串。
简化问题:
product_names = ['string1', 'string2']
products = [{'id': 'string1', 'test': 'test1 - value'}, {'id': 'string3', 'test': 'test2 - value'}]
# prints: string1 string3
product_ids = (p['id'] for p in products)
for ids in product_ids:
print(ids)
# doesn't print found
for p in product_names:
if p in product_ids:
print('found')
# doesn't print missing product names
if not all(p in product_ids for p in product_names):
print('missing product names')
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这不起作用,我是否必须以某种方式重新启动起始索引,是这样,如何?