It seems there is some kind of TCP buffering issue (only on linux?) which causes loooong delays when sending certain size messages over ActiveMQ. This was discussed and supposedly fixed in the past (e.g. here: https://issues.apache.org/jira/browse/AMQ-1156) but at least with the PHP Stomp library the problem still persists. Sending messages of 800 bytes or 20 kB works fine and fast, but sending a message of 805 bytes or a couple kB gets delayed and takes 60 seconds. (This is with default Stomp configuration for ActiveMQ on Ubuntu Maverick with a 2.6.35-23-generic kernel.)
The messages arrive on ActiveMQ according to the console, but somehow they don't get sent to the waiting client until a 60 second delay expires.
I modified the Stomp library to use socket_create style sockets rather than fsockopen, and then I added support for the URL argument to turn off the TCP delay, which I supposed was the issue. (e.g. example.com:61613?tcpNoDelay=true
as is supported by openwire) With this patch the bug is gone and I now have full speed messaging with all message sizes. Oddly enough, I've found that it doesn't matter whether the tcpNoDelay option is set or not. Somehow moving to the socket_create style sockets fixes the issue, so maybe using fsockopen, fread and fwrite uses a different underlying sub-system or different default options for buffering or something?
Attached is the modified Stomp.php file from the stomp library downloaded here:
I think the maintainers of the library are probably on this list. I tried logging in to post a bug on the Stomp issue tracker but I don't have a login, so instead I'll leave it here for others to find and hopefully a maintainer to pickup.
Note that some hosting parties don't allow socket_create because they don't want to let you listen on a socket. This might have been why fsockopen was used in the first place...