Making a Wrapper class for ActiveMQ

Posted by DarthVader on Stack Overflow See other posts from Stack Overflow or by DarthVader
Published on 2011-11-15T00:01:25Z Indexed on 2011/11/15 1:50 UTC
Read the original article Hit count: 169

Filed under:
|
|
|

I want to make a Wrapper class for ActiveMQ which will have only send and get functions. I want to wrap them in a static class. Users can use this client and send, get messages to the activemq instance.

I want this process to be transparent. There are two classes in this link

My only handicap is, i need to this in c++ and not sure where to start. I havent used c++ for ages and now not sure how I can create this wrapper class.

I m giving it a try as follows:

// .h file
#include <stdlib.h>
#include <iostream>

using namespace std;

class ActiveMQWrapper
{
        public:
                static void send(std::string message);
                static std::string get();

};

// .cpp file
#include<string>
#include<iostream>

#include "ActiveMQWrapper.h"

void ActiveMQWrapper::send(std::string message){
        std::cout<<message;
}

std::string ActiveMQWrapper::get(){
        return "test";
}

// test file
#include <string>
#include <iostream>
#include "ActiveMQWrapper.h"


int main() {
        std::string foo ="test";
        ActiveMQWrapper::send(foo);
        std::cout<<ActiveMQWrapper::get();
        return 1;
}

When I added the following to .h file, hell breaks loose. Do you think I should seperate this impl to a factory and initialize and instance and return to the wrapper above? How do i deal with all the dependencies?

private:

    Connection* connection;
    Session* session;
    Destination* destination;
    MessageProducer* producer;
    int numMessages;
    bool useTopic;
    bool sessionTransacted;
    std::string brokerURI;

and the header files, i get several messages as errors, which complains about the path.

How can i get this correct? I eventually want to build a Factory, get an instance and send or get the messages to the queue.

is there a code sample i can look into to get this right? essential i want to use the functionality of only this producer and consumer.

Edit: I understand there is no such thing as static class in C++ . This is my reference.

© Stack Overflow or respective owner

Related posts about c++

Related posts about static