Archive for November, 2007

new face of cogent …

Sunday, November 25th, 2007

Cogent Consulting have a redone their web site and it’s very nice. Take a moment to have a look at it and the manifesto page. I have worked with Steve Hayes and many of the other Cogent people and they are a great bunch who do what they do *very* well.

http://www.cogentconsulting.com.au/index.html

thank you nett#

Saturday, November 24th, 2007

I received a new magazine in the mail today called “Nett#, Take your business further online.” and I can’t remember ordering it and I certainly didn’t pay for it. If one of you reading this organized this magazine for me, then thank you. If you didn’t organize the magazine, thank you anyway for coming back here and listening to what I have to say.

The initial issue of Nett# has some interesting content, like 137 Great Ideas to improve your workday, Free $50 google adwords, 73 website tricks and a good cover story on Dare Jennings the founder of Mambo.

If I get another issue for free then I may consider subscribing. :)

Thank you again for reading my blog.

a holiday on facebook and recomfriend …

Tuesday, November 20th, 2007

I’m on holidays from Aegeon for a week and so I thought I would do what I like to do when I am relaxing, and that is to write some code.

I created a little facebook application called recomfriend, which will show recommendations from friends and enable you to share recommendations with them. For example, if you saw a movie, or you went to a restaurant, and you think a friend would like them, then maybe you can write a recommendation so your friends can make more informed choices. You can also ask for a recommendation for an activity, but your friends need to opt into this, so you can’t spam them.

It’s early days for the app, and if you want a particular feature then email me on facebook.

These are a couple of tutorials I followed to get started:

http://services.tucows.com/developers/2007/07/25/getting-started-with-facebook-application-development/

http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails

http://developers.facebook.com/step_by_step.php

Sign up for the Melbourne Grooy User Group

Saturday, November 10th, 2007




alt=”Click here to join groovy-melbourne”>
Click to join groovy-melbourne

synchronous JMS messaging with Spring …

Saturday, November 10th, 2007

My current work involves messaging and I have been working with Spring and JMS (ActiveMQ), which is a great combination, especially since you can make Message Driven Pojos (MDP).

In most cases I try to make interactions between components asynchronous, where a request is sent and a response is not immediately expected, but dealt with later, possibly by another component. However, there are situations where this isn’t desired and you need to be able to send a request and wait for the response before continuing.

Spring provides an excellent facility for this with it’s JMS remoting, but in my case I couldn’t use this because non-spring based components need to send requests. I didn’t find a way to achieve this out of the box with Spring so I had to write something to do the job. This is the code:

public Object convertAndSendAndReceiveAndConvert(Object request) {
    final String uuid = UUID.randomUUID().toString();
    convertAndSend(request, new MessagePostProcessor() {
        public Message postProcessMessage(Message message) throws JMSException {
            message.setJMSCorrelationID(uuid);
            return message;
        }
    });
    return receiveSelectedAndConvert(getReplyFromDestination(),
             "JMSCorrelationID='" + uuid + "'");
}

I put this code into my own subclass of JmsTemplate so the calling code can just call convertAndSendAndReceiveAndConvert(). I also added some properties to the JmsTemplate subclass to define the reply queue. The Spring definition of the template looks like this:
(I’m wrestling with my blog editor and have removed some XML characters, but I’m sure you get the gist.)

bean id="doSomethingSynchronousJmsTemplate" class="MyJmsTemplate"
    property name="connectionFactory" ref="connectionFactory"
    property name="defaultDestination" ref="requestQueue"
    property name="replyFromDestination" ref="replyQueue"
    property name="messageConverter" ref="xmlMessageConverter"
    property name="receiveTimeout" value="5"

I’m using a queue for requests and a queue for responses which “feels” right when considered against a temporary queue for this situation.
The calling code is much the same as other JmsTemplate usages:

    return (reply) _synchronousJmsTemplate
                     .convertAndSendAndReceiveAndConvert(request);

I’m converting the Request and Response objects using XStream in a custom MessageConverter subclass. This allows the receiving components to accept XML requests from any sender. As long as they conform the the XML wire format.

All is working nicely, and I hope this post helps you.

mule jms example …

Wednesday, November 7th, 2007

I have been spiking a Mule example for a couple of days and it has been a little frustrating, since the documentation is there but it is hard to put all the pieces together. I find it strange that there isn’t an example of using JMS with Mule to download and therefore I am publishing what I have so far, which works. I did get a lot of help from Andrew Perepelytsya in the Nabble forum, although I probably frustrated him a lot.

My example has a unit test that uses the Mule client to send a request to an end-point. The Mule server is running in a separate JVM to the unit test, so I use the remote dispatcher and a sendRemote() call. The JMS implementation I am using is Activemq. Both Mule and Activemq are used out of the box and I have not modified any configuration files. I simply run activemq in an xterm and Mule in another. When running Mule I specify the config on the command line, using the -config flag. eg: mule -config my-config.xml

My goal was to have the unit test send a message via Mule and have the standard Mule EchoComponent echo it back, allowing me to see that the replyTo synchronous facilities I need are catered for. I plan to expand on this and have a component of my own receive the message and act upon it.

I have chosen to run the Mule Server and Activemq as separate servers, but this may not be optimal and I’ll be looking into the various arrangements available to the developer. It appears likely that Mule will be embedded into the application.

Here is what the unit test looks like:

 @Test
 public void shouldBeAbleToSendAndReceiveFromEchoComponent() throws Exception {
    String expectedMessage = "this is the response I expect to be echoed.";
    MuleClient client = new MuleClient();
    RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:60504");
    UMOMessage message = dispatcher.sendRemote("jms://echoin", expectedMessage, null);
    assertNotNull("Dispatcher response message is unexpectedly NULL.", message);
    assertEquals("Response message not as expected.", expectedMessage, message.getPayloadAsString());
 }

You can download the working project here: mule-jms-echo-example

Stay tuned for an expanded example.