Skip to content

Commit 38db73a

Browse files
vincentWangKBleonchen83
authored andcommitted
upload rocketmq-cpp code
remove unused boost file update README.md update readme.md update readme.md update readme add gitkeep to bin update readme.md update apache license info remove static dependency update readme.md add jsoncpp and libevent install discription udpate makefile update jsoncpp version unify dependency update readme support cmake instead alog by boost::log For cmake, remove alog remove alog comment [add rocketmq-cpp code apache#27] add cmake to readme use rocketmq namespace, update json version to 0.10.6 update cmakelist update json version to 0.10.6 remove makefile add default search path for jsoncpp and libevent Update README.md fix could not find jsoncpp issue support build on new g++ version Remove built .o files
1 parent 064eb6a commit 38db73a

File tree

192 files changed

+30000
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+30000
-0
lines changed

rocketmq-cpp/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Compiled source #
2+
###################
3+
*.com
4+
*.class
5+
*.dll
6+
*.exe
7+
*.o
8+
*.lo
9+
*.so
10+
*.a
11+
/build
12+
# Packages #
13+
############
14+
# it's better to unpack these files and commit the raw source
15+
# git has its own built in compression methods
16+
*.7z
17+
*.dmg
18+
*.gz
19+
*.iso
20+
*.jar
21+
*.rar
22+
*.tar
23+
*.zip
24+
rpm/.dep_create/*
25+
# Logs and databases #
26+
######################
27+
*.log
28+
*.sql
29+
*.sqlite
30+
31+
# OS generated files #
32+
######################
33+
.DS_Store
34+
.DS_Store?
35+
._*
36+
.Spotlight-V100
37+
.Trashes
38+
Icon?
39+
ehthumbs.db
40+
Thumbs.db

rocketmq-cpp/CMakeLists.txt

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
cmake_minimum_required(VERSION 2.8)
17+
18+
19+
# CMake complains if we don't have this.
20+
if (COMMAND cmake_policy)
21+
cmake_policy(SET CMP0003 NEW)
22+
endif()
23+
24+
# We're escaping quotes in the Windows version number, because
25+
# for some reason CMake won't do it at config version 2.4.7
26+
# It seems that this restores the newer behaviour where define
27+
# args are not auto-escaped.
28+
if (COMMAND cmake_policy)
29+
cmake_policy(SET CMP0005 NEW)
30+
endif()
31+
32+
# First, declare project (important for prerequisite checks).
33+
project(all)
34+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
35+
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
36+
set(CMAKE_VERBOSE_MAKEFILE 1)
37+
38+
#Find dependency
39+
#set(BOOST_INCLUDEDIR xxx)
40+
find_package(Boost 1.56.0)
41+
if(Boost_FOUND)
42+
include_directories(${Boost_INCLUDE_DIRS})
43+
endif()
44+
45+
#set(LIBEVENT_INCLUDE_DIR xxx)
46+
find_package(Libevent 2.0.22)
47+
if(LIBEVENT_FOUND)
48+
include_directories(${LIBEVENT_INCLUDE_DIRS})
49+
endif()
50+
51+
#set(JSONCPP_INCLUDE_DIR xxx)
52+
find_package(Jsoncpp 0.10.6)
53+
if(JSONCPP_FOUND)
54+
include_directories(${JSONCPP_INCLUDE_DIR})
55+
endif()
56+
57+
# put binaries in a different dir to make them easier to find.
58+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
59+
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
60+
61+
# for unix, put debug files in a separate bin "debug" dir.
62+
# release bin files should stay in the root of the bin dir.
63+
# if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
64+
# if (CMAKE_BUILD_TYPE STREQUAL Debug)
65+
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/debug)
66+
# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/debug)
67+
# endif()
68+
# endif()
69+
70+
if(NOT CMAKE_BUILD_TYPE)
71+
set(CMAKE_BUILD_TYPE "Release")
72+
endif()
73+
74+
set(C_FLAGS
75+
-g
76+
-Wall
77+
-Wno-deprecated
78+
-fPIC
79+
-fno-strict-aliasing
80+
)
81+
set(CXX_FLAGS
82+
-g
83+
-Wall
84+
-Wno-deprecated
85+
-fPIC
86+
-fno-strict-aliasing
87+
-std=c++0x
88+
# -finline-limit=1000
89+
# -Wextra
90+
# -pedantic
91+
# -pedantic-errors
92+
# -D_FILE_OFFSET_BITS=64
93+
# -DVALGRIND
94+
# -DCHECK_PTHREAD_RETURN_VALUE
95+
# -Werror
96+
# -Wconversion
97+
# -Wno-unused-parameter
98+
# -Wunused-but-set-variable
99+
# -Wold-style-cast
100+
# -Woverloaded-virtual
101+
# -Wpointer-arith
102+
# -Wshadow
103+
# -Wwrite-strings
104+
# -Wdeprecated-declarations
105+
# -march=native
106+
# -MMD
107+
# -std=c++0x
108+
# -rdynamic
109+
)
110+
111+
if(CMAKE_BUILD_BITS EQUAL 32)
112+
list(APPEND CXX_FLAGS "-m32")
113+
else() #not-condition
114+
list(APPEND CXX_FLAGS "-m64")
115+
endif()
116+
117+
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
118+
string(REPLACE ";" " " CMAKE_C_FLAGS "${C_FLAGS}")
119+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG")
120+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
121+
122+
# Declare deplibs, so we can use list in linker later. There's probably
123+
# a more elegant way of doing this; with SCons, when you check for the
124+
# lib, it is automatically passed to the linker.
125+
set(deplibs)
126+
127+
# For some reason, the check_function_exists macro doesn't detect
128+
# the inet_aton on some pure Unix platforms (e.g. sunos5). So we
129+
# need to do a more detailed check and also include some extra deplibs.
130+
list(APPEND deplibs dl)
131+
list(APPEND deplibs pthread)
132+
list(APPEND deplibs rt)
133+
list(APPEND deplibs z)
134+
135+
# add include dir for bsd (posix uses /usr/include/)
136+
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
137+
138+
# For config.h, set some static values; it may be a good idea to make
139+
# these values dynamic for non-standard UNIX compilers.
140+
set(ACCEPT_TYPE_ARG3 socklen_t)
141+
set(HAVE_CXX_BOOL 1)
142+
set(HAVE_CXX_CASTS 1)
143+
set(HAVE_CXX_EXCEPTIONS 1)
144+
set(HAVE_CXX_MUTABLE 1)
145+
set(HAVE_CXX_STDLIB 1)
146+
set(HAVE_PTHREAD_SIGNAL 1)
147+
set(SELECT_TYPE_ARG1 int)
148+
set(SELECT_TYPE_ARG234 "(fd_set *)")
149+
set(SELECT_TYPE_ARG5 "(struct timeval *)")
150+
set(STDC_HEADERS 1)
151+
set(TIME_WITH_SYS_TIME 1)
152+
set(HAVE_SOCKLEN_T 1)
153+
154+
# For config.h, save the results based on a template (config.h.in).
155+
# configure_file(res/config.h.in ${root_dir}/config.h)
156+
157+
# add_definitions(-DSYSAPI_UNIX=1 -DHAVE_CONFIG_H)
158+
159+
add_subdirectory(libs)
160+
add_subdirectory(project)
161+
add_subdirectory(example)

rocketmq-cpp/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
================build and install========================
2+
- linux platform:
3+
4+
-1. install dependency
5+
- 1>. install libevent 2.0.22 dependency
6+
- <1>. dowload libevent 2.0.22
7+
- https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
8+
- <2>. build and install libevent
9+
- ./configure
10+
- make
11+
- make install
12+
- 2>. install JsonCPP 0.7.0 dependency
13+
- <1> download jsoncpp 0.7.0
14+
- https://github.com/open-source-parsers/jsoncpp/archive/0.10.6.zip
15+
- <2> build and install jsoncpp
16+
- cmake .
17+
- make
18+
- make install
19+
- 3>. install boost 1.56.0 dependency
20+
- <1>. dowload boost 1.56.0
21+
- http://www.boost.org/users/history/version_1_56_0.html
22+
- <2>. build and install boost 1.56.0
23+
- <1>. cd path/to/boost_1_56_0
24+
- <2>. config boost:./bootstrap.sh
25+
- <3>. build boost:
26+
- build static boost lib: ./b2 link=static runtime-link=static
27+
- build dynamic boost lib: ./b2 link=shared runtime-link=shared
28+
- <3>. install boost: ./b2 install
29+
30+
-2. make&install
31+
- default install path:
32+
- header files: /usr/local/include
33+
- lib: /usr/local/lib
34+
- 1>.make&install by cmake
35+
- <1>. cmake will auto find_package, if failes, change BOOST_INCLUDEDIR/LIBEVENT_INCLUDE_DIR/JSONCPP_INCLUDE_DIR in CMakeList.txt, according to its real install path
36+
- <2>. make
37+
- <3>. make install
38+
39+
- Windows platform:
40+
- will be supported later
41+
42+
43+
44+
- check verion:
45+
- strings librocketmq.so |grep VERSION
46+
47+
- log path:$HOME/logs/metaq-client4cpp
48+
49+
- Before Run:
50+
- export LD_LIBRARY_PATH=/xxx/rocketmq-client4cpp/bin/:$LD_LIBRARY_PATH;LD_LIBRARY_PATH=/A/lib:$LD_LIBRARY_PATH
51+
52+
=================meaning of each parameter===================
53+
- -n : nameserver addr, if not set -n and -i ,no nameSrv will be got
54+
- -i : nameserver domain name, if not set -n and -i ,no nameSrv will be got
55+
- Notice: oper should only set one option from -n and -i,
56+
- -g : groupName, contains producer groupName and consumer groupName
57+
- -t : msg topic
58+
- -m : message count(default value:1)
59+
- -c : msg content(default value: only test)
60+
- -b : consume model(default value: CLUSTER)
61+
- -a : set sync push(default value: async)
62+
- -r : setup retry times(default value:5 times)
63+
- -u : select active broker to send msg(default value: false)
64+
- -d : use AutoDeleteSendcallback by cpp client(defalut value: false)
65+
- -T : thread count of send msg or consume msg(defalut value: system cpu core number)
66+
- -v : print more details information
67+
68+
- Example:
69+
- sync producer: ./SyncProducer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
70+
- async producer: ./AsyncProducer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
71+
- send delay msg: ./SendDelayMsg -g producerGroup -t topic -c msgContent -n nameServerAddr
72+
- sync pushConsumer: ./PushConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr -s sync
73+
- async pushConsumer: ./AsyncPushConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
74+
- orderly sync pushConsumer: ./OrderlyPushConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr -s sync
75+
- orderly async pushConsumer: ./OrderlyPushConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
76+
- sync pullConsumer:./PullConsumer -g producerGroup -t topic -c msgContent -m msgCount -n nameServerAddr
77+
78+
==================================Notice=============================================
79+
- producer must invoke following interface:
80+
- DefaultMQProducer g_producer("please_rename_unique_group_name");
81+
- g_producer.start();
82+
- g_producer.send(...);
83+
- g_producer.shutdown();
84+
85+
- pullconsumer must invoke following interface:
86+
- DefaultMQPullConsumer g_consumer("please_rename_unique_group_name");
87+
- g_consumer.start();
88+
- g_consumer.fetchSubscribeMessageQueues(..., ...);
89+
- g_consumer.pull(...)
90+
- g_consumer.shutdown();
91+
92+
- pushconsumer must invoke following interface:
93+
- DefaultMQPushConsumer g_consumer("please_rename_unique_group_name_1");
94+
- g_consumer.subscribe("test_topic", "*");
95+
- g_consumer.registerMessageListener(listener);
96+
- g_consumer.start();
97+
- g_consumer.shutdown();
98+

rocketmq-cpp/bin/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#keep

rocketmq-cpp/cmake/FindJsoncpp.cmake

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Find jsoncpp
17+
#
18+
# Find the jsoncpp includes and library
19+
#
20+
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
21+
#
22+
# This module defines
23+
# JSONCPP_INCLUDE_DIR, where to find header, etc.
24+
# JSONCPP_LIBRARY, the libraries needed to use jsoncpp.
25+
# JSONCPP_FOUND, If false, do not try to use jsoncpp.
26+
# JSONCPP_INCLUDE_PREFIX, include prefix for jsoncpp.
27+
# jsoncpp_lib_static imported library.
28+
29+
# only look in default directories
30+
find_path(
31+
JSONCPP_INCLUDE_DIR
32+
NAMES json/json.h jsoncpp/json/json.h
33+
PATHS /usr/include/jsoncp /usr/local/include/jsoncpp
34+
DOC "jsoncpp include dir"
35+
)
36+
37+
find_library(
38+
JSONCPP_LIBRARY
39+
NAMES jsoncpp
40+
PATHS /usr/lib /usr/local/lib
41+
DOC "jsoncpp library"
42+
)
43+
44+
add_library(jsoncpp_lib_static UNKNOWN IMPORTED)
45+
set_target_properties(
46+
jsoncpp_lib_static
47+
PROPERTIES
48+
IMPORTED_LOCATION "${JSONCPP_LIBRARY}"
49+
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_INCLUDE_DIR}"
50+
)
51+
52+
# debug library on windows
53+
# same naming convention as in qt (appending debug library with d)
54+
# boost is using the same "hack" as us with "optimized" and "debug"
55+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
56+
find_library(
57+
JSONCPP_LIBRARY_DEBUG
58+
NAMES jsoncppd
59+
DOC "jsoncpp debug library"
60+
)
61+
62+
set_target_properties(
63+
jsoncpp_lib_static
64+
PROPERTIES
65+
IMPORTED_LOCATION_DEBUG "${JSONCPP_LIBRARY_DEBUG}"
66+
)
67+
set(JSONCPP_LIBRARY optimized ${JSONCPP_LIBRARY} debug ${JSONCPP_LIBRARY_DEBUG})
68+
69+
endif()
70+
71+
# find JSONCPP_INCLUDE_PREFIX
72+
find_path(
73+
JSONCPP_INCLUDE_PREFIX
74+
NAMES json.h
75+
PATH_SUFFIXES jsoncpp/json json
76+
)
77+
78+
if (${JSONCPP_INCLUDE_PREFIX} MATCHES "jsoncpp")
79+
set(JSONCPP_INCLUDE_PREFIX "jsoncpp/json")
80+
else()
81+
set(JSONCPP_INCLUDE_PREFIX "json")
82+
endif()
83+
84+
85+
86+
# handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE
87+
# if all listed variables are TRUE, hide their existence from configuration view
88+
include(FindPackageHandleStandardArgs)
89+
find_package_handle_standard_args(jsoncpp DEFAULT_MSG JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)
90+
mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)

0 commit comments

Comments
 (0)