I gave a talk back in October at Adobe MAX named “High-Performance Real-Time Messaging with Flex and LiveCycle Data Services” and I’ve been asked about the slide deck by a number of people since then. Sorry it took so long, but here it is, enjoy!
Not sure how many people know about this but most of BlazeDS/LCDS server classes are exposed as JMX MBeans which means they can be viewed with a JMX enabled client such as jconsole. Additionally, BlazeDS/LCDS comes with a simple application called ds-console that can be used to view these MBeans as well. These MBeans provide information about the state of the server such as number of Flex Sessions, number of Flex Clients, command counts, message counts, along with some performance related info. If you want to check it out yourself, here’s what you need to do.
First, you need to make sure manageable flag is set to true in services-config.xml (by default, it’s enabled). This makes sure MBeans are created and exposed via JMX server. You can turn off management if you don’t want your application to be available via JMX or for other reasons (eg. Goggle App Engine does not support JMX for example).
Then, you can start your application along with ds-console application. Ds-console has a few tabs but I think the “Generic Administration View” is the most useful one. It shows all the exposed MBeans in a tree like structure:
You don’t actually need ds-console to see these MBeans. You can use jconsole that comes with Java. Setup is pretty easy. As you first start your server, you need to make sure JMX is enabled. You can do this in a number of ways but one easy way to set the following Java option in the terminal and start the server.
Then, simply start jconsole from the terminal and attach to your server. You should see the same tree view in jconsole:
In couple posts back, I talked about using NetConnection to talk to a remoting destination in BlazeDS/LCDS. This helps for pure Flash clients talk to BlazeDS/LCDS but what if you have a Java client app and you want to do a remoting call from your Java app, is this possible? That’s when AMFConnection comes into play.
I created this nice little class in BlazeDS source tree a while back. It tries to mimic Flash’s NetConnection in Java (hence the name AMFConnection) and inspired by Peter Farland‘s AMFConnection. It uses BlazeDS’ AMF serializer/deserializer (which means you need flex-messaging-common.jar and flex-messaging-core.jar from BlazeDS in your classpath) and it can potentially be used from any Java code to serialize/deserialize AMF messages. Internally, Java’s HttpURLConnection is used to send/receive HTTP request/replies and can be used to perform remoting calls to BlazeDS, LCDS, or any other server technology that understands AMF from your Java client.
You would use AMFConnection pretty much like NetConnection. One notable difference is that calls are not asynchronous which makes sense for Java. Here’s a brief example:
// Create the AMF connection.
AMFConnection amfConnection = new AMFConnection();
// Connect to the remote url.
// Make a remoting call and retrieve the result.
Object result = amfConnection.call("remoting_AMF.echo", "Hello World!");
catch (ClientStatusException cse)
// Handle exception.
catch (ServerStatusException sse)
// Handle exception.
// Close the connection.
A full example can be found in this JUnit test in BlazeDS source tree.