Connecting Java applications with Blaze DS
Posted by cornel | Filed under Java, LCDS/Blaze DS
A new feature was added to Blaze DS (currently only in the nightly builds) – the ability to connect to a Blaze DS server from a Java client. It’s a useful feature if you have to do integration between some legacy Java application and a Blaze DS server and you don’t want to write your own serialization mechanism or if you plan to write some tools for testing.
The specification can be found here and I’ve also created a Hello world project which can be downloaded from this location. On my local computer I was able to do about 3000 calls per second – impressive compared with a WebService call.
On the client I wrote four lines of code in order to invoke the method from the server:
AMFConnection amfConnection = new AMFConnection();
amfConnection.connect(http://localhost:8080/blaze/messagebroker/amf);
Message message = (Message)amfConnection.call(“HelloService.sayHello”, new Message(“cornel”));
amfConnection.close();
And the method signature is:
public class HelloService {
public Message sayHello(Message message){
return new Message(“hello “+message.getText());
}
}
On the client you need to use two jar files from Blaze DS distribution (flex-messaging-common.jar and flex-messaging-core.jar).