On 29 May 2008, at 00:18, Squarespace Services wrote:
> Carl Bourne <carl....@intellect.co.uk> (Unregistered) commented
> on AS3 AMQP Client: First Cut:
> However, I having problems trying to work out what you mean by this!
>
>> This means that you will have to run the code generation before
>> >you can
> compile the client. To do this, go to the top level of >the
> codegen project and
> run the main method of the CodeGenerator >class. This will
> generate all of the
> necessary AS3 source files >in the correct location for you.
>
> Do I do this from within FlexBuilder or do I need to comple the
> java class
> first? I checked out the test project but there was now reference
> to the
> CodeGenerator class.
>
> Could you provide a more detailed step by step guide that takes
> me through
> getting the test project up and running with FlexBuilder 3?
>
> I have RabbitMQ running on a dedicated server.
No, you don't need to do this anymore. Since I wrote the article
Alexey Slynko has contributed the ant script to build the swc in one
step.
Just go to the root directory and run the ant script, the default
target will generate all of the AS3 classes that you need in the right
place.
Once you have built the swc, you can just reference this from your FB
project as normal dependency.
If you want more detail, let me know.
HTH,
Ben
On 29 May 2008, at 13:16, carlskii wrote:
> I ran the ant script at that succesfully built the source code:
...
>
> I've downloaded the test project - could you tell me what I need to do
> now! I have FB 3 installed.
I've attached a screenshot of the properties for the test project.
All of the source code should be under the src directory
(including .as and .mxml files).
The test project has 3 dependencies:
1. as3ds
2. flexunit
3. the core as3amqp library
1 and 2 are in the lib directory that you've downloaded. Just go into
the Properties of the project, click on Flex Build Path and then on
"Add SWC Folder" to add the lib directory. After doing that you should
see something similar to the screenshot.
3 you can get 2 ways. Because I develop on the core and the test, I've
got both projects in FB. So therefore I just define a project
dependency (Click on the "Add Project" button). But if you've already
built the core from the ant script, you can just click on "Add SWC"
and choose the path to where you built it. Copying the swc to the lib
folder has the same effect.
After that, all dependencies should be fulfilled and you should be
able to run the tests.
HTH,
Ben
On 29 May 2008, at 14:30, carlskii wrote:
> Noticed a few warnings in the console:-
>
> Severity and Description Path Resource Location Creation Time Id
> 1008: return value for function 'onCreationComplete' has no type
> declaration. as3-amqp/as3amqp-test-f4f4d1f7db06/src GetTest.mxml line
> 12 1212067003489 260
> 1008: return value for function 'onCreationComplete' has no type
> declaration. as3-amqp/as3amqp-test-f4f4d1f7db06/src LifecycleTest.mxml
> line 13 1212067008248 262
> 1008: return value for function 'onCreationComplete' has no type
> declaration. as3-amqp/as3amqp-test-f4f4d1f7db06/src
> PublishSubscribeTest.mxml line 13 1212067001416 258
> 1008: return value for function 'onCreationComplete' has no type
> declaration. as3-amqp/as3amqp-test-f4f4d1f7db06/src TLSTest.mxml line
> 12 1212067006142 261
> 3596: Duplicate variable definition. as3-amqp/as3amqp-test-
> f4f4d1f7db06/src/org/amqp/test PublishSubscribeTest.as line 73
> 1212067001693 259
Being the dynamic language that it is, AS3 lets you get away with
this, but I will tighten this up and push that back down to the
repository (which is where I assume you got the code from). Thanks for
the heads up.
> I assume I need to edit the AbstractTest.as file to reflect the
> hostname/IP address of my RabbitMQ server?
>
The server parameters are set in the buildConnectionState() function,
which can be overridden in a subclass instead of changing it in the
superclass.
This article ( http://hopper.squarespace.com/blog/2008/5/22/pet-store-part-1.html
) shows you how to do things even easier using dependency injection
a la Spring.
For real work you might want to look at this to reduce the amount of
LOC in your client.
> After doing this the flex applications run and I get a green bar that
> says "Running". The "All Tests" tab say Pass:
>
> Should there be some mechanism to start/stop the tests and view the
> results?
No, that's it really. The tests are real tests, i.e. I use them to
verify the functioning of the library when I refactor things, so by
having them pass shows me that the core functionality is not broken.
They are not very interesting from an application perspective, but
they do show you how to use the API.
As I said before, you might want to look at that other article to see
a more high level view of the API.
Furthermore, as I wrote in the first article, the library is pretty
low level, which is where you have to start I guess. I've been
thinking about introducing a higher layer, but I was waiting for some
input from the community as to how they may like to see this.
> I'm looking to get a simple sender/reciever application running (AKA
> chat type application) to demonstrate to my management!
This is certainly possible. After you've set the client with an
exchange and have some queues, it's just a case of starting a consumer
to receive messages and using the publish command to send data. It's
all just AMQP.
If you want some more detail, just let me know.
HTH,
Ben
On 29 May 2008, at 17:13, carlskii wrote:
>> If you want some more detail, just let me know.
>
> Details of a simple publish/subscribe usage from within FB would be
> very helpful. Better still, a simple working example using the higher
> level API you mention would be very much appreciated.
The high level API does not exist yet :-(
I was talking about the possibility of a high level API, perhaps along
the lines of a template like in Spring, but I wanted to get some
feedback from the community first about how they would like it to work.
For now, there is only the standard API.
If you want to send a message, this is how you do it:
var publish:Publish = new Publish();
publish.exchange = x;
publish.routingkey = routing_key;
var props:BasicProperties = Properties.getBasicProperties();
var cmd:Command = new Command(publish, props, data);
sessionHandler.dispatch(cmd);
If you want to receive a message asynchronously via a subscription,
this is how you can do it (MyBasicConsumer is obviously a non-existent
implementation of the BasicConsumer interface - this would be
application specific):
var consumer:BasicConsumer = new MyBasicConsumer();
var consume:Consume = new Consume();
consume.queue = q;
consume.noack = true;
sessionHandler.register(consume, consumer);
The reason why I wrote the Pet Store application is to give somebody
an example of a real application that has a high level interface to
AMQP. This is using asynchronous RPC over AMQP. However, this is only
one variant of an abstraction around the core API and doesn't really
cover pub/sub semantics for the application (although under the covers
it is using pub/sub to get the data back and forth).
Writing a pub/sub tutorial/abstraction is on my TODO list, but I'm not
quite there yet :-(
For now, I would just use the core API as indicated above. It's simple
enough to get going with.
HTH,
Ben
On 29 May 2008, at 23:10, carlskii wrote:
> I'm trying to work through this article but have hit a bit of a
> blocker at the rabbitmq-erlang-client part.
>
> This is what I've done so far:-
>
> I'm running on Ubuntu 8.0.4
>
> 1. Installed RabbitMQ via the rabbit APT repository (I think this
> installed Erlang/OTP) - Server starts and runs perfectly
> 2. Downloaded the Erlang client for AMQP
> 3. Downloaded the Cotton Erlang library, version 0.3.3
> 4. Downloaded the cotton-over-amqp source (hg clone
> http://freehg.org/u/0x6e6562/cotton-over-amqp/)
>
> So I think I now have all the pre-reqs?
That's all correct.
>> When you have OTP and RabbitMQ installed, you can compile and link
>> both the AMQP client and Cotton libraries to the lib directory of
>> your OTP installation. To >do this, unpack both packages and run
>> the make command inside the respective root directories. This will
>> compile the source code.
>
> When I run the make command in the rabbit-erlang-client I get the
> following error:-
>
> mkdir -p ebin
> erlc +debug_info -I include -o ebin -W0 src/*.erl
> src/direct_client_test.erl:33: can't find include lib "eunit/include/
> eunit.hrl"
> src/direct_client_test.erl:54: function test/0 undefined
> src/direct_client_test.erl:60: function test/0 undefined
> make: *** [compile] Error 1
>
You don't have eunit installed. This is the same problem as the
undefined macros below. I've been meaning to tweak the makefile so
that it only compiles the tests depending on whether you have eunit
installed or not.
However, until then, the easiest way to get around this is to install
eunit:
1. svn co http://svn.process-one.net/contribs/trunk/eunit eunit
2. cd eunit && make
3. which erl ( This will return PATH_TO_OTP/bin/erl )
4. cd $PATH_TO_OTP/lib/erlang/lib
5. ln -shf PATH_TO_EUNIT eunit-2.0
There's a couple of projects going on to solve cross module
dependencies in Erlang, so it would be good to look into them to avoid
having to do all of this.
See step 3 above.
> What paltform did you use when you built this?
OSX 10.5.3, but your problem is simple - see above.
HTH,
Ben
This looks like an old bug in the Erlang AMQP client. What version of
the client did you download?
Ben
On 30 May 2008, at 12:08, carlskii wrote:
> Ben,
>
> OK - Sorry I lied in the last post - I actually used the latest
> snapshot from RabbitMQ
....
> So on to the AS3 client - hopefully this will go a little more
> smoothly.
Cool.
This was the point I was trying to make about dependency management in
Erlang.
It would be nice to have something like maven for Erlang, so that an
end user doesn't need to worry about all of the plumbing.
Ben
On 3 Jun 2008, at 11:26, carlskii wrote:
>
> 1. The main project - i.e. the one the screen shot was taken from
> 2. cotton_over_amqp - added to the library path
> 3. cotton - added to the library path
Sometimes the transitive dependencies are not not resolved as you may
have expected in FB.
However, when you know what the dependencies actually are, it's not
difficult to tell FB this.
1. Your test project depends on the cotton_over_amqp library.
2. cotton_over_amqp depends on
a) cotton
b) as3amqp
So all of this must be on the library path. *Sometimes* FB does this
all automatically, sometimes not, I haven't figured out why and how yet.
In terms of the easy of setting paths and test directories FB leaves a
lot to be desired IMHO, which is the reason why you need a separate
test project in the first place.
If FB were a little more flexible in this respect, this would all be
less confusing.
HTH,
Ben
Sorry for the delay, I've had a keyboard failure on the laptop where I
have FB installed :
Before I can get round to doing this, probably the quickest solution
is to go into the properties of your test project and add every single
other project in FB as a dependency to the build path (it's under
Build Path/Add Project IIRC).
HTH,
Ben