Google Cloud 运行 pubsub pull listener app 启动失败
Google Cloud Run pubsub pull listener app fails to start
我正在使用此示例 java 代码的侦听器部分 运行 在云上测试 pubsub“拉”订阅者(SubscribeAsyncExample...稍微修改以适合我的 SpringBoot 应用程序):
https://cloud.google.com/pubsub/docs/quickstart-client-libraries#java_1
它在部署期间无法启动...但是在它尝试启动时,它确实从 pubsub 队列中提取项目。最初,我在不同的 pubsub 主题上有一个 HTTP“推送”接收器(@RestController)并且工作正常。有什么建议么?我是 Cloud 运行 的新手。谢谢
Deploying...
Creating Revision... Cloud Run error: Container failed to start. Failed to start and then listen on the port defined
by the PORT environment variable. Logs for this revision might contain more information....failed
Deployment failed
In logs:
2020-08-11 18:43:22.688 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4606 ms
2020-08-11T18:43:25.287759Z Listening for messages on projects/ce-cxmo-dev/subscriptions/AndySubscriptionPull:
2020-08-11T18:43:25.351650801Z Container Sandbox: Unsupported syscall setsockopt(0x18,0x29,0x31,0x3eca02dfd974,0x4,0x28). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information.
2020-08-11T18:43:25.351770555Z Container Sandbox: Unsupported syscall setsockopt(0x18,0x29,0x12,0x3eca02dfd97c,0x4,0x28). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information.
2020-08-11 18:43:25.680 WARN 1 --- [ault-executor-0] i.g.n.s.i.n.u.internal.MacAddressUtil : Failed to find a usable hardware address from the network interfaces; using random bytes: ae:2c:fb:e7:92:9c:2b:24
2020-08-11T18:45:36.282714Z Id: 1421389098497572
2020-08-11T18:45:36.282763Z Data: We be pub-sub'n in pull mode2!!
Nothing else after this and the app stops running.
@Component
public class AndyTopicPullRecv {
public AndyTopicPullRecv()
{
subscribeAsyncExample("ce-cxmo-dev", "AndySubscriptionPull");
}
public static void subscribeAsyncExample(String projectId, String subscriptionId) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
// Instantiate an asynchronous message receiver.
MessageReceiver receiver =
(PubsubMessage message, AckReplyConsumer consumer) -> {
// Handle incoming message, then ack the received message.
System.out.println("Id: " + message.getMessageId());
System.out.println("Data: " + message.getData().toStringUtf8());
consumer.ack();
};
Subscriber subscriber = null;
try {
subscriber = Subscriber.newBuilder(subscriptionName, receiver).build();
// Start the subscriber.
subscriber.startAsync().awaitRunning();
System.out.printf("Listening for messages on %s:\n", subscriptionName.toString());
// Allow the subscriber to run for 30s unless an unrecoverable error occurs.
// subscriber.awaitTerminated(30, TimeUnit.SECONDS);
subscriber.awaitTerminated();
System.out.printf("Async subscribe terminated on %s:\n", subscriptionName.toString());
// } catch (TimeoutException timeoutException) {
} catch (Exception e) {
// Shut down the subscriber after 30s. Stop receiving messages.
subscriber.stopAsync();
System.out.printf("Async subscriber exception: " + e);
}
}
}
Kolban 问题很重要!!对于共享代码,我想说“不”。 Cloud Run contract 明确:
- 您的服务必须响应 HTTP 请求。出于请求,您无需支付任何费用,也没有 CPU 专用于您的实例(当没有请求正在处理时,该实例就像一个守护进程)
- 你的服务必须是无状态的(这里不是你的情况,我不会花时间在这上面)
如果您想提取您的 PubSub 订阅,请在您的 code with a Rest controller 中创建一个端点。在您处理此请求时,运行 您的拉取机制和处理消息。
此端点可以由 Cloud Scheduler 定期调用以保持进程正常运行。
请注意,您有 a max request processing timeout at 15 minutes(今天,近期可能会发生变化)。所以,你不能 运行 你的过程超过 15 分钟。使其具有弹性以应对失败并将您的调度程序设置为每 15 分钟调用一次您的服务
我正在使用此示例 java 代码的侦听器部分 运行 在云上测试 pubsub“拉”订阅者(SubscribeAsyncExample...稍微修改以适合我的 SpringBoot 应用程序): https://cloud.google.com/pubsub/docs/quickstart-client-libraries#java_1 它在部署期间无法启动...但是在它尝试启动时,它确实从 pubsub 队列中提取项目。最初,我在不同的 pubsub 主题上有一个 HTTP“推送”接收器(@RestController)并且工作正常。有什么建议么?我是 Cloud 运行 的新手。谢谢
Deploying...
Creating Revision... Cloud Run error: Container failed to start. Failed to start and then listen on the port defined
by the PORT environment variable. Logs for this revision might contain more information....failed
Deployment failed
In logs:
2020-08-11 18:43:22.688 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4606 ms
2020-08-11T18:43:25.287759Z Listening for messages on projects/ce-cxmo-dev/subscriptions/AndySubscriptionPull:
2020-08-11T18:43:25.351650801Z Container Sandbox: Unsupported syscall setsockopt(0x18,0x29,0x31,0x3eca02dfd974,0x4,0x28). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information.
2020-08-11T18:43:25.351770555Z Container Sandbox: Unsupported syscall setsockopt(0x18,0x29,0x12,0x3eca02dfd97c,0x4,0x28). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information.
2020-08-11 18:43:25.680 WARN 1 --- [ault-executor-0] i.g.n.s.i.n.u.internal.MacAddressUtil : Failed to find a usable hardware address from the network interfaces; using random bytes: ae:2c:fb:e7:92:9c:2b:24
2020-08-11T18:45:36.282714Z Id: 1421389098497572
2020-08-11T18:45:36.282763Z Data: We be pub-sub'n in pull mode2!!
Nothing else after this and the app stops running.
@Component
public class AndyTopicPullRecv {
public AndyTopicPullRecv()
{
subscribeAsyncExample("ce-cxmo-dev", "AndySubscriptionPull");
}
public static void subscribeAsyncExample(String projectId, String subscriptionId) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
// Instantiate an asynchronous message receiver.
MessageReceiver receiver =
(PubsubMessage message, AckReplyConsumer consumer) -> {
// Handle incoming message, then ack the received message.
System.out.println("Id: " + message.getMessageId());
System.out.println("Data: " + message.getData().toStringUtf8());
consumer.ack();
};
Subscriber subscriber = null;
try {
subscriber = Subscriber.newBuilder(subscriptionName, receiver).build();
// Start the subscriber.
subscriber.startAsync().awaitRunning();
System.out.printf("Listening for messages on %s:\n", subscriptionName.toString());
// Allow the subscriber to run for 30s unless an unrecoverable error occurs.
// subscriber.awaitTerminated(30, TimeUnit.SECONDS);
subscriber.awaitTerminated();
System.out.printf("Async subscribe terminated on %s:\n", subscriptionName.toString());
// } catch (TimeoutException timeoutException) {
} catch (Exception e) {
// Shut down the subscriber after 30s. Stop receiving messages.
subscriber.stopAsync();
System.out.printf("Async subscriber exception: " + e);
}
}
}
Kolban 问题很重要!!对于共享代码,我想说“不”。 Cloud Run contract 明确:
- 您的服务必须响应 HTTP 请求。出于请求,您无需支付任何费用,也没有 CPU 专用于您的实例(当没有请求正在处理时,该实例就像一个守护进程)
- 你的服务必须是无状态的(这里不是你的情况,我不会花时间在这上面)
如果您想提取您的 PubSub 订阅,请在您的 code with a Rest controller 中创建一个端点。在您处理此请求时,运行 您的拉取机制和处理消息。
此端点可以由 Cloud Scheduler 定期调用以保持进程正常运行。
请注意,您有 a max request processing timeout at 15 minutes(今天,近期可能会发生变化)。所以,你不能 运行 你的过程超过 15 分钟。使其具有弹性以应对失败并将您的调度程序设置为每 15 分钟调用一次您的服务