How to send notification from app engine to local application

54 views
Skip to first unread message

Juan Hoo

unread,
Jan 29, 2018, 4:31:50 PM1/29/18
to Google App Engine
Hi, 

I tried to find a way to send message from Google app engine to local application.
Here is my case, I have a servlet running in the GAE and a daemon application run local linux machine. Sometimes I need the servlet notify the local daemon to run some tasks immediately. 
Not sure whether a way to do that? Email is not a option.
What I found now is 
1. GCM/FCM support mobile device/web app but doesn't support windows/linux application.
2. Google app engine doesn't support listen. So I can not create connection between local application and GAE servlet.  Also the daemon is under firewall and can not listen either.

Are there any other way to achieve it? 

Thanks

George (Cloud Platform Support)

unread,
Jan 29, 2018, 6:26:52 PM1/29/18
to Google App Engine
Hello Juan, 

You may choose to implement a topic, and have your daemon application subscribe to it. Google Cloud Pub/Sub provides reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a topic, and other applications can subscribe to that topic to receive the messages. You may find more detail in the "Writing and Responding to Pub/Sub Messages" online document

Juan Hoo

unread,
Jan 29, 2018, 10:54:10 PM1/29/18
to Google App Engine
Thanks for quick response. I read pub/sub topic before but didn't realize that it can be use in desktop application.
Will check again.

Juan Hoo

unread,
Feb 13, 2018, 3:41:50 PM2/13/18
to Google App Engine
Hi George,

I tried to implement publisher on the my Server code (GAE). It worked. But it stop publishing any message today. I use pub/sub client code similar with example code in https://cloud.google.com/pubsub/docs/publisher

If I publish message through https://console.cloud.google.com on the topic, my client can receive the message without any problem.

Are there any issue with the publish code?

public static void publish(String message) throws Exception {
TopicName topicName = TopicName.of(projectId, topicId);


Publisher publisher = null;
List<ApiFuture<String>> messageIdFutures = new ArrayList<>();

try {
publisher = Publisher.newBuilder(topicName).build();
ByteString data = ByteString.copyFromUtf8(message);
PubsubMessage pubsubMessage = PubsubMessage.newBuilder().setData(data).build();
ApiFuture<String> messageIdFuture = publisher.publish(pubsubMessage);
messageIdFutures.add(messageIdFuture);
}finally {
List<String> messageIds = ApiFutures.allAsList(messageIdFutures).get();
for (String messageId : messageIds) {
System.out.println("published with message ID: " + messageId);

}
if (publisher != null) {
// When finished with the publisher, shutdown to free up resources.
publisher.shutdown();
}

}

Thanks

On Monday, January 29, 2018 at 5:26:52 PM UTC-6, George (Cloud Platform Support) wrote:
Reply all
Reply to author
Forward
0 new messages