talking stomp to apache camel with c
Tue, Jul 28, 2009
I’ve got an Apache Camel instance running with stomp listening for interesting things to happen and it works just fine from Ruby. But I need to read from a queue using C++ on Windows for GADfly. So I needed to build a C++ client in Visual Studio. To do that you need the following:
- Apache apr
- Apache apr-iconv
- Apache apr-util
Open APR_SRC_HOME/apr/apr.dsw, ignore any warnings about project stuff and build the entire solution.
Open APR_SRC_HOME/apr-iconv/apriconv.sln and build that
Open APR_SRC_HOME/apr-util/aprutil.sln. This might give you a load of messages. Just ignore them. Then remove all projects from the solution that are to do with database support. It’s much easier without them as they need extra dependencies which you don’t need for messaging. Once you’ve removed them build the entire solution.
If you have the above source layout in the correctly named directories each apr project will find what it needs from the other ones.
Now, download ActiveMQ CMS and unpack to CMS_SOURCE_HOME.
Open the file CMS_SOURCE_HOME/vs2005-build/vs2005-activemq-cpp.sln
Under Configuration Properties -> C++ -> General -> Additional Include Directories, add links to the apr and apr-util include directories:
The next step is to actually use the C++ CMS library. A quick way to test is to grab the CMS example code, which doesn’t work with the latest release of CMS but we’ll fix that.
Create a new project in STOMP_TEST_HOME, Win32 console application and copy/paste the example code into it.
Under Configuration Properties -> C++ -> General -> Additional Include Directories, add links to the apr and cms include directories:
#include <activemq/library/ActiveMQCPP.h>and add these lines to the main() code:
using namespace activemq::library; ActiveMQCPP::initializeLibrary();or you’ll just get this error when you run:
no matching factory registered for format := tcp
Build the project, then copy these files to the Debug directory (this is a quick way of getting the dependencies onto the path):