Introduction for Developers

This introductory walkthrough demonstrates using Monterey with a Spring project and deploying the application to Amazon EC2 using Eclipse/STS.  The process is very similar if you use another toolchain and CDI scheme, or none at all, so this gives a good overview of how to use Monterey, regardless of your peccadillos.

[ This documentation is for Monterey V3. This is not the Quickstart for Monterey Version 4 (Actor-Router)]

If you’re a developer using the Spring Framework and the many tools in its ecosystem, you’re probably familiar with writing code like this:

interface implementation

You have an interface, and an implementation. When you’re writing code that wants to record information about comic books, you code against the interface, and with a little help from some Spring wiring, your code will automatically run against the right implementation.

There are lots of advantages to coding this way: you can change the implementation without changing code; you can replace the implementation with stubs to help with unit testing; you can use a simplified implementation while developing to avoid having to setup an SQL database or other heavyweight dependency – but you know all these reasons already.

One of the big advantages when coding like this is that you can now put your code as a service on a different machine: you code a new implementation of the interface that turns method calls into remote server invocations. On the server you have something that listens for invocations and calls methods on the real implementation, and sends responses back. Again, nothing surprising about this: it’s a staple of multi-tier architecture, and there are countless implementations out there, from SunRPC, through CORBA and SOAP, up to REST.

This is where Monterey Spring Edition comes in. Its crucial difference to all these others is that it supports intelligent application mobility, to move your services around. This key feature allows you to efficiently run your code in the cloud – scaling out to meet high demand when it’s needed, and scaling back to save costs when it’s not.

And you hardly need to change your code to take advantage of it.

That’s a big claim – so let’s prove it to you. We’ve got our interface; we’ve got a class that implements it. If you’ve installed Monterey Spring Edition into your SpringSource Tool Suite, you’ll have a new project type called Monterey Service Project. Making one looks a bit like this:

new project

When we click Finish, we have a pair of projects – one containing the interface, and one containing the implementation. This is our service: and it’s ready to be deployed to the cloud.

Open the new Clouds view, and add a new Amazon EC2 account:

cloud account

Create a new cloud environment using this account:

cloud environment

Drag-and-drop the projects into the Amazon Cloud Environment:

drag drop

After a short wait while Amazon starts its virtual machine, your new cloud network will appear in the Clouds view:

clouds view

From here you can launch a Monterey Management Console, and start adding some nodes to make a little cloud:

little cloud

Or, alternatively, add lots of nodes to make a bigger, global cloud:

big cloud

But normally you wouldn’t want to actually make a big cloud. Instead you would use Monterey’s policies to manage the network for you. These will respond to the demand for your service – when demand goes up, the policies will add more nodes to your cloud, so your service can meet demand without affecting performance. When demand drops, nodes are released so you’re not paying for unused computing power.

So far you’ve taken your service and put it in the cloud. That’s great, but how do your users then access the service?

Fortunately this is really easy too, because  everything is coded to an interface. Monterey will provide an implementation of your interface, which invisibly sends methods calls into your cloud and channels back the responses. Doing things in a Spring-like way, all you need to do is configure how to reach your cloud:

spring beans

Write your bean to take a service locator instance that Monterey provides, and start coding:

client code

This walkthrough has only just touched the surface of what you can do with Monterey.

If you haven’t already done so, download Monterey Developer Edition and try it out for yourself!

More resources are available at http://developers.cloudsoftcorp.com, including a video demonstration.