You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2018/11/22 03:02:14 UTC

[GitHub] vongosling closed pull request #3: Update readme file to polish the quick start guidance

vongosling closed pull request #3: Update readme file to polish the quick start guidance
URL: https://github.com/apache/rocketmq-client-python/pull/3
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..990936c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea/
+cmake-build-debug/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c611e27..d450797 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,21 +120,33 @@ else() #not-HAVE_LIBDL
     message(FATAL_ERROR "Missing library: dl")
 endif()
 
-list(APPEND deplibs rt)
 
-check_library_exists(z compress2 "" HAVE_LIBZ)
-if(HAVE_LIBZ)
-    list(APPEND deplibs z)
-else() #not-HAVE_LIBZ
-    message(FATAL_ERROR "Missing library: z")
+set(BOOST_INCLUDEDIR /usr/local/include/)
+#set(BOOST_INCLUDEDIR C:/boost_1_56_0/)
+set(Boost_USE_STATIC_LIBS    "only find boost static libs"     OFF) # only find static libs
+set(Boost_USE_MULTITHREADED          ON)
+set(Boost_USE_STATIC_RUNTIME         ON)
+if(WIN32)
+    find_package(Boost 1.53 REQUIRED COMPONENTS python)
+else()
+    #find_package(Boost 1.53 REQUIRED COMPONENTS python)
+    set(Boost_LIBRARIES         "boost_python")
 endif()
 
+#if(Boost_FOUND)
+    message(status "** Boost Include dir: ${Boost_INCLUDE_DIR}")
+    message(status "** Boost Libraries dir: ${Boost_LIBRARY_DIRS}")
+    message(status "** Boost Libraries: ${Boost_LIBRARIES}")
+    include_directories(${Boost_INCLUDE_DIRS})
+#endif()
+
 # rocketmq is used on both Linux and Mac
-check_library_exists("rocketmq" CreateMessage "" HAVE_PTHREAD)
-if (HAVE_PTHREAD)
-    list(APPEND deplibs rocketmq)
+check_library_exists("rocketmq" CreateMessage "" HAVE_ROCKETMQ)
+if (HAVE_ROCKETMQ)
+    #list(APPEND deplibs rocketmq)
+    message(status "----------------------------------- Find RocketMQ library----------------------------")
 else()
-    message(FATAL_ERROR "Missing library: pthread")
+    message(FATAL_ERROR "Missing library: rocketmq")
 endif()
 # add include dir for bsd (posix uses /usr/include/)
 set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
diff --git a/README.md b/README.md
index 79233fb..bd9728d 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ At present, this SDK supports
 * consuming message using push model
 
 ----------
-## How to use
+## Quick Start
 * Step-by-step instruction are provided in [RocketMQ Client Python Introduction](https://github.com/apache/rocketmq-client-python/blob/master/doc/Introduction.md)
 * Consult [RocketMQ Quick Start](https://rocketmq.apache.org/docs/quick-start/) to setup rocketmq broker and nameserver.
 
diff --git a/doc/Introduction.md b/doc/Introduction.md
index 24b55c2..8ad2c5f 100644
--- a/doc/Introduction.md
+++ b/doc/Introduction.md
@@ -1,69 +1,87 @@
 ----------
-## How to build
+## RocketMQ Client Python
 
-#### 1. Python Version
-* Support python 2.7.X
+### 1. Python Version
+* Python 2.7.x
 
 
-#### 2. Dependency Installation
-* Install libevent 2.0.22 dependency
-    - Download [libevent 2.0.22](https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz)
-    - Build and install libevent
-	   - ./configure
-	   - make
-	   - make install 
-* Install JsonCPP 0.10.6 dependency
-    - Download [jsoncpp 0.10.6](https://github.com/open-source-parsers/jsoncpp/archive/0.10.6.zip)
-    - Build and install jsoncpp
-  	     - cmake .
-  	     - make
-  	     - make install
-* Install boost 1.56.0 dependency
-	 - Download [boost 1.53.0](http://www.boost.org/users/history/version_1_53_0.html)
-	 - Build and install boost
-	   - cd path/to/boost_1_53_0
-	   - config boost:./bootstrap.sh
-	   - build boost:     
-	       - build static boost lib: ./b2 link=static runtime-link=static
-	       - build dynamic boost lib: ./b2 link=shared runtime-link=shared
-	   -  install boost: ./b2 install
-* Install librocketmq dependency
-    - Download [librocketmq](https://github.com/apache/rocketmq-client-cpp)
-    - Build and install librocketmq
-	   - make
-	   - make install 	
-* Install Boost-python 1.53.0 dependency
-    - install boost-python
+### 2. Dependency
+
+* [librocketmq](https://github.com/apache/rocketmq-client-cpp)	
+* python-devel 2.7.x
+* boost-python 1.53.0+
+      
+### 3. Build and Install
+#### Linux Platform
+* Install compile tools:
+    ```
+    - sudo yum install make
+    - sudo yum install gcc-c++
+    ```
+* Install dependency:
+ 
+    1. python-devel
+    ```
+    sudo yum install python-devel
+    ```
+    2. boost-python
+    ```
+    sudo yum install boost-python
+    sudo yum install boost-python-devel
+    ```
+    3. [librocketmq](https://github.com/apache/rocketmq-client-cpp),choose one method below:
+      
+    - make and install the rocketmq library manually,[Here](https://github.com/apache/rocketmq-client-cpp)
+         
+    - quick install
+    ```
+    mkdir rocketmqlib
+    cd rocketmqlib
+    wget https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.0.2/RHEL7.x/librocketmq.tar.gz
+    tar -xzf librocketmq.tar.gz
+    sudo cp librocketmq.so librocketmq.a /usr/local/lib/
+    sudo cp -r rocketmq /usr/local/include/
+    ```
+   
       
-#### 3. Make and Install
-* Default install path:
-    - header files: /usr/local/include/
-    - lib: /usr/local/lib
-* Make and install using make
+* Module make and install
+   ```
     - make
     - make install
-	
-#### 4. Check verion
-- strings librocketmqclientpython.so |grep PYTHON_CLIENT_VERSION
-
+   ```
+* Check verion
+   ```
+   strings librocketmqclientpython.so |grep PYTHON_CLIENT_VERSION
+   ```
+   
 ----------
-## Best practice
-
+## How to use
+- set LD_LIBRARY_PATH
+  ``````
+  export LD_LIBRARY_PATH=/usr/local/lib
+- import module
+  ```
+  from librocketmqclientpython import *
+  ```
+  
 - create message by following interface:
+  ```
   - msg = CreateMessage("your_topic.")
   - SetMessageBody(msg, "this_message_body.")
   - SetMessageKeys(msg, "this_message_keys.")
   - SetMessageTags(msg, "this_message_tag.")
-  
+  ```
 - producer must invoke following interface:
+  ```
   - producer =CreateProducer("please_rename_unique_group_name");
   - SetProducerNameServerAddress(producer,"please_rename_unique_name_server")
   - StartProducer(producer)
   - SendMessageSync(producer,msg)
   - ShutdownProducer(producer)
   - DestroyProducer(producer)
-
-- how to consumer meaasges
+  ```
+- how to consumer messages
+  ```
   - def consumerMessage(msg):
   - topic = GetMessageTopic(msg)
   - body = GetMessageBody(msg)
@@ -71,8 +89,9 @@
   - msgid = GetMessageId(msg)
   - handle message
   - return 0
-
+  ```
 - pushconsumer must invoke following interface:
+  ```
   - consumer =CreatePushConsumer("please_rename_unique_group_name_1");
   - SetPushConsumerNameServerAddress(consumer,"please_rename_unique_name_server")
   - Subscribe(consumer, "your_topic", "*")
@@ -80,7 +99,7 @@
   - StartPushConsumer(consumer)
   - ShutdownPushConsumer(consumer)
   - DestroyPushConsumer(consumer)
-
+  ```
 ----------
 ## Demo
 - sync producer
diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt
index 9e86bcd..8292708 100644
--- a/project/CMakeLists.txt
+++ b/project/CMakeLists.txt
@@ -32,6 +32,9 @@ LIST(APPEND SUB_DIRS ${CMAKE_SOURCE_DIR}/src)
 # include_directories
 include_directories(${CMAKE_SOURCE_DIR}/include)
 include_directories(${SUB_DIRS})
+include_directories(/usr/local/include/rocketmq)
+include_directories(/usr/include/python2.7)
+
 
 # static
 add_library(rocketmqclientpython_static STATIC ${SRC_FILES})
@@ -46,10 +49,9 @@ add_library(rocketmqclientpython_shared SHARED ${SRC_FILES})
 set_target_properties(rocketmqclientpython_shared PROPERTIES OUTPUT_NAME "rocketmqclientpython")
 #add_dependencies(rocketmqclientpython_shared)
 target_link_libraries(rocketmqclientpython_shared ${deplibs})
-target_link_libraries(rocketmqclientpython_shared)
+target_link_libraries(rocketmqclientpython_shared librocketmq.a)
+target_link_libraries(rocketmqclientpython_shared ${Boost_LIBRARIES})
 
 # install
-install (TARGETS   rocketmqclientpython_static             DESTINATION bin)
-install (DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include)
-install (DIRECTORY ${CMAKE_SOURCE_DIR}/doc/     DESTINATION doc)
+install (TARGETS   rocketmqclientpython_shared             DESTINATION lib)
 
diff --git a/project/Makefile b/project/Makefile
index c43749a..f80b7e8 100755
--- a/project/Makefile
+++ b/project/Makefile
@@ -52,7 +52,7 @@ CPPFLAGS := -I$(TOPDIR)/include \
 
 LDFLAGS := -shared -Wl,-soname=librocketmqclientpython.so -pthread -fPIC
 LIBPATH := $(addprefix -L, $(ROCKETMQ_LIBD) $(PYTHON_LIBD))
-LDLIBS := $(addprefix -l,rocketmq boost_python python2.7)
+LDLIBS := $(addprefix -l,rocketmq boost_python)
 
 CXX := g++
 AR := ar
diff --git a/sample/base.py b/sample/base.py
index 6cb4f48..7943b43 100644
--- a/sample/base.py
+++ b/sample/base.py
@@ -21,7 +21,7 @@
 def initProducer(name):
     print("---------Create Producer---------------")
     producer =CreateProducer(name)
-    SetProducerNameServerAddress(producer,"172.17.0.5:9876")
+    SetProducerNameServerAddress(producer,"172.17.0.2:9876")
     StartProducer(producer)
     return producer
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services