Mach II 1.6 - Message Subscribing for cfthread-ing

The past week or so I've been upgrading an app to Mach II version 1.6 and CF 8. The first task was to take advantage of cfthread for some auditing. Basically just like a hit counter we have an audit filter that logs when certain events are requested. This writes a record to the db and can easily be handled by a new thread since nothing after it is dependent on its completion.

To use cfthread I decided to try out the Publish-Subscribe Listener Method Invocation. It was easy enough to convert the filter to a listener by just changing some of the parameter references to event arg references. I then added a new <message-subscriber> block to replace the <filter>. Within that I specified multithreaded="true" and waitForThreads="false".

Then, in the events that previously had a <filter name="audit"> reference I changed that to <publish message="audit">. Any parameters that used to be sent to the filter via the <parameter> command can easily be changed to <event-arg> so the new listener can access it.

 

And that was all it took to take advantage of some threading. I didn't even have to learn the syntax and usage of cfthread. Maybe this is good, maybe not. I did look at how the Mach-II core files were doing it though, just out of curiousity.

Team Mach-II did a good job of wrapping up that functionality so that it can be used by other parts of the framework when appropriate.

I hope to blog some more about some of Mach-II's new features. I've also been trying to help out with some docs on the wiki, so check it out when you're ready for the new version.

0 Comments  |  CF General, Mach II  |  Send
Posted 6/16/08 @ 5:41 PM by Matt Williams