Google cloud platform 在Google PubSub Pull中收到订户数据后回复消息
一旦您从Publisher收到数据,是否可以回复消息。 一旦发布者发布消息,它必须是直接回复。 我正在使用谷歌PubSub服务 发布者/发送者(PHP): 订阅者/接收者(Javascript): 一旦收到来自的数据,是否可以回复消息 出版商 这取决于你所说的“回复”是什么意思。消息发布者发布关于发布/订阅主题的消息。订阅者从发布/订阅接收消息。这里没有双向通信通道。没有发布/订阅回复方法 订阅者可以将消息发布到发布者作为订阅者读取的其他主题。双方都是出版商和订阅者,但主题不同 一旦收到消息,订户就可以直接调用发布服务器上的API 但是,发布/订阅的目的是将发送方与接收方分离,而不是将它们锁定在一起 一旦收到来自的数据,是否可以回复消息 出版商 这取决于你所说的“回复”是什么意思。消息发布者发布关于发布/订阅主题的消息。订阅者从发布/订阅接收消息。这里没有双向通信通道。没有发布/订阅回复方法 订阅者可以将消息发布到发布者作为订阅者读取的其他主题。双方都是出版商和订阅者,但主题不同 一旦收到消息,订户就可以直接调用发布服务器上的API 但是,发布/订阅的目的是将发送方与接收方分离,而不是将它们锁定在一起Google cloud platform 在Google PubSub Pull中收到订户数据后回复消息,google-cloud-platform,publish-subscribe,pull,reply,subscriber,Google Cloud Platform,Publish Subscribe,Pull,Reply,Subscriber,一旦您从Publisher收到数据,是否可以回复消息。 一旦发布者发布消息,它必须是直接回复。 我正在使用谷歌PubSub服务 发布者/发送者(PHP): 订阅者/接收者(Javascript): 一旦收到来自的数据,是否可以回复消息 出版商 这取决于你所说的“回复”是什么意思。消息发布者发布关于发布/订阅主题的消息。订阅者从发布/订阅接收消息。这里没有双向通信通道。没有发布/订阅回复方法 订阅者可以将消息发布到发布者作为订阅者读取的其他主题。双方都是出版商和订阅者,但主题不同 一旦收到消息,
$sendToOps =[];
$sendToOps['MESSAGE'] = "my message";
$topicName = env('GOOGLE_CLOUD_TO_OPS_TOPIC');
$pubSub = new PubSubClient();
$topic = $pubSub->topic($topicName);
$ret = $topic->publish([
'attributes'=>$sendToOps
]);
//**********The word "Apple" must output here**********
echo $ret;
//*****************************************************
'use strict';
//Get .env File Data
require('dotenv').config({path: '/usr/share/nginx/html/myProject/.env'});
var request = require('request');
var port = process.env.PORT_GATEWAY;
var host = process.env.IP_PUSH;
var test = process.env.TEST_FLAG;
var pubsubSubscription = process.env.GOOGLE_CLOUD_TO_OPS_SUBSCRIPTION;
const keyFilePath= 'public/key/key.json';
// Imports the Google Cloud client library
const {PubSub} = require('@google-cloud/pubsub');
// Creates a client; cache this for further use
const pubSubClient = new PubSub({
keyFilename: keyFilePath
});
function listenForMessages() {
// References an existing subscription
const subscription = pubSubClient.subscription(pubsubSubscription);
// Create an event handler to handle messages
const messageHandler = message => {
console.log(message.attributes);
//*****************************************************
//I want to reply to Sender with the word "Apple" here
//*****************************************************
message.ack()
};
subscription.on('message', messageHandler);
}
listenForMessages();