SVCC Google App Engine: Java Runtime
Upcoming SlideShare
Loading in...5
×
 

SVCC Google App Engine: Java Runtime

on

  • 4,276 views

In this session, we will go step by step through the creation of a Google App Engine (GAE) application using the Java Runtime. This will be a beginner level session with respect to Google App Engine, ...

In this session, we will go step by step through the creation of a Google App Engine (GAE) application using the Java Runtime. This will be a beginner level session with respect to Google App Engine, but, a good understanding of how to build web applications in Java will be assumed. The code of the twitter bot sample application is available online.

Statistics

Views

Total Views
4,276
Views on SlideShare
4,265
Embed Views
11

Actions

Likes
2
Downloads
50
Comments
0

2 Embeds 11

http://www.slideshare.net 10
http://www.lmodules.com 1

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • How many people are familiar with twitter? Explain concepts: followers, friends, tweets, and direct messages. Kritter makes all your followers friends automatically. It responds to certain commands sent from friends as direct messages and sends back responses to friends also as direct messages.
  • Can I have a volunteer? Anyone on twitter right now? If not, MrVanShizzle will have to fill in. =) Note: the long term vision is third party applications generating the KrillionKritter commands on behalf of users. For now, this is an easy way to test the functionality.
  • This has been quite the learning opportunity for me as a long time IntelliJ IDEA user. If the plugin for IDEA had not displayed passwords in the clear, I would have probably gone that route instead for this presentation. I highly recommend Fred Sauer's Sunday 9:15am GWT Session for those interested in GWT.
  • Due to sessions being shortened from 75 to 60 minutes, we won't be able to take time now to get folks setup. Sorry! Java getting started docs are excellent and work well for the Eclipse development approach. Twitter4J has worked flawlessly. Even using the HttpClient class from this project for my Krillion web service calls.
  • Mention logging setup in appengine.xml. Good idea to set INFO as default logging level for new projects. Nothing special in web.xml. Define my own custom task queues. Cron can be shut off by deploying an empty element.
  • In my Eclipse setup, jdoconfig.xml was generated for me with reasonable defaults right out of the box. kritter.properties is where you configure the bot to work with the twitter account of your choosing. Checked in values are placeholders that you must change to some valid twitter account credentials.
  • Say more about datastore later. Focus on the task queue usage in this servlet: 1. Get named queue from factory 2. Add url to the queue 3. Uses builder pattern for adding parameters to the url. Note: Output a plain text response in parallel to logged information. This was really helpful during initial manual testing phase.
  • Each worker request provides new follower's ID as request parameter. Use this to verify existing friendship and establish new friendships as necessary. Send twitter direct message welcoming new friends. Persist new friend records in our datastore. You need to be careful with task handlers. If they fail, the task queue management logic will keep retrying them. They can also run more than once. Can you say ... Idempotence? =)
  • Say more about datastore later. Focus on the task queue usage in this servlet: 1. Get named queue from factory 2. Add url to the queue 3. Uses builder pattern for adding parameters to the url. Note: Output a plain text response in parallel to logged information. This was really helpful during initial manual testing phase.
  • Each worker request provides message text and the sender as request parameters. Any messages that match our command syntax are handled. Note: We update Friend record early on and add new Reply record at the end. Important to do single close of the PersistenceManager at the very end.
  • If you go the JDO route, the google documentation on JDO linked to here is a must read. Very well documented. In fact, my implementation of PMF is a copy/paste from the google documentation. This is highly recommended due to overhead associated with PersistenceManager initialization. My datastore may not be very complicated, but, I was extremely happy with how easy persistence was to implement for this application.
  • By retrieving latest FollowerStat in cron job processing, I can efficiently process only the new followers during each scheduled execution of the /followers job. By retrieving latest MessageStat in cron job processing, I can efficiently process only the new messages during each scheduled execution of the /messages job.
  • Friend entities are pretty straighforward. It will get more interesting when I add support to store multiple products or multiple zip code preferences per Friend. Reply entities capture the incoming command and the generated answer. Storing the parsed UPC code and Zip code as separate fields for possible future use. For example, looking up in the Reply table all the unique UPC codes searched for in a particular Zip code area.
  • Demonstrate how simple deployment is from within Eclipse IDE. I confess. I did most of my debugging with the logs and plain text responses during the initial manual testing. In theory, you deploy locally to debug. Get to know the App Engine web dashboard for your application. Deployed version management, log viewing, cron job status, viewing your datastore data, and quota stats are all there. It may not be sexy, but, there is a lot of useful functionality in it.
  • The kritter cron jobs spawn idempotent tasks, but, it is still a good idea to secure the URLs involved. This is something I will be adding soon I would like to add a dashboard to the webapp that uses Ajax to show a live stream of new followers and new replies. This is a perfect task for introducing GWT to this project. My current RegEx approach will not scale. Kritter code sorely needs to be properly documented. My bad.
  • First resource, is a Google I/O video that comes highly recommended. I'm a big fan of Rich Hightower's stuff. This is a three part tutorial that looks promising. Gaelyk looked interesting to me. At this point, there is also a Grails App Engine plugin. Of course, we can't leave Scala/Lift out of the equation either. =)
  • If you are still hungry for more, you can attend Jason Cooper's App Engine 101 session on Sunday at 1:00pm.

SVCC Google App Engine: Java Runtime SVCC Google App Engine: Java Runtime Presentation Transcript

  • Google App Engine: Java Runtime
    • Michael "Van" Riper
    • Silicon Valley Code Camp
    • October 3, 2009
    • Kritter
    • a twitter bot written in Java
    • and deployed on App Engine
  • Google App Engine: Java Runtime
    • Kritter Demo
    • Follow @KrillionKritter
    • Two minutes later, check messages
    • d krillionkritter u 883974183913 94041
    • One minute later, check messages
  • Google App Engine: Java Runtime
    • Caveats
    • I am a neophyte Eclipse user =)
    • No Google Web Toolkit coverage
    • Dependency on Twitter service
  • Google App Engine: Java Runtime
    • Getting Started
    • App Engine Docs code.google.com/appengine/
    • Kritter Source Code code.google.com/p/kritter/
    • Twitter4J Project j.mp/twitter4j
  • Google App Engine: Java Runtime
    • WEB-INF Configuration
    • appengine.xml
    • logging.properties
    • web.xml
    • queue.xml
    • cron.xml
  • Google App Engine: Java Runtime
    • META-INF Configuration
    • jdoconfig.xml
    • Kritter Server Configuration
    • kritter.properties
  • Google App Engine: Java Runtime
    • FollowerServlet
    • Test manually first
    • Automate with cron job later on
    • Uses Datastore to save cron state
    • Uses “followers” Task Queue
  • Google App Engine: Java Runtime
    • FollowerWorkerServlet
    • Handles “followers” Task Queue
    • Saves new “friends” in Datastore
  • Google App Engine: Java Runtime
    • MessageServlet
    • Test manually first
    • Automate with cron job later on
    • Uses Datastore to save cron state
    • Uses “messages” Task Queue
  • Google App Engine: Java Runtime
    • MessageWorkerServlet
    • Handles “messages” Task Queue
    • Saves new “replies” in Datastore
  • Google App Engine: Java Runtime
    • Datastore: Why I Chose JDO
    • Better documented: Using JDO with App Engine
    • Nice default JDO Support in Eclipse
    • Datastore: PMF
    • PersistenceManager Singleton
  • Google App Engine: Java Runtime
    • Datastore: FollowerStat
    • Used by FollowerServlet
    • Stores new follower history
    • Datastore: MessageStat
    • Used by MessageServlet
    • Stores new message history
  • Google App Engine: Java Runtime
    • Datastore: Friend
    • Used by FollowerWorkerServlet
    • Stores friends and their preferences
    • Datastore: Reply
    • Used by MessageWorkerServlet
    • Stores messages and replies
  • Google App Engine: Java Runtime
    • Deploy & Monitor
    • Local vs Remote Deployment
    • appengine.google.com
      • Versions
      • Logs
      • Cron Jobs
      • Task Queue
      • Data Viewer
      • Quota Details
  • Google App Engine: Java Runtime
    • Kritter: Unfinished Business
    • Securing URLs for Cron Jobs
    • Add GWT sample code
    • Add proper command parser
    • Documentation
  • Google App Engine: Java Runtime
    • Additional Resources
    • Building Scalable, Complex Apps
    • Rick Hightower on developerWorks
    • Gaelyk, a Groovy Toolkit
    • Scala on Google App Engine
  • Google App Engine: Java Runtime
    • That's All Folks
    • Questions?