Mqfilter is built if possible

The mqfilter was not built by default even though it should have been. This has
been fixed but the filter is built only if librabbitmq is found. This was done
to avoid having the librabbitmq and its development headers as a hard
dependency.
This commit is contained in:
Markus Makela 2015-11-25 06:26:06 +02:00
parent 6ea209d13a
commit 443bbe73d2
5 changed files with 19 additions and 82 deletions

View File

@ -40,6 +40,7 @@ find_package(TCMalloc)
find_package(Jemalloc)
find_package(Git)
find_package(CURL)
find_package(RabbitMQ)
# Build PCRE2
# Read BuildPCRE2 for details about how to add pcre2 as a dependency to a target

View File

@ -160,77 +160,7 @@ Delivery 1, exchange foo routingkey k1
Content-type: text/plain
```
## Step 4 - MaxScale integration with librabbitmq-c
A new filter (mqfilter.c) is implemented in order to send messages to the rabbitmq server and a message consumer (rabbitmq_consumer/consumer.c) program will get messages and store them into a MySQL/MariaDB database.
A quick way to install MaxScale with the RabbitMQ filter is to go to the MaxScale source directory and run the following commands:
```
mkdir build
cd build
cmake .. -DBUILD_RABBITMQ=Y
make
make install
```
To build the RabbitMQ filter CMake needs an additional parameter:
```
-DBUILD_RABBITMQ=Y
```
If the librabbitmq-c library is manually compiled it may be necessary to manually pass the location of the libraries and header files to CMake.
Libraries:
```
-DRABBITMQ_LIBRARIES=<path to RabbitMQ-c libraries>
```
Headers:
```
-DRABBITMQ_HEADERS=<path to RabbitMQ-c headers>
```
Please note, Message Queue Consumer (consumer.c) also needs to be compiled with MySQL/MariaDB client libraries in addition to the RabbitMQ-c libraries. If you have your MySQL/MariaDB client libraries and headers in non-standard locations, you can pass them manually to CMake:
Libraries:
```
-DMYSQLCLIENT_LIBRARIES=<path to libraries>
```
Headers:
```
-DMYSQLCLIENT_HEADERS=<path to headers>
```
The message queue consumer must be also built as a separate task, it’s not built as part of MaxScale build system. To build it, run the following commands in the rabbitmq_consumer directory in the MaxScale source folder:
```
mkdir build
cd build
cmake ..
make
```
To install it:
```
make install
```
To build packages:
```
make package
```
This generates RPM or DEB packages based on your system. These packages can then be installed on remote systems for easy access to the data generated by the consumer client.
## Step 5 - Configure new applications
## Step 4 - Configure new applications
The new filter needs to be configured in maxscale.cnf.

View File

@ -1,11 +1,12 @@
# This CMake file tries to find the the RabbitMQ library
# This CMake file tries to find the the RabbitMQ 0.5 library
# The following variables are set:
# RABBITMQ_FOUND - System has RabbitMQ client
# RABBITMQ_LIBRARIES - The RabbitMQ client library
# RABBITMQ_HEADERS - The RabbitMQ client headers
include(CheckCSourceCompiles)
find_library(RABBITMQ_LIBRARIES NAMES rabbitmq)
find_path(RABBITMQ_HEADERS amqp.h PATH_SUFFIXES mysql mariadb)
find_path(RABBITMQ_HEADERS amqp.h)
if(${RABBITMQ_LIBRARIES} MATCHES "NOTFOUND")
set(RABBITMQ_FOUND FALSE CACHE INTERNAL "")
@ -17,7 +18,9 @@ else()
endif()
set(CMAKE_REQUIRED_INCLUDES ${RABBITMQ_HEADERS})
check_c_source_compiles("#include <amqp.h>\n int main(){if(AMQP_DELIVERY_PERSISTENT){return 0;}return 1;}" HAVE_RABBITMQ50)
if(NOT HAVE_RABBITMQ50)
message(FATAL_ERROR "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
endif()
if(RABBITMQ_FOUND AND NOT HAVE_RABBITMQ50)
message(WARNING "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
endif()

View File

@ -57,7 +57,7 @@ macro(set_variables)
set(STATIC_EMBEDDED TRUE CACHE BOOL "Use static version of libmysqld")
# Build RabbitMQ components
set(BUILD_RABBITMQ FALSE CACHE BOOL "Build RabbitMQ components")
set(BUILD_RABBITMQ TRUE CACHE BOOL "Build RabbitMQ components")
# Build the binlog router
set(BUILD_BINLOG TRUE CACHE BOOL "Build binlog router")

View File

@ -1,9 +1,12 @@
if(BUILD_RABBITMQ)
find_package(RabbitMQ)
include_directories(${RABBITMQ_HEADERS})
add_library(mqfilter SHARED mqfilter.c)
target_link_libraries(mqfilter query_classifier log_manager ${RABBITMQ_LIBRARIES})
install(TARGETS mqfilter DESTINATION ${MAXSCALE_LIBDIR})
if(RABBITMQ_FOUND)
include_directories(${RABBITMQ_HEADERS})
add_library(mqfilter SHARED mqfilter.c)
target_link_libraries(mqfilter query_classifier log_manager ${RABBITMQ_LIBRARIES})
install(TARGETS mqfilter DESTINATION ${MAXSCALE_LIBDIR})
else()
message(WARNING "Could not find librabbitmq, the mqfilter will not be built.")
endif()
endif()
add_library(regexfilter SHARED regexfilter.c)