Log in

No account? Create an account

Tue, Dec. 19th, 2006, 11:58 am
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.

Thu, Dec. 21st, 2006 10:12 am (UTC)
cudddly: Speed

Did you up the activemq.prefetchSize to 100 or so?

Mon, Dec. 25th, 2006 01:03 am (UTC)

How very Dentesque. Or Dentist?

Sun, Feb. 14th, 2010 06:47 pm (UTC)
(Anonymous): explanation to your question

well, seems that this is already 4 years after you asked...

Selection has to be formulated as SQL92. The JMS interface separates the int and string properties. So when you get a message there is a clear distinction if a property is a string or number. Therefore you can write year=2006

Stop is textual. There is nothing like setIntProperty. Therefore it is only proper to check year='2006'. Because that is a string property when sent or received by stomp.

That is the story.