1 #ifndef HAVE_EVENT_MANAGER_H
2 #define HAVE_EVENT_MANAGER_H 1
8 #include <condition_variable>
11 #include <boost/asio.hpp>
14 #include "rdf_model.hpp"
15 #include "ContentItem.hpp"
16 #include "PersistenceService.hpp"
17 #include "AnalysisService.hpp"
26 static const std::string EXCHANGE_SERVICE_REGISTRY =
"service_registry";
32 static const std::string EXCHANGE_SERVICE_DISCOVERY =
"service_discovery";
37 static const std::string QUEUE_CONTENT_INPUT =
"content_input";
42 static const std::string QUEUE_CONTENT_OUTPUT =
"content_output";
47 static const std::string QUEUE_CONFIG_REQUEST =
"config_request";
50 class AnalysisConsumer;
51 class DiscoveryConsumer;
52 class RabbitConnectionHandler;
53 class ConfigurationClient;
60 std::mutex firstCallMutex;
77 const std::string& getMessage() {
return message; };
84 io_service io_service;
86 boost::asio::ip::tcp::
106 RabbitConnectionHandler* rabbit;
108 AMQP::Connection* connection;
109 AMQP::Channel* channel;
111 std::map<AnalysisService*, AnalysisConsumer*> services;
113 std::thread receiver;
115 std::condition_variable cv;
124 std::vector<char> intermediateReceiveBuffer;
130 EventManager(
const std::string& host,
const std::string& user,
const std::string& password) :
EventManager(host, 5672, 8080, user, password) {};
135 EventManager(
const std::string& host,
int rabbitPort,
int marmottaPort,
const std::string& user,
const std::string& password);
156 void onData(AMQP::Connection *connection,
const char *data,
size_t size);
172 void onError(AMQP::Connection *connection,
const char *message);
198 void onClosed(AMQP::Connection *connection);
mico::persistence::PersistenceService * getPersistenceService()
Return a reference to the persistence service used by this event manager, e.g.
Definition: EventManager.cpp:466
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...
Definition: http_client.cpp:23
void registerService(AnalysisService *service)
Register the given service with the event manager.
Definition: EventManager.cpp:490
void onConnected(AMQP::Connection *connection)
Method that is called when the login attempt succeeded.
Definition: EventManager.cpp:390
void injectContentItem(const mico::persistence::ContentItem &item)
Trigger analysis of the given content item.
Definition: EventManager.cpp:556
Main service for accessing the MICO persistence API.
Definition: PersistenceService.hpp:41
This exception is thrown by the event manager in case a method call failed.
Definition: EventManager.hpp:71
void onData(AMQP::Connection *connection, const char *data, size_t size)
Method that is called by the AMQP library every time it has data available that should be sent to Rab...
Definition: EventManager.cpp:372
virtual ~EventManager()
Shut down the event manager, cleaning up and closing any registered channels, services and connection...
Definition: EventManager.cpp:308
void onClosed(AMQP::Connection *connection)
Method that is called when the connection was closed.
Definition: EventManager.cpp:480
Representation of a ContentItem.
Definition: ContentItem.hpp:76
Definition: EventManager.hpp:80
Definition: EventManager.cpp:69
void onError(AMQP::Connection *connection, const char *message)
When the connection ends up in an error state this method is called.
Definition: EventManager.cpp:385
void unregisterService(AnalysisService *service)
Unregister the service with the given ID.
Definition: EventManager.cpp:525
Interface to be implemented by services.
Definition: AnalysisService.hpp:18
Definition: EventManager.hpp:57