In this mini-tutorial we make use of Adobe AIR and Amazon Web Services to create a bare-bones desktop visualization application which is connected to the cloud. This combines two technologies that I’m very excited about, Adobe Flex and AWS. Adobe Flex allows you to create professional dynamic visualizations and GUIs while AWS lends serious computational resources behind them.
- Project Files – The Adobe AIR + Tomcat Server Project for this post.
Setting Up the Server
This mini-tutorial is meant to get you started on the AWS side of things. I’m assuming that you’re new to AWS (like me at this point). I’m assuming that you’re somewhat familiar with setting up an Adobe Flex/Air application using Tomcat and BlazeDS to serve remote objects. If not check out these tutorials:
- Getting Started with Blaze DS from the Adobe Developer Connection
- BlazeDS with Remote Objects example on the Code of Doom website.
I have included a zip file of my AIR application and Tomcat server project, which are ready to run out of the box. Just import into Eclipse and make sure to set up the correct preferences: I’m using Flex SDK 4.1 with AIR 1.5, and Tomcat 7.
If you haven’t done so already, go to the AWS website and sign up for the service. Check out the EC2 Getting Started Guide to get you familiar with creating a new AMI server instance, and accessing the server from a shell.
To get started, create a new instance of a Basic 64-bit Amazon Linux AMI (Note: Don’t select the Micro, free-tier eligible instance, it’s too restrictive.) When you get to the Configure Firewall page, create a new security group that allows access to ports 8080, 22, 80, and 53.
Now go to the Elastic IP section in your Amazon EC2 dashboard. Allocate a new address and associate it with your new server instance.
Finally create a terminal session and ssh into your new instance as ec2-user (If you have problems logging in, use the public DNS address as specified in the getting started guide, not your elastic IP address.)
Now we must install Tomcat on our new instance. To do this, I followed the instructions in Setting Up EC2 for Tomcat, loosely. I downloaded Tomcat 7 and unpacked the tarball into my /opt/tomcat/ directory. The AMI that I chose had a JRE already built in, so I didn’t have to install that. At this point you can run Tomcat by executing the startup.sh script. Now if you open up a web browser and go to http://<your_elastic_ip_address>:8080/ You should see the tomcat splash page. This means you are successfully interacting with your server on the cloud.
Installing the Application
Fire up Eclipse. In your settings, make sure to set up the Flex SDK (I’m using Flex SDK 4.1 with AIR 1.5), the JRE and the server runtime environment for Tomcat 7.
Setup the Backend
Use the Import Existing Projects tool to import the projects from the application package I created. You should import 3 projects: CouldApp, FeatureService and Servers.
Next, set up a new server in Eclipse for the Feature Service project. To do this, open up the Servers view. Do a right click -> new Server, then define a new server using Tomcat 7 as the server type. Click next then add the Feature Service project into the server. Click Finish.
Double click the Tomcat v7.0 Server in the Server view to bring up the Overview page. Select the “Publish module contexts to separate XML files”. Save it and start the server.
Now copy the the FeatureService build from your local machine into the tomcat directory onto the server. The FeatureService build can be found in <eclipse_workspace_root>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/FeatureService. Copy this directory into the the webapps directory under the tomcat installation on your server. For example on my host this directory is /opt/tomcat/apache-tomcat-7.0.11/webapps. Now restart Tomcat.
Setup the Air App
At this point the backend is fully configured. Now you need to tell your AIR app where your Tomcat server is. For the purposes of this example open up _Super_FeatureService.as and modify the _serviceControl.endpoint object to point to the Tomcat instance on the cloud ( _serviceControl.endpoint = "http://<your_elastic_ip>:8080/FeatureService/messagebroker/amf". )
You are set. Build the AIR app and launch it. If all works correctly you should see a screen showing two point clouds. This data is coming to you from the Cloud!
At this point the bare-bones framework is in place from which you can begin to explore extensions to the application. Here’s a few things that are on my wish list, you want to play around with them too…
- Set up a MySQL Server to provide data,
- Use the Cloud Front services to be able to deploy my server configuration automatically
- Use auto scaling capabilities to replicate servers as demand increases
- Use Elastic Map reduce to implement a distributed clustering algorithm.