我正在尝试使用以下代码从 pub/sub 中读取
Read<String> pubsub = PubsubIO.<String>read().topic("projects/<projectId>/topics/<topic>").subscription("projects/<projectId>/subscriptions/<subscription>").withCoder(StringUtf8Coder.of()).withAttributes(new SimpleFunction<PubsubMessage,String>() {
@Override
public String apply(PubsubMessage input) {
LOG.info("hola " + input.getAttributeMap());
return new String(input.getMessage());
}
});
PCollection<String> pps = p.apply(pubsub)
.apply(
Window.<String>into(
FixedWindows.of(Duration.standardSeconds(15))));
pps.apply("printdata",ParDo.of(new DoFn<String, String>() {
@ProcessElement
public void processElement(ProcessContext c) {
LOG.info("hola amigo "+c.element());
c.output(c.element());
}
}));
Run Code Online (Sandbox Code Playgroud)
与我在 NodeJS 上收到的相比,我收到了将包含在该data字段中的消息。我怎样才能得到这个ackId字段(我以后可以用它来确认消息)?我正在打印的属性映射是null. 是否有其他方法可以确认所有消息而无需弄清楚 ackId?
使用最新的客户端库(pymongo 3.4、mongodb (nodejs) 2.2.27),我在通过复制连接到我的 mongodb 服务器时遇到问题。复制集配置包含服务器的内部 ip 或主机名。我收到以下错误:
pymongo.errors.ServerSelectionTimeoutError: mongodbdriver20151129-arbiter-1:27017: [Errno 8] nodename nor servname provided, or not known,mongodbdriver20151129-instance-1:27017: [Errno 8] nodename nor servname provided, or not known,mongodbdriver20151129-instance-2:27017: [Errno 8] nodename nor servname provided, or not known
Run Code Online (Sandbox Code Playgroud)
或者
pymongo.errors.ServerSelectionTimeoutError: 10.0.0.5:27017: timed out,10.0.0.6:27017: timed out,10.0.0.4:27017: timed out
Run Code Online (Sandbox Code Playgroud)
我目前正在通过更改副本集配置来解决这个问题,以包含服务器的外部 ip,但我想这会减慢服务器间的通信速度。如何使用原始 rsconf 从外部位置连接到我的服务器?
[更新] 注意:我正在尝试连接到服务器的外部 IP,并且在使用 pymongo 2.8 或 mongodb (js) 2.1.4 时效果很好
[更新] 关注此聊天以获取更多详细信息/示例
而不是在编译/运行时收到承诺拒绝警告
npm start
(node:22996) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected identifier
Run Code Online (Sandbox Code Playgroud)
我可以获得整个堆栈跟踪,指出我的代码中出现错误的行,就像在 Nodejs 4 中那样?
SyntaxError: /Users/user/Documents/project/app.js: Unexpected token (30:57)
Run Code Online (Sandbox Code Playgroud) f1, f2我已经在两个字段上创建了索引db.test.createIndex({"f1":"text","f2":"text"},{unique:true})
{
"v" : 2,
"unique" : true,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "f1_text_f2_text",
"ns" : "test.test",
"weights" : {
"f1" : 1,
"f2" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
}
Run Code Online (Sandbox Code Playgroud)
当我插入两个文档时
db.test.insert({f1:"hello",f2:"there"})
db.test.insert({f1:"hello",f2:"there2"})
Run Code Online (Sandbox Code Playgroud)
我收到重复密钥错误
"E11000 duplicate key error collection: test.test index: f1_text_f2_text dup key: { : \"hello\", : 1.1 }"
Run Code Online (Sandbox Code Playgroud)
然而db.test.insert({f1:"hello2",f2:"there"})有效。
复合文本索引不应该像常规复合索引一样工作吗?
mongodb ×2
apache-beam ×1
indexing ×1
java ×1
javascript ×1
node.js ×1
pymongo ×1
replicaset ×1