Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dd9229d
lib: refactor Channel ctor and Create funcs
alanxz Aug 3, 2020
38c13a3
lib: update Channel::CreateSecureFromUri docs
alanxz Aug 3, 2020
b1b9731
lib: make CreateFromUri when SSL URI is specified
alanxz Aug 3, 2020
427139e
build: restore GNUInstallDirs include (#265, #266)
alanxz Aug 3, 2020
f9fb520
Update ChangeLog and version for v2.5.1 release
alanxz Aug 3, 2020
aa9981d
Increment version to v2.6 (take 2)
alanxz Aug 3, 2020
f009117
lib: add missing headers to SimpleAmqpClient.h
alanxz Aug 6, 2020
09ad35d
lib: Add Channel::Open factory func API
alanxz Aug 3, 2020
bdc3fd6
lib: add missing dllexport markings
alanxz Aug 7, 2020
706d42e
lib: Mark Channel::Create* functions as deprecated
alanxz Aug 10, 2020
ad67f5f
lib: switch to StringToBytes from amqp_cstring_bytes
alanxz Aug 29, 2020
4704a82
lib: correct format issue
alanxz Aug 30, 2020
4818655
Fix setting of flags in CreateAmqpProperties().
s3rvac Nov 5, 2020
5a2b985
Add vscode-related files to .gitignore
alanxz Nov 9, 2020
f2b7498
dev: Add codespaces configuration
alanxz Nov 5, 2020
ba5baa8
lib: add Channel::CheckExchangeExists API
alanxz Nov 9, 2020
3274e1b
lib: convert Channel::CheckExchangeExists to use boost::string_ref
alanxz Nov 13, 2020
e474a06
lib: Add Channel::CheckQueueExists API
alanxz Nov 13, 2020
f1344fb
Add "Build procedure for Windows" (#302)
lyuzinmaxim Dec 27, 2021
6369b99
Optionally set ca cert path (#309)
p487morgan Jul 25, 2022
ac77fa0
lib: compile SimpleAmqpClient as C++17
alanxz Jun 27, 2020
b00f7bf
ci: use gcc-7 and clang-8 under travis-ci
alanxz Jul 23, 2020
2ef475b
test: update googletest to v1.10
alanxz Jun 27, 2020
84bff8d
lib: switch away from boost::scoped_ptr
alanxz Jun 27, 2020
5841f0c
lib: switch away from boost::noncopyable
alanxz Jun 27, 2020
9f4162e
lib: switch to using <cstdint>
alanxz Jul 18, 2020
27fcca4
lib: switch to std::array
alanxz Jul 18, 2020
a2d3d7f
lib: switch away from boost::lexical_cast
alanxz Jul 22, 2020
3a7e234
lib: drop unused boost/limits.hpp
alanxz Jul 22, 2020
64a1fac
lib: drop unused boost/foreach.hpp
alanxz Jul 22, 2020
4bd0514
lib: switch boost::shared_ptr to std::shared_ptr
alanxz Jul 22, 2020
8c8d20e
lib: switch boost::variant to std::variant
alanxz Jul 23, 2020
7e192fd
lib: switch boost::chrono to std::chrono
alanxz Jul 23, 2020
2bc812a
lib: replace boost::bind with lambdas
alanxz Jul 23, 2020
d37979e
lib: remove use of boost::split
alanxz Jul 23, 2020
ebbb603
lib: replace boost::optional with std::optional
alanxz Jul 25, 2020
5ab9e6f
lib: remove boost library from build
alanxz Jul 23, 2020
319e32f
lib: replace boost::stringref with std::string_view
prateek9623 Jul 13, 2022
d46e49a
1. updated README, ci and devcontainer with with removed boost lib
prateek9623 Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
ARG VARIANT=buster
FROM mcr.microsoft.com/vscode/devcontainers/cpp:dev-${VARIANT}

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends lsb-release wget software-properties-common \
&& bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \
&& apt-get -y install --no-install-recommends clang-format-11 clang-tidy-11 ninja-build rabbitmq-server \
libssl-dev librabbitmq-dev
12 changes: 12 additions & 0 deletions .devcontainer/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
ARG VARIANT=buster
FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT}

# Install needed packages. Use a separate RUN statement to add your own dependencies.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install build-essential cmake cppcheck valgrind clang lldb llvm gdb \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
"args": { "VARIANT": "ubuntu-20.04" }
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

// Set *default* container specific settings.json values on container create.
"settings": {
"clangd.path": "clangd-11",
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json",
"workbench.colorTheme": "Solarized Dark",
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// "ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"vscodevim.vim",
"llvm-vs-code-extensions.vscode-clangd",
"twxs.cmake",
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*~
.*.sw?

.cache/
.vscode/
build/
CMakeCache.txt
cmake_install.cmake
CMakeFiles/
Expand All @@ -13,4 +16,5 @@ Debug/
ipch/
install_manifest.txt
.ycm_extra_conf.py*
compile_commands.json
*.orig
22 changes: 10 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ dist: xenial

jobs:
include:
- compiler: gcc
env: FLAGS=""
- compiler: clang
env: FLAGS=""
- compiler: clang
env: FLAGS="-g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer"
- compiler: clang
env: FLAGS="-g -O1 -fsanitize=thread -fno-omit-frame-pointer"
- env: CC=gcc-7 CXX=g++-7 FLAGS=""
- env: CC=clang-8 CXX=clang++-8 FLAGS=""
- env: CC=clang-8 CXX=clang++-8 FLAGS="-g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer"
- env: CC=clang-8 CXX=clang++-8 FLAGS="-g -O1 -fsanitize=thread -fno-omit-frame-pointer"

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- sourceline: deb http://dl.bintray.com/rabbitmq-erlang/debian xenial erlang
key_url: https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
- sourceline: deb https://dl.bintray.com/rabbitmq/debian xenial main
key_url: https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
packages:
- libboost-dev
- libboost-chrono-dev
- libboost-system-dev
- gcc-7
- g++-7
- clang-8
- rabbitmq-server
- ninja-build

Expand All @@ -50,6 +48,6 @@ before_script:

# Run the Build script
script:
- cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${FLAGS}" -DCMAKE_INSTALL_PREFIX=../_install -DENABLE_TESTING=ON -DRabbitmqc_DIR=${RABBITMQ_C_DIR} ..
- cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror ${FLAGS}" -DCMAKE_INSTALL_PREFIX=../_install -DENABLE_TESTING=ON -DRabbitmqc_DIR=${RABBITMQ_C_DIR} ..
- cmake --build . --target install
- AMQP_BROKER=localhost ASAN_OPTIONS=detect_leaks=1 ctest -V .
43 changes: 7 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.5)

project(SimpleAmqpClient LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand All @@ -21,7 +21,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# 4. If any interfaces have been removed since the last public release, then set age to 0.

set(SAC_SOVERSION_CURRENT 7)
set(SAC_SOVERSION_REVISION 0)
set(SAC_SOVERSION_REVISION 1)
set(SAC_SOVERSION_AGE 0)

math(EXPR SAC_SOVERSION_MAJOR "${SAC_SOVERSION_CURRENT} - ${SAC_SOVERSION_AGE}")
Expand All @@ -41,17 +41,6 @@ string(REGEX MATCH "[0-9]+" _API_VERSION_PATCH ${_API_VERSION_PATCH})

set(SAC_APIVERSION ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH})

option(Boost_Dynamic_Linking_ENABLED "Enable boost dynamic linking" OFF)

if(Boost_Dynamic_Linking_ENABLED)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
endif()

find_package(Boost 1.47.0 COMPONENTS chrono system REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
find_package(Rabbitmqc REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Rabbitmqc_INCLUDE_DIRS})
Expand All @@ -68,15 +57,6 @@ if (CMAKE_GENERATOR MATCHES ".*(Make|Ninja).*"
message(STATUS "CMAKE_BUILD_TYPE not specified. Using ${CMAKE_BUILD_TYPE} build")
endif ()

if (CMAKE_CXX_FLAGS STREQUAL ""
AND NOT DEFINED SAC_CXX_FLAGS_SET)
if (CMAKE_COMPILER_IS_GNUCXX
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "-Wall -Wextra" CACHE STRING "Flags used by the compiler during all build types." FORCE)
endif ()
set(SAC_CXX_FLAGS_SET TRUE CACHE INTERNAL "Have the SAC default compiler flags been set?")
endif ()

include_directories(BEFORE src
${CMAKE_CURRENT_BINARY_DIR})

Expand All @@ -96,6 +76,8 @@ set(SAC_LIB_SRCS
src/SimpleAmqpClient/AmqpException.h
src/AmqpException.cpp

src/SimpleAmqpClient/Bytes.h

src/SimpleAmqpClient/Channel.h
src/Channel.cpp

Expand Down Expand Up @@ -133,7 +115,7 @@ set(SAC_LIB_SRCS


add_library(SimpleAmqpClient ${SAC_LIB_SRCS})
target_link_libraries(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${SOCKET_LIBRARY} ${Boost_LIBRARIES} $<$<BOOL:${Boost_Dynamic_Linking_ENABLED}>:Boost::dynamic_linking>)
target_link_libraries(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${SOCKET_LIBRARY})

if (WIN32)
set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} OUTPUT_NAME SimpleAmqpClient.${SAC_SOVERSION})
Expand Down Expand Up @@ -190,6 +172,8 @@ if (BUILD_API_DOCS)
)
endif ()

include(GNUInstallDirs)

install(TARGETS SimpleAmqpClient
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down Expand Up @@ -221,19 +205,6 @@ set(exec_prefix "\${prefix}")
set(libdir ${CMAKE_INSTALL_LIBDIR})
set(includedir "\${prefix}/include")

foreach(_lib ${Boost_LIBRARIES})
get_filename_component(_LIBPATH ${_lib} PATH)
if (NOT _LIBPATH STREQUAL _LASTLIBPATH)
set(libs_private "${libs_private} -L${_LIBPATH}")
set(_LASTLIBPATH ${_LIBPATH})
endif()

get_filename_component(_LIBNAME ${_lib} NAME_WE)
string(REGEX REPLACE "^lib" "" _LIBNAME ${_LIBNAME})
set(_LIBNAME "-l${_LIBNAME}")
set(libs_private "${libs_private} ${_LIBNAME}")
endforeach()

configure_file(libSimpleAmqpClient.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libSimpleAmqpClient.pc @ONLY)

install(FILES
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Changes since v2.5.0 (v2.5.1)

- fix: restore GNUInstallDirs that was mistakenly removed.
- refactor of Channel constructors

# Changes since v2.4 (v2.5)

NOTE: this release requires rabbitmq-c v0.8.0 or better.
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Installing
----------------

Known to work in the following environments:
- Windows 10 (MSVC 2019, Win64)
- Windows 7 (MSVC 10, Win64, Win32). Likely to work in others, but has not been tested
- Linux (RHEL 6.0, GCC-4.4.5, 32 and 64 bit). Likely to work on other configurations, but has not been tested
- Mac OS X (10.7, 10.6, gcc-4.2, 32 and 64-bit). Likely to work on older version, but has not been tested

### Pre-requisites
+ [boost-1.47.0](http://www.boost.org/) or newer (uses chrono, system internally in addition to other header based libraries such as sharedptr and noncopyable)
+ [rabbitmq-c](http://github.com/alanxz/rabbitmq-c) you'll need version 0.8.0 or better.
+ [cmake 3.5+](http://www.cmake.org/) what is needed for the build system
+ [Doxygen](http://www.stack.nl/~dimitri/doxygen/) OPTIONAL only necessary to generate API documentation
Expand All @@ -41,6 +41,16 @@ Notes:
+ The test google-test based test suite can be enabled by passing `-DENABLE_TESTING=ON` to
cmake

### Build procedure for Windows

To build and install succesfully, [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) should be built **as shared library**.

Let [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) be on ```C:\rabbitmq-c```,
SSL be OFF, and VS2019 is used, than CMake CLI is:
```
cd cmake -G "Visual Studio 16" -A x64 -DRabbitmqc_INCLUDE_DIR="C:/rabbitmq-c/include" -DRabbitmqc_LIBRARY="C:/rabbitmq-c/lib/rabbitmq.4.lib" -DBUILD_STATIC_LIBS=ON -DENABLE_SSL_SUPPORT=OFF ..
```

Using the library
-----------------

Expand All @@ -55,9 +65,9 @@ instance of this class.

AmqpClient::Channel::ptr_t connection = AmqpClient::Channel::Create("localhost");

All classes have a typedef ptr_t which is equivalent to boost::shared_ptr<> of the
All classes have a typedef ptr_t which is equivalent to std::shared_ptr<> of the
containing class. All classes also have a Create() method does the job creating a new
ptr_t using boost::make_shared<>(). It is recommended that you use these methods
ptr_t using std::make_shared<>(). It is recommended that you use these methods
to construct objects in the library.

Commands dealing with declaring/binding/unbinding/deleting exchanges and queues are
Expand Down
52 changes: 25 additions & 27 deletions src/AmqpException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,33 @@
#include <amqp_framing.h>
#include <assert.h>

#include <boost/lexical_cast.hpp>
#include <sstream>
#include <string>

namespace AmqpClient {

const boost::uint16_t ContentTooLargeException::REPLY_CODE =
const std::uint16_t ContentTooLargeException::REPLY_CODE =
AMQP_CONTENT_TOO_LARGE;
const boost::uint16_t NoRouteException::REPLY_CODE = AMQP_NO_ROUTE;
const boost::uint16_t NoConsumersException::REPLY_CODE = AMQP_NO_CONSUMERS;
const boost::uint16_t AccessRefusedException::REPLY_CODE = AMQP_ACCESS_REFUSED;
const boost::uint16_t NotFoundException::REPLY_CODE = AMQP_NOT_FOUND;
const boost::uint16_t ResourceLockedException::REPLY_CODE =
AMQP_RESOURCE_LOCKED;
const boost::uint16_t PreconditionFailedException::REPLY_CODE =
const std::uint16_t NoRouteException::REPLY_CODE = AMQP_NO_ROUTE;
const std::uint16_t NoConsumersException::REPLY_CODE = AMQP_NO_CONSUMERS;
const std::uint16_t AccessRefusedException::REPLY_CODE = AMQP_ACCESS_REFUSED;
const std::uint16_t NotFoundException::REPLY_CODE = AMQP_NOT_FOUND;
const std::uint16_t ResourceLockedException::REPLY_CODE = AMQP_RESOURCE_LOCKED;
const std::uint16_t PreconditionFailedException::REPLY_CODE =
AMQP_PRECONDITION_FAILED;
const boost::uint16_t ConnectionForcedException::REPLY_CODE =
const std::uint16_t ConnectionForcedException::REPLY_CODE =
AMQP_CONNECTION_FORCED;
const boost::uint16_t InvalidPathException::REPLY_CODE = AMQP_INVALID_PATH;
const boost::uint16_t FrameErrorException::REPLY_CODE = AMQP_FRAME_ERROR;
const boost::uint16_t SyntaxErrorException::REPLY_CODE = AMQP_SYNTAX_ERROR;
const boost::uint16_t CommandInvalidException::REPLY_CODE =
AMQP_COMMAND_INVALID;
const boost::uint16_t ChannelErrorException::REPLY_CODE = AMQP_CHANNEL_ERROR;
const boost::uint16_t UnexpectedFrameException::REPLY_CODE =
const std::uint16_t InvalidPathException::REPLY_CODE = AMQP_INVALID_PATH;
const std::uint16_t FrameErrorException::REPLY_CODE = AMQP_FRAME_ERROR;
const std::uint16_t SyntaxErrorException::REPLY_CODE = AMQP_SYNTAX_ERROR;
const std::uint16_t CommandInvalidException::REPLY_CODE = AMQP_COMMAND_INVALID;
const std::uint16_t ChannelErrorException::REPLY_CODE = AMQP_CHANNEL_ERROR;
const std::uint16_t UnexpectedFrameException::REPLY_CODE =
AMQP_UNEXPECTED_FRAME;
const boost::uint16_t ResourceErrorException::REPLY_CODE = AMQP_RESOURCE_ERROR;
const boost::uint16_t NotAllowedException::REPLY_CODE = AMQP_NOT_ALLOWED;
const boost::uint16_t NotImplementedException::REPLY_CODE =
AMQP_NOT_IMPLEMENTED;
const boost::uint16_t InternalErrorException::REPLY_CODE = AMQP_INTERNAL_ERROR;
const std::uint16_t ResourceErrorException::REPLY_CODE = AMQP_RESOURCE_ERROR;
const std::uint16_t NotAllowedException::REPLY_CODE = AMQP_NOT_ALLOWED;
const std::uint16_t NotImplementedException::REPLY_CODE = AMQP_NOT_IMPLEMENTED;
const std::uint16_t InternalErrorException::REPLY_CODE = AMQP_INTERNAL_ERROR;

void AmqpException::Throw(const amqp_rpc_reply_t &reply) {
assert(reply.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION);
Expand All @@ -77,7 +75,7 @@ void AmqpException::Throw(const amqp_rpc_reply_t &reply) {
throw std::logic_error(
std::string(
"Programming error: unknown server exception class/method")
.append(boost::lexical_cast<std::string>(reply.reply.id)));
.append(std::to_string(reply.reply.id)));
}
}

Expand Down Expand Up @@ -124,7 +122,7 @@ void AmqpException::Throw(const amqp_channel_close_t &reply) {
default:
throw std::logic_error(
std::string("Programming error: unknown channel reply code: ")
.append(boost::lexical_cast<std::string>(reply.reply_code)));
.append(std::to_string(reply.reply_code)));
}
}

Expand Down Expand Up @@ -186,14 +184,14 @@ void AmqpException::Throw(const amqp_connection_close_t &reply) {
default:
throw std::logic_error(
std::string("Programming error: unknown connection reply code: ")
.append(boost::lexical_cast<std::string>(reply.reply_code)));
.append(std::to_string(reply.reply_code)));
}
}

AmqpException::AmqpException(const std::string &what,
const std::string &reply_text,
boost::uint16_t class_id,
boost::uint16_t method_id) throw()
std::uint16_t class_id,
std::uint16_t method_id) throw()
: std::runtime_error(what),
m_reply_text(reply_text),
m_class_id(class_id),
Expand Down
Loading