Flex AMQP Client: Technology Preview
This article demonstrates a proof-of-concept client for AMQP written in AS3, which has not yet been published as a formal library. The intention is to show what an AMQP wire client could look like and to gain feedback on its usefulness in providing AMQP connectivity for Flex applications.
This AS3 library will be of interest for those wanting to:
- Use AMQP-based messaging in a Flex or AS3 application;
- Provide a browser-based client that can connect to an AMQP server.
In this article I am going to describe the library and demonstrate its usage with a simple Flex project. To benefit from this article it is assumed that:
- You already have a grasp of the AMQP model;
- You have the Flexbuilder IDE installed, either version 2 or 3 and are comfortable using it;
- You can run an mvn-based Java project, either via a shell or from within your IDE;
- You have an installation of RabbitMQ server, version 1.2 or higher;
- You have the Java client library that accompanies the Rabbit server you are using.
To start off you need to download the example Flexbuilder project and extract it. This project contains only the src directory for a Flex client, it does not contain the Flexbuilder .project file, so you will need to create a new project based on the extracted directory in your workspace. This project depends on the amqp.swc library, so you need to download this and add it to the library path in your project preferences. At the moment this library also has a dependency on some utility classes provided by flexunit, so you will also have to put the flexunit swc onto the library path.
To kick the demonstration off, follow these steps:
- Make sure that Rabbit is running locally and that the default guest user is enabled;
- Run the amqp_example.mxml application from within Flexbuilder.
When you run the MXML application, the login screen will be displayed:

Entering the default user's name and password (guest/guest) will display the main screen.

So far so good, but we have not yet won any prizes for artistic genius. To get the client to do anything useful, you will require another AMQP peer that sends and receives messages to and from the exchange, so that it can interact with the Flex client. An example peer program that uses the Java client library that ships with Rabbit is supplied in the example Flexbuilder project that contains the Flex code.
The Java client example is housed in the ExampleMain class that resides in an mvn project in the Java subdirectory of the project. You can run the the ExampleMain class either from within your favorite IDE or just from the command line. Since a maven pom.xml file is supplied, it is your choice as to whether you want to generate an IDE project or simply build using the maven compile process. If you have never worked with maven, reading the Maven in 5 minutes tutorial would be time well spent.
When you run the ExampleMain class, it starts a separate writer thread that publishes random integers to a queue that the Flex client binds itself to as a consumer when you click on the 'Subscribe' button in the main screen. After you have subscribed the Flex client, it should begin to consume the messages produced by the Java client and update the UI control upon receiving each message.
The ExampleMain class also creates an AMQP consumer and registers this with the server, so that it receives messages destined for a second queue. When you enter a number into the 'publish text' field in the main screen of the UI and click on 'Publish', this message will be sent to the exchange and routed to the Java consumer. If this is successful, you should see the Flex UI being periodically updated by the messages produced in the Java writer thread. Also, when you publish your own numbers via the UI, you should see a similar log entry from the Java client:
[15:26:35] DEBUG [amqp.example.ExampleMain] -
Sucessfully connected to AMQP broker
[15:26:35] DEBUG [amqp.example.ExampleMain] -
Bound queue javainput to exchange using binding
java.input
[15:26:35] DEBUG [amqp.example.ExampleMain] -
Started reader: amq.ctag80_nonode@nohost_20080123184251_
[15:26:40] DEBUG [amqp.example.ExampleMain] -
Published message (122) using routing key: flex.input
[15:26:45] DEBUG [amqp.example.ExampleMain] -
Published message (25) using routing key: flex.input
[15:26:48] DEBUG [amqp.example.ExampleMain] -
dequeued: 4
[15:26:50] DEBUG [amqp.example.ExampleMain] -
Published message (104) using routing key: flex.input
[15:26:55] DEBUG [amqp.example.ExampleMain] -
Published message (181) using routing key: flex.input
In this example, you can see that the Java client produced the messages containing the random numbers 122, 25, 104 and 181. Also, the sixth log entry shows a message that it received from the Flex client.
That is about the extent of the functionality provided in this demonstration - to show how a program written in AS3 can talk to a Java program using AMQP in a bi-directional fashion. The purpose of this article is to demonstrate a simple integration scenario for a Flex AMQP client and to provide an example project to determine how this works from a code perspective.
In a follow up article I will go into more detail about the API that the client exposes and the way that the event handling framework in Flash is used to facilitate sending and receiving AMQP wire frames.
I have completely re-written the AMQP client library to make it as easy to use as possible. This article describes the first formal release of the library and demonstrates the basic usage.
References (3)
-
Response: evden eve nakliyeM?RO?LU EVDEN EVE NAKL?YAT, 22 y?ldan bu yana evden eve ta??mac?l?kta, ilk g�n�n heyecan? ile sizlere hizmet vermektedir.Sistemli �al??mas? ile hert�rl� ev ve ofis mobilyalar?n?z?, gidece?i yere hi�bir zarar g�ryece?i ?ekilde ta??r. -
Response: EVDEN EVE NAKLIYAT ISTANBULM?RO?LU EVDEN EVE NAKL?YAT, 22 y?ldan bu yana evden eve ta??mac?l?kta, ilk g�n�n heyecan? ile sizlere hizmet vermektedir.Sistemli �al??mas? ile hert�rl� ev ve ofis mobilyalar?n?z?, gidece?i yere hi�bir zarar g�ryece?i ?ekilde t... -
The first quarter of 2008 has seen the slowest traditional office space take up in London since the emergence of the corporate market in 2004. The traditional office space demand has significantly fallen as troubled sectors such as the banking industr...

Reader Comments (7)
Great post! I was actually just about to ask you a few questions about this client, but this post answered them all.
Thanks,
Derek Wischusen
very nice article.
good article.
ankara nakliyat
ankara nakliyat
nice article, really good informations! thx
very nice article
Very interesting and useful tips,
so many helpful informations include in this article!
Thanks for good items! This looks good! Excellent SITE.
Great post! I was actually just about to ask you a few questions about this client, but this post answered them all.Very interesting and useful tips,
so many helpful informations include in this article!
thx