-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsumer.cpp
47 lines (34 loc) · 1.19 KB
/
consumer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Created on 11/29/16.
//
#include <stdio.h>
#include <string>
#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/core/ActiveMQConnection.h>
#include <activemq/transport/DefaultTransportListener.h>
#include <activemq/library/ActiveMQCPP.h>
using namespace activemq;
using namespace activemq::core;
using namespace activemq::transport;
using namespace cms;
using namespace std;
int main (int argc, char **argv)
{
string brokerURI = "tcp://127.0.0.1:61616";
string dest = "cppQueue";
activemq::library::ActiveMQCPP::initializeLibrary();
ActiveMQConnectionFactory* connectionFactory = new ActiveMQConnectionFactory (brokerURI);
Connection *connection = connectionFactory->createConnection();
connection->start();
Session *session = connection->createSession (Session::AUTO_ACKNOWLEDGE);
Destination *destination = session->createQueue (dest);
MessageConsumer *consumer = session->createConsumer (destination);
TextMessage *m = (TextMessage*) consumer->receive();
cout << "Got Message: " << m->getText() << endl;
delete m;
delete destination;
delete session;
delete connection;
delete connectionFactory;
return 0;
}