Thursday, February 7, 2013

HazelcastMQ Stompee Now Available

After implementing Stomper, the Java STOMP server, I wanted an easy way to test it and demonstrate its functionality. As of today, Stompee, the Java STOMP client is available at GitHub. Stompee is a generic STOMP client, and therefore should work with any STOMP server, but was designed and tested against Stomper.

In most cases, you're probably better off just using the HazelcastMQ JMS APIs rather than using Stompee, but there may be some cases where you want all your components, regardless of language, using STOMP for message passing.

While working on Stompee, I found and fixed a couple of bugs in HazelcastMQ. Most importantly, I switched the queue MessageConsumer implementation from listening to Hazelcast events to using a separate polling thread. This should result in better performance and handle the case were messages queued before the consumer started are properly consumed immediately.

I added a few new examples in the hazelcastmq-examples module that demonstrates how to use Stomper, Stompee, and the JMS APIs together. At this point I'm ready to begin some serious production testing and push for a 1.0 release. Let me know what you think.

Sunday, February 3, 2013

Patio Bench Project Complete

I took a small break from coding this weekend and spent some time in the workshop. I completed my first large project, a patio bench, using the plans from Woodworking for Mere Mortals. I ran into a few issues with incorrect measurements in the published cut list but overall it was a fun and pretty easy project. Now I just need to wait for the temperature to get above freezing for a few days so I can drag it outside and get it painted.


I'm already on to building a table saw sled to fix the fact that my cheap fence is always out of square. I also owe a few people some children's toys for gifts but after that I'll be looking for my next large project. I'm thinking maybe a name puzzle step stool for my daughter.

HazelcastMQ Stomper Now Available

As I mentioned in a previous post, to completely move off of ActiveMQ as my message broker, I would need a messaging solution for some of the C and C++ components in my system. Currently these components use the STOMP interface exposed by the ActiveMQ broker. After getting the initial version of HazelcastMQ pushed to GitHub, I started working on a STOMP server implementation. Today I'm happy to announce that the first cut at the server is now also available in GitHub as HazelcastMQ Stomper.

Stomper is implemented as a layer on HazelcastMQ so it uses all the standard JMS components for message sending and receiving. Using the JMS components allows a STOMP client to easily interact with JMS clients creating a language agnostic messaging solution on Hazelcast. While Stomper was written and tested with HazelcastMQ JMS components, it should work with any JMS provider if you wanted to use it as a generic STOMP server implementation. You can also use Stomper's STOMP server without dealing with any of the JMS APIs other than creating the initial connection factory.

With Stomper and HazelcastMQ you can now send a message to a queue or topic via the STOMP API and receive it via the JMS API (all on a distributed cluster of Hazelcast nodes). The same works in the opposite direction. This is extremely useful in a mixed language environment where Python, Ruby, C, or C++ components need to interact with Java components without having to implement a custom message passing solution.

Check out the examples in the hazelcastmq-examples module and give it a try. The next step is to write a simple STOMP client (to be named HazelcastMQ Stompee) which will allow me to write some simple producer/consumer examples using just the STOMP API (i.e. no direct JMS interaction).

Thursday, January 24, 2013

HazelcastMQ Code Available

I setup a GitHub repository for my HazelcastMQ implementation. The README contains a list of what I have working and what still needs to be done. I plan on throwing a few more hours at it this week to try to get a few more features in there soon.

Tuesday, January 22, 2013

Hazelcast JMS Provider

I'm currently using Apache ActiveMQ on a project in a "network of brokers" configuration with Apache Camel used to implement the enterprise integration patterns. From a development point of view, you work with a Camel generated proxy and setup routes to transform dispatch, and receive messages. This hides all the Java Messaging Service (JMS) complexities behind Camel's JMS (or ActiveMQ) components. My system primarily uses this setup for low volume, asynchronous work requests or RPC request/reply operations.

For the most part things work well but it has been a constant fight trying to get a stable system. The issues range from configuration complexity, network instability, deployment requirements, and just plain old bugs. Both ActiveMQ and Camel have a rather large set of dependencies and properly configuring a JMS broker and clients is rather tricky. A small configuration issue can cause your system to slowly grind to halt (usually only under production loads)! While ActiveMQ is one of the easier brokers to configure and use (it has Spring namespace bindings and can be used without JNDI), I could still imaging a full time position for broker management, configuration, monitoring, etc.

On another part of the system I've been prototyping some distributed locking using Hazelcast, an in-memory data grid that implements Java's Map, List, Queue, and Lock interfaces. I've been extremely impressed with how easy it is to get a Hazelcast cluster up and running and the fact that it has few, if any dependencies is another plus. As a data grid, clustering is a first class citizen in Hazelcast unlike a lot of JMS brokers which use a hub and spoke pattern with a "network of brokers" as a bit of an after thought for high availability.

While working on the project, I got to thinking about switching out the ActiveMQ broker with Hazelcast using queues and topics. There are a number of pros and cons to consider:

Pros
  • I'm looking to use it for distributed locks so I could remove a dependency on ActiveMQ/JMS by using it for both locks and messages
  • It is designed from the ground up for clustering and data distribution while clustering is a bit of an add-on for ActiveMQ (and other MQs)
  • It is much simpler to configure and support than a JMS serves
  • It has built in support for distributed queues
  • I could leverage it in the future as a distributed cache
  • I could continue to hide it behind Camel so there would be little to no code change in my code
Cons
  • The distributed queues are in memory in Hazelcast so messages would be lost if all nodes went down (it should survive any single node failure). That being said, my queues are empty 95% of the time because the messages are consumed quickly. Hazelcast also has persistence support for maps which I believe back the queue implementation so some form of persistence may be possible.
  • It exposes a custom REST API but not a generic STOMP API so I would need to either implement a STOMP server or rewrite some of our existing non-Java code that uses the STOMP interface on ActiveMQ
  • Camel has basic Hazelcast support (as a cache) but I would need to write some non-trivial code to support message marshaling and transaction management
  • Performance is a bit of an unknown. There are performance numbers for raw distributed map read/writes but not so much as a message passing system. That being said, I have very low performance requirements for the bus (10s - 100s of messages a second but not much more than that).
I first played around with writing a custom Apache Camel component but it quickly got complicated. Handling request/reply patterns with asynchronous clients isn't simple and properly using the internal Camel APIs definitely has a learning curve. That's when I got the idea to simply reuse Camel's JMS component and write a JMS provider for Hazelcast. The JMS APIs are well documented and relatively simple to understand.

After a day or so of work I have a simple, working implementation of a JMS provider on top Hazelcast which supports message producers and consumers on topics, queues, and temporary queues. I was even able to swap out the ActiveMQ ConnectionFactory for my HazelcastMQ ConnectionFactory with no code changes in my application. So far things are looking promising. The big advantage of implementing the JMS APIs is that it "just works" with Apache Camel, the Spring JmsTemplate API, or other JMS consumer.

There are some limitations that I don't have a good solution for yet. For example, implementing consumer message selectors isn't an option with Hazelcast queues (although they do support them with maps). Also, some of the JMS options like message persistence can't be honored because persistence would be all or nothing configured within Hazelcast. I'm hoping I can continue to work around these issues to support the majority of common usage patterns.

I'll post again soon with some more examples and hopefully I'll have the code available shortly if there is interest.

Thursday, October 7, 2010

Lemmings iPhone Wallpaper

Look at me... I get a little free time and what do I do? I created a Lemmings wallpaper/background for the iPhone. I was inspired by the Pacman wallpaper I saw the other day and the lemmings sprite sheet made it all possible. A whole bunch of copy and pasting and a little resizing/flipping magic and presto, a fun retro wallpaper. Enjoy!

From Mike's Life, Work, and Everything Inbetween


From Mike's Life, Work, and Everything Inbetween

Sunday, May 9, 2010

NetBIOS Strikes Again

After two weeks of not being able to connect to my Windows Home Server from my Windows 7 laptop I think I finally tracked down the problem. I'm hoping I can save someone else a few hours (ok, days) trying to fix this issue.

First, the symptoms. At some point, seemingly randomly, my Windows 7 laptop could no longer connect to the Home Server using the machine name. So \\homestorage wouldn't work. Strangely, the IP address, or \\192.168.150.5 would work. Unfortunately, all my drive mappings and the windows home server console itself relied on the hostname. When trying to connect to \\homestorage, I would get a non-helpful error 0x80004005.

I had another Windows 7 machine on the network and it was still able to see the Home Server so I was pretty convinced that this wasn't a network issue or a Home Server issue but something specific to my laptop. To debug it, I checked that all the important services were running: Computer Browser, TCP/IP NetBIOS Helper, RPC, etc. I installed and uninstalled various network protocols including Client for MS Networks. I uninstalled any virtual NICs including VirtualBox. I stopped and started firewalls and virus software. I installed and watched MS NetMon. Finally I learned the wonders of nbtstat.

Using nbtstat -r, I saw that all the values were 0. Nothing was ever resolved by my machine and nothing ever registered. This seemed really strange and I could confirm with the other Win7 machine that it was resolving and registering with the same command. I also found that I could run nbtstat -a 192.168.150.5 and Win7 would find and cache the Home Server name. Using nbtstat -c, I could see the HOMESTORAGE machine name show up with a 600 second countdown. While the name was in cache, I could access the host without error; however once it dropped from the cache, I was back to square one.

Finally, after much comparing between the two Win7 machines, I noticed that the Node Type, listed with ipconfig /all was Hybrid on the working machine but Peer-Peer on my laptop. A little research and I determined that Peer-Peer didn't make sense because I don't have a WINS server on my home network. A little more research and I found out how to change it here:
http://technet.microsoft.com/en-us/library/cc781175%28WS.10%29.aspx

I edited the registry and set DhcpNodeType to a value of 8 (Hybrid), rebooted, and presto! Now nbtstat -r lists successful resolutions and registrations. I have no idea how the network stack got switched into peer-peer, but thankfully things seem to be working now.

Good luck!