| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This sample demonstrates how to use Google Cloud Pub/Sub and Google Translate from Google App Engine standard environment.
The home page of this application provides a form to publish messages using Google/Cloud PubSub (though publishing in local development is currently not supported). The application then receives these published messages over a push subscription endpoint, translates it from a source language into a target language, and finally stores in Google Cloud Datastore.
The home page also provides a view of the most recently translated messages persisted in storage.
Copy the sample apps to your local machine, and cd to the translate-pubsub directory:
git clone https://github.com/GoogleCloudPlatform/java-docs-samples cd java-docs-samples/appengine-java8/translate-pubsub
gcloud init
gcloud app create
For local development, set up authentication
Choose a topic name and verification token.
export PUBSUB_TOPIC=<your-topic-name> export PUBSUB_VERIFICATION_TOKEN=<your-verification-token>
gcloud pubsub topics create $PUBSUB_TOPIC
gcloud pubsub subscriptions create <your-subscription-name> \ --topic $PUBSUB_TOPIC \ --push-endpoint \ https://<your-project-id>.appspot.com/pubsub/push?token=$PUBSUB_VERIFICATION_TOKEN \ --ack-deadline 30
Run using shown Maven command. You can then direct your browser to http://localhost:8080/ to see translated messages created in the following step.
mvn appengine:run
curl -H "Content-Type: application/json" -i --data @sample_message.json \ "localhost:8080/pubsub/push?token=$PUBSUB_VERIFICATION_TOKEN"
Update the environment variables PUBSUB_TOPIC and PUBSUB_VERIFICATION_TOKEN in appengine-web.xml, then:
mvn appengine:deploy
Direct your browser to https://<your-project-id>.appspot.com.
| Back | FazBrowse Home | New Git URL |