Simon Wistow (deflatermouse) wrote,
Simon Wistow

What I need is a good defence

So there's this thing called JMS which means Java Messaging Service which is

"... a messaging standard that allows application components based on the Java 2 Platform, Enterprise Edition (J2EE) to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous."

ActiveMQ is one implementation of this. It also adds some extensions and other jubbins.

JMS is, by it's very nature, Java based. Except that some bright spark defined a textual protocol to sit on top of it so that other, lesser languages can deign to speak unto the world of Java. This protocol is called Stomp (aka Streaming Text Orientated Messaging Protocol or The Protocol Briefly Known as TTMP).

There was a pretty un-Perlish stomp module available on the Stomp site but the ever wonderful and suspiciously productive Leon Brocard wrote Net::Stomp which is distinctly Perlish. When I wrote some interop tests the Perl code was far shorter and easier to understand than the Java version. This pleases me.

Incidentally, speed wise, the Perl Client was practically as fast as the Java Client when paired with a Java Message Consumer (between 3000-5000 messages a second depending on the load of my lappy). However with a Perl Message Consumer both were rock solid at 100 messages per second. Something is clearly "going on". Further bulletins as events warrant.

Aaaaaaaaaaaanyway ... so this Stomp thing. You may remember from previous diversions that JMS has the concept of Message Selectors - a subset of SQL-92 conditionals that allow you to pick and choose messages to look at.

Previously in Java world I'd been doing something like this in the client
    TextMessage message = new TextMessage();
    message.setIntProperty("year", 2006);   
    message.setIntProperty("month", 12);
    // ... etc etc ...

and then in the message consumer my message selector looks like
   (year=2006 OR year IS NULL) AND (month=12 OR month IS NULL) 

But when I was sending my Perl message it wasn't getting through. Until I got rid of the date esque properties on it or removed the message selector. Curious, I thought whilst sipping a cup of proper British tea, specially imported into the states to stop me from having to drink the pseudo-tea they have here. Most curious.

The answer, for thems that is curious, is that the message selector needs to be this
   (year='2006' OR year IS NULL) AND (month='12' OR month IS NULL) 

even though the Stomp message going out was

why? Buggered if I know. Presumably all Stomp message properties are assumed to be textual. Attempting to do

to force numeric context doesn't work and

gets an InvalidMessageSelector exception.

Ah well. I suspect I'm missing something but it all works for now so that makes me happy.

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.