Repository: incubator-rocketmq-site Updated Branches: refs/heads/master 754269cf5 -> a84f68daa
[ROCKETMQ-216] - Website polish closes apache/incubator-rocketmq-site#14 Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/commit/a84f68da Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/tree/a84f68da Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/diff/a84f68da Branch: refs/heads/master Commit: a84f68daaf400df1cf08e5b89ceade5b14d894ff Parents: 754269c Author: zhoudiqiu <[email protected]> Authored: Tue Jun 6 21:19:40 2017 +0800 Committer: dongeforever <[email protected]> Committed: Tue Jun 6 21:19:40 2017 +0800 ---------------------------------------------------------------------- _data/navigation.yml | 4 +- _docs/01-quick-start-guide.md | 7 +- _docs/02-motivation.md | 10 +- _docs/04-cli-admin-tool.md | 2 +- _docs/07-frequently-asked-questions.md | 12 +- _docs/12-rmq-batch-example.md | 27 ++--- _docs/13-rmq-broadcasting-example.md | 61 +++++----- _docs/14-rmq-deployment.md | 10 +- _docs/15-order-message-example .md | 105 ++++++++-------- _docs/16-rmq-architecture.md | 16 +-- _docs/17-rmq-schedule-example.md | 5 +- _docs/18-simple-example.md | 179 +++++++++------------------- _docs/19-filter-by-sql92-example.md | 40 +++---- home.md | 26 ++-- 14 files changed, 209 insertions(+), 295 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_data/navigation.yml ---------------------------------------------------------------------- diff --git a/_data/navigation.yml b/_data/navigation.yml index 97f0958..5185f2d 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -19,10 +19,10 @@ main: docs: - title: User Guide children: - - title: "Quick Start" - url: /docs/quick-start/ - title: "Why RocketMQ" url: /docs/motivation/ + - title: "Quick Start" + url: /docs/quick-start/ - title: "Simple Example" url: /docs/simple-example/ - title: "Order Example" http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/01-quick-start-guide.md ---------------------------------------------------------------------- diff --git a/_docs/01-quick-start-guide.md b/_docs/01-quick-start-guide.md index 8b84636..e298d39 100644 --- a/_docs/01-quick-start-guide.md +++ b/_docs/01-quick-start-guide.md @@ -5,7 +5,7 @@ excerpt: "How to quickly install and setup Apache RocketMQ." modified: 2016-12-29T15:01:43-04:00 --- -This quick start guide is to give detailed instructions, helping you setup RocketMQ messaging system on a single local machine and send/receive the very first message. +This quick start guide is a detailed instruction of setting up RocketMQ messaging system on a local machine and sending/receiving messages. {% include toc %} @@ -42,12 +42,11 @@ This quick start guide is to give detailed instructions, helping you setup Rocke > tail -f ~/logs/rocketmqlogs/broker.log The broker[%s, 172.30.30.233:10911] boot success... ``` - you may need to pay attention to the broker ip, for that the broker will not use the loopback network interface, So you should make sure you have connected to other network. - + # Send & Receive Messages -Before sending/receiving messages, we need to tell clients where name servers are located. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable `NAMESRV_ADDR` +Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable `NAMESRV_ADDR` ```shell > export NAMESRV_ADDR=localhost:9876 http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/02-motivation.md ---------------------------------------------------------------------- diff --git a/_docs/02-motivation.md b/_docs/02-motivation.md index d462d98..14eb57a 100644 --- a/_docs/02-motivation.md +++ b/_docs/02-motivation.md @@ -4,19 +4,19 @@ permalink: /docs/motivation/ modified: 2016-12-16T15:01:43-04:00 --- -In the early stages, we constructed our distributed messaging middleware on the basis of ActiveMQ 5.x(less than 5.3). Our international business uses it for async communication, search, social network activity stream, data pipeline, even in our trade order process. As our trade business throughput rises more and more inconceivably, pressure originating from our messaging cluster also become more and more obvious. +At early stages, we constructed our distributed messaging middleware based on ActiveMQ 5.x(prior to 5.3). Our multinational business uses it for async communication, search, social network activity stream, data pipeline, even in its trade processes. As our trade business throughput rises, pressure originating from our messaging cluster also become urgent. {% include toc %} # Why RocketMQ ? -Based on our observations and research, with more and more queues and virtual topics in use, ActiveMQ IO module becomes a bottleneck. In some cases, slower consumers can slow down the producers. We tried our best efforts to handle this problems through throttling, circuit breaker or degradation, but it cannot scale out gracefully. So we begin to focus on the popular messaging solution Kafka at that time. Unfortunately, Kafka can not meet our requirements such as low latency and high reliability, see [here](/rocketmq/how-to-support-more-queues-in-rocketmq/) for details. +Based on our research, with increased queues and virtual topics in use, ActiveMQ IO module reaches a bottleneck. We tried our best to solve this problem through throttling, circuit breaker or degradation, but it didn't work well. So we begin to focus on the popular messaging solution Kafka at that time. Unfortunately, Kafka can not meet our requirements especially low latency and high reliability, see [here](/rocketmq/how-to-support-more-queues-in-rocketmq/) for details. -In this context, we decided to innovate a new messaging middleware to handle a broad set of use cases, ranging from traditional publish/subscribe scenario to demandingly high volume realtime transaction system that tolerates no message loss. We also created a cornerstone product based on RocketMQ, a Platform as a Service (PaaS) product named the -[Alibaba Cloud Platform](https://intl.aliyun.com/). Today, more than 100 companies are using the RocketMQ open source version in their business solutions. We believe RocketMQ can benefit more people, so we would like to share it around the world. +In this context, we decided to invent a new messaging engine to handle a broader set of use cases, ranging from traditional pub/sub scenarios to high volume realtime zero-loss tolerance transaction system. We believe this solution can be beneficial, so we would like to open source it to the community. Today, more than 100 companies are using the open source version of RocketMQ in their business. We also published a commercial distribution based on RocketMQ, a Platform as a Service (PaaS) product called the +[Alibaba Cloud Platform](https://intl.aliyun.com/). -The following are some different design between RocketMQ, ActiveMQ and Kafkaï¼They are the apache's most popular messaging solutions according to [awesome-java](https://github.com/akullpp/awesome-java)): +The following table demonstrates the comparison between RocketMQ, ActiveMQ and Kafka (Apache's most popular messaging solutions according to [awesome-java](https://github.com/akullpp/awesome-java)): # RocketMQ vs. ActiveMQ vs. Kafka http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/04-cli-admin-tool.md ---------------------------------------------------------------------- diff --git a/_docs/04-cli-admin-tool.md b/_docs/04-cli-admin-tool.md index ca351e9..aa2ef44 100644 --- a/_docs/04-cli-admin-tool.md +++ b/_docs/04-cli-admin-tool.md @@ -17,7 +17,7 @@ Make sure you have walked through [Quick Start](/docs/quick-start/) and [Core Co The admin tool is shipped along with RocketMQ. Either you download a pre-built binary version or build from source by yourself, you already have it. -In case you have source code, the [rocketmq-tools module](https://github.com/apache/incubator-rocketmq/tree/master/tools) contains its source code. +In case you don't have source code, the [rocketmq-tools module](https://github.com/apache/incubator-rocketmq/tree/master/tools) contains its source code. # How to use http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/07-frequently-asked-questions.md ---------------------------------------------------------------------- diff --git a/_docs/07-frequently-asked-questions.md b/_docs/07-frequently-asked-questions.md index 671e364..68d45e1 100644 --- a/_docs/07-frequently-asked-questions.md +++ b/_docs/07-frequently-asked-questions.md @@ -3,20 +3,20 @@ title: "Frequently Asked Questions" permalink: /docs/faq/ modified: 2016-12-27T15:18:43-04:00 --- -The following questions are frequently asked with regard to the RocketMQ project in general. If you have further questions, make sure to consult the documentation or ask the community. +The following questions are frequently asked with regard to the RocketMQ project in general. ## General -### 1. Why create rocketmq project instead of selecting other products? -In some cases, slower consumers can slow down the producers. We tried our best efforts to handle this problems through throttling, circuit breaker or degradation, but it cannot scale out gracefully. So we begin to focus on the popular messaging solution Kafka at that time. Unfortunately, Kafka can not meet our requirements such as low latency and high reliability. So we decided to innovate a new messaging middleware to handle a broad set of use cases, ranging from traditional publish/subscribe scenario to demandingly high volume realtime transaction system that tolerates no message loss. +### 1. Why did we create rocketmq project instead of selecting other products? +Please refer to [Why RocketMQ](/docs/motivation/) ### 2. Do I have to install other softewares, such as zookeeper, to use RocketMQ? -No. RocketMQ can run without any other softeware, you can run broker server and name server indepentently. Aslo, the topic can be created by using command, such as sh mqadmin updatetopic etc. After creating successfully, you enjoy yourself with RocketMQ. +No. RocketMQ can run independently. ## Usage ### 1. Where does the newly created Consumer ID start consuming messages? -1. If the topic sends a message within three days, then the consumer start consume message from the first message saved in the server. -2. If the topic sends a message in three days ago, the consumer start consume message from the latest message in the server, in other words, starting to consume the message queue tail. +1. If the topic sends a message within three days, then the consumer start consuming messages from the first message saved in the server. +2. If the topic sends a message three days ago, the consumer start consuming messages from the latest message in the server, in other words, starting from the tail of message queue. 3. If such consumer is the second reboot, then start to consumer message from the last consumption location. ### 2. How to reconsume message when consumption fails? http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/12-rmq-batch-example.md ---------------------------------------------------------------------- diff --git a/_docs/12-rmq-batch-example.md b/_docs/12-rmq-batch-example.md index 01b5d32..a94c27c 100644 --- a/_docs/12-rmq-batch-example.md +++ b/_docs/12-rmq-batch-example.md @@ -7,23 +7,16 @@ modified: 2017-04-24T15:01:43-04:00 {% include toc %} -#### When to use batch -Batch is not for packaging but improving performance of small messages. So the messages of the same batch should act the same role, no more effort should be taken to split the batch. -No split has another important advantage, messages of the same batch should be sent atomically, that is all successfully or all unsuccessfully, of which the importance is self-evident. -So performance and atomicity are the original intentions, which will reflect on the usage constraints. -That is to say, if you want to improve performance for small messages or to send messages atomically, batch is a nice solution for you. -#### Usage constraints -Performance and atomicity are worth the following constraints: -messages of the same batch should have: +### Why batch? +Sending messages in batch improves performance of delivering small messages. -1. same topic: If they belong to different topics(internally the queues), then may be sent to different brokers, which will against atomicity. -2. same waitStoreMsgOK: also differences will against atomicity. -3. no delay level: If we care about the delay level, we need to decode the internal properties of every message, which will cause much performance loss. +### Usage constraints +Messages of the same batch should have: same topic, same waitStoreMsgOK and no schedule support. -And the most important, the total size, that is the sum of size of each message in one batch, should be no more than 1M. +Besides, the total size of the messages in one batch should be no more than 1MiB. -#### How to use batch -If you just send several small messages in a time and do not need to worry about the size limit, it is easy to use batch: +### How to use batch +If you just send messages of no more than 1MiB at a time, it is easy to use batch: ```java String topic = "BatchTest"; @@ -39,8 +32,8 @@ try { } ``` -#### Split into lists -The complexity only grow when you send large batch and you may not sure if it exceeds the size limit (1M). +### Split into lists +The complexity only grow when you send large batch and you may not sure if it exceeds the size limit (1MiB). At this time, you'd better split the lists: @@ -98,4 +91,4 @@ while (splitter.hasNext()) { //handle the error } } -``` \ No newline at end of file +``` http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/13-rmq-broadcasting-example.md ---------------------------------------------------------------------- diff --git a/_docs/13-rmq-broadcasting-example.md b/_docs/13-rmq-broadcasting-example.md index 63a10fb..ea2b30d 100644 --- a/_docs/13-rmq-broadcasting-example.md +++ b/_docs/13-rmq-broadcasting-example.md @@ -7,21 +7,18 @@ modified: 2017-04-24T15:01:43-04:00 {% include toc %} -#### What is Broadcasting -Broadcasting is when sending a meeage to a topic,all subscribers of the topic will receive the message even if they are in the same consumer group.If you want all subscribers in a group receive all the messages in a topic,broadcasting is a good choice. +### What is broadcasting +Broadcasting is sending a message to all subscribers of a topic. If you want all subscribers receive messages about a topic, broadcasting is a good choice. -#### How to use - -##### First,Produce message as before +### Producer example ```java -DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName"); - -producer.start(); +public class BroadcastProducer { + public static void main(String[] args) throws Exception { + DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName"); + producer.start(); -for (int i = 0; i < 10000000; i++){ - try { - { + for (int i = 0; i < 100; i++){ Message msg = new Message("TopicTest", "TagA", "OrderID188", @@ -29,38 +26,38 @@ for (int i = 0; i < 10000000; i++){ SendResult sendResult = producer.send(msg); System.out.printf("%s%n", sendResult); } - - } catch (Exception e) { - e.printStackTrace(); + producer.shutdown(); } } -producer.shutdown(); ``` -##### Second,Consume message in Broadcast mode +### Consumer example ```java -DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_1"); +public class BroadcastConsumer { + public static void main(String[] args) throws Exception { + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("example_group_name"); -consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); + consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); -//set to broadcast mode -consumer.setMessageModel(MessageModel.BROADCASTING); + //set to broadcast mode + consumer.setMessageModel(MessageModel.BROADCASTING); -consumer.subscribe("TopicTest", "TagA || TagC || TagD"); + consumer.subscribe("TopicTest", "TagA || TagC || TagD"); -consumer.registerMessageListener(new MessageListenerConcurrently() { + consumer.registerMessageListener(new MessageListenerConcurrently() { - @Override - public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, - ConsumeConcurrentlyContext context) { - System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); - return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; - } -}); + @Override + public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, + ConsumeConcurrentlyContext context) { + System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + }); -consumer.start(); -System.out.printf("Broadcast Consumer Started.%n"); + consumer.start(); + System.out.printf("Broadcast Consumer Started.%n"); + } +} ``` -Enjoy it. http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/14-rmq-deployment.md ---------------------------------------------------------------------- diff --git a/_docs/14-rmq-deployment.md b/_docs/14-rmq-deployment.md index 3fb000c..9e52422 100644 --- a/_docs/14-rmq-deployment.md +++ b/_docs/14-rmq-deployment.md @@ -14,14 +14,14 @@ Before starting this section, make sure you have read Quick Start section, in wh #### Production-ready Deployment ##### Name Server -To ensure the cluster can still operate normally when one instance crashes, two or more name server instances are recommended. As long as there is at least one name server instance alive, the whole cluster remains serving. +To ensure the cluster can still operate normally when one instance crashes, two or more name server instances are recommended. As long as there is one name server instance alive, the whole cluster remains in service. -Name server follows share-nothing design paradigm. Brokers send heartbeat data to all name servers. Producers and consumers may query meta data from any one of name servers available while sending / consuming messages. +Name server follows the share-nothing design paradigm. Brokers send heartbeat data to all name servers. Producers and consumers may query meta data from any of name servers available while sending / consuming messages. #### Broker Brokers can be divided into two categories according to their roles: master and slave. Master brokers provide RW access while slave brokers only accept read access. -To deploy a high-availability RocketMQ cluster which has no single point of failure, a series of broker sets should be deployed. One broker set contains one master with brokerId set to 0 and several slaves with non-zero brokerIDs. All of the brokers in one set have the same brokerName. In serious scenarios, we should have at least two brokers in one broker set. Each topic resides in two or more brokers. +To deploy a high-availability RocketMQ cluster which has no single point of failure, a series of broker sets should be deployed. A broker set contains one master with brokerId set to 0 and several slaves with non-zero brokerIDs. All of the brokers in one set have the same brokerName. In serious scenarios, we should have at least two brokers in one broker set. Each topic resides in two or more brokers. ### Configuration When deploying a RocketMQ cluster, below configurations should be taken into consideration. @@ -111,11 +111,11 @@ usage: mqadmin clusterList [-h] [-i <arg>] [-m] [-n <arg>] ``` ### Replication mode -With the purpose to guarantee that any successfully published message will not be lost, RocketMQ provides a Replication mode to gain stronger durability and higher availability with two replication way: Sync & Async. +To guarantee any successfully published message won't be lost, RocketMQ provides a Replication mode to gain stronger durability and higher availability with two replication way: Sync & Async. ##### Replication: Sync / Async Broker -Similar to many replication system, sync brokers await until commit log is replicated to the slave before acknowledging. Async brokers, instead, return immediately after messages are processed on master. +Like many replication system, sync brokers wait until commit log is replicated to the slave before acknowledging. Async brokers, instead, return immediately after messages are processed on master. ##### How to configure There are three pre-built configurations shipped with the distribution of RocketMQ under conf folder for your reference: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/15-order-message-example .md ---------------------------------------------------------------------- diff --git a/_docs/15-order-message-example .md b/_docs/15-order-message-example .md index 0375322..a8c2b7a 100644 --- a/_docs/15-order-message-example .md +++ b/_docs/15-order-message-example .md @@ -9,39 +9,38 @@ modified: 2017-04-24T15:01:43-04:00 {% include toc %} -To send and subscribe to order messages, use Java MQ SDK 1.2.7 and above. The sequential message is a kind of message type which is provided by MQ according to the order, which is suitable for the news release and consumption according to the principle of fifo. - -For more information, please refer to the sequential message file. -The global order message and the partition order message send and receive the way to be the same basically, please refer to the following example code specifically. +RocketMQ provides ordered messages using FIFO order. +The following example demonstrates sending/recieving of globally and partitionally ordered message. #### Send message sample code ```java -try { - MQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); - producer.start(); - - String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; - for (int i = 0; i < 100; i++) { - int orderId = i % 10; - Message msg = - new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i, - ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); - SendResult sendResult = producer.send(msg, new MessageQueueSelector() { +public class OrderedProducer { + public static void main(String[] args) throws Exception { + //Instantiate with a producer group name. + MQProducer producer = new DefaultMQProducer("example_group_name"); + //Launch the instance. + producer.start(); + String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; + for (int i = 0; i < 100; i++) { + int orderId = i % 10; + //Create a message instance, specifying topic, tag and message body. + Message msg = new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i, + ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); + SendResult sendResult = producer.send(msg, new MessageQueueSelector() { @Override public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) { Integer id = (Integer) arg; int index = id % mqs.size(); return mqs.get(index); } - }, orderId); + }, orderId); - System.out.printf("%s%n", sendResult); + System.out.printf("%s%n", sendResult); + } + //server shutdown + producer.shutdown(); } - - producer.shutdown(); -} catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) { - e.printStackTrace(); } ``` @@ -49,38 +48,42 @@ try { #### Subscription message sample code ```java -DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_3"); - -consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); - -consumer.subscribe("TopicTest", "TagA || TagC || TagD"); - -consumer.registerMessageListener(new MessageListenerOrderly() { - - AtomicLong consumeTimes = new AtomicLong(0); - @Override - public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, - ConsumeOrderlyContext context) { - context.setAutoCommit(false); - System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); - this.consumeTimes.incrementAndGet(); - if ((this.consumeTimes.get() % 2) == 0) { - return ConsumeOrderlyStatus.SUCCESS; - } else if ((this.consumeTimes.get() % 3) == 0) { - return ConsumeOrderlyStatus.ROLLBACK; - } else if ((this.consumeTimes.get() % 4) == 0) { - return ConsumeOrderlyStatus.COMMIT; - } else if ((this.consumeTimes.get() % 5) == 0) { - context.setSuspendCurrentQueueTimeMillis(3000); - return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT; - } - return ConsumeOrderlyStatus.SUCCESS; +public class OrderedConsumer { + public static void main(String[] args) throws Exception { + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("example_group_name"); - } -}); + consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); + + consumer.subscribe("TopicTest", "TagA || TagC || TagD"); -consumer.start(); + consumer.registerMessageListener(new MessageListenerOrderly() { -System.out.printf("Consumer Started.%n"); + AtomicLong consumeTimes = new AtomicLong(0); + @Override + public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, + ConsumeOrderlyContext context) { + context.setAutoCommit(false); + System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); + this.consumeTimes.incrementAndGet(); + if ((this.consumeTimes.get() % 2) == 0) { + return ConsumeOrderlyStatus.SUCCESS; + } else if ((this.consumeTimes.get() % 3) == 0) { + return ConsumeOrderlyStatus.ROLLBACK; + } else if ((this.consumeTimes.get() % 4) == 0) { + return ConsumeOrderlyStatus.COMMIT; + } else if ((this.consumeTimes.get() % 5) == 0) { + context.setSuspendCurrentQueueTimeMillis(3000); + return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT; + } + return ConsumeOrderlyStatus.SUCCESS; + + } + }); + + consumer.start(); + + System.out.printf("Consumer Started.%n"); + } +} ``` http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/16-rmq-architecture.md ---------------------------------------------------------------------- diff --git a/_docs/16-rmq-architecture.md b/_docs/16-rmq-architecture.md index fc2774e..0cd352b 100644 --- a/_docs/16-rmq-architecture.md +++ b/_docs/16-rmq-architecture.md @@ -13,17 +13,17 @@ modified: 2017-04-24T15:01:43-04:00 # Overview -The greatest innovation of RocketMQ is high throughput, high reliability, and low latency of supporting massive messages through exquisite scale out and scale up. RocketMQ consists of four parts, Name Servers, Brokers, Producers and Consumers. Each of them can be horizontally extended without single Point of Failure. As shown in screenshot below. +The greatest strengths of RocketMQ are high throughput, high reliability, and low latency when supporting massive messages through exquisite scale out and scale up. RocketMQ consists of four parts: name servers, brokers, producers and consumers. Each of them can be horizontally extended without a single Point of Failure. As shown in screenshot below. **NameServer Cluster** -Name Servers provide lightweight service discovery and routing. Each Name Server records full routing information, provides equivalent reading and writing service, and supports fast storage expansion. +Name Servers provide lightweight service discovery and routing. Each Name Server records full routing information, provides corresponding reading and writing service, and supports fast storage expansion. **Broker Cluster** -Brokers take care of message storage by providing lightweight TOPIC and QUEUE mechanisms. It supports the Push and Pull modes, fault tolerance mechanism (2 copies or 3 copies), strong padding of peaks and capacity of accumulating hundreds of billion messages in their original time order. In addition, Brokers provide disaster recovery, rich metrics statistics, and alert mechanisms, all of which are lack in traditional messaging systems. +Brokers take care of message storage by providing lightweight TOPIC and QUEUE mechanisms. It supports the Push and Pull model, contains fault tolerance mechanism (2 copies or 3 copies), and provides strong padding of peaks and capacity of accumulating hundreds of billion messages in their original time order. In addition, Brokers provide disaster recovery, rich metrics statistics, and alert mechanisms, all of which are lacking in traditional messaging systems. **Producer Cluster** @@ -31,17 +31,17 @@ Producers support distributed deployment. Distributed Producers send messages to **Consumer Cluster** -Consumers support distributed deployment in the Push and Pull models as well. It also supports cluster consumption and message broadcast. It provides real-time message subscription mechanism and can meet most consumer scenarios. -RocketMQâs website provide a quick-start guide[3] for those guys who want to have a try without too much labor. +Consumers support distributed deployment in the Push and Pull model as well. It also supports cluster consumption and message broadcasting. It provides real-time message subscription mechanism and can meet most consumer requirements. +RocketMQâs website provides a simple quick-start guide[3] to interested users. # NameServer -NameServer is a little but fully functional server, which mainly includes two features: +NameServer is a fully functional server, which mainly includes two features: -* Broker Management, **NameServer** accepts the register from Broker cluster and provides heartbeat mechanism to ensure whether a broker is alive. +* Broker Management, **NameServer** accepts the register from Broker cluster and provides heartbeat mechanism to check whether a broker is alive. * Routing Management, each NameServer will hold whole routing info about the broker cluster and the **queue** info for clients query. -As we know, RocketMQ clients(Producer/Consumer) will query the queue routing info from NameServer, but how do the clients find NameServer address? +As we know, RocketMQ clients(Producer/Consumer) will query the queue routing info from NameServer, but how do clients find NameServer address? There are four methods to feed NameServer address list to clients: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/17-rmq-schedule-example.md ---------------------------------------------------------------------- diff --git a/_docs/17-rmq-schedule-example.md b/_docs/17-rmq-schedule-example.md index a55b46d..e9610ee 100644 --- a/_docs/17-rmq-schedule-example.md +++ b/_docs/17-rmq-schedule-example.md @@ -10,8 +10,9 @@ modified: 2017-04-24T15:01:43-04:00 {% include toc %} -### What is mq schedule? -If you use `DefaultMQPullConsumer` to consume message,you have to fetch message manualy.There are some steps here to achieve this point.But with `MQPullConsumerScheduleService`,you will consume messages easily. +### What is scheduled message? +Scheduled messages differ from normal messages such that they won't be delivered until a provided time later. +If you use `DefaultMQPullConsumer` to consume message, you have to fetch message manually. There are other options availible but `MQPullConsumerScheduleService` is the easiest. #### DefaultMQPullConsumer use case http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/18-simple-example.md ---------------------------------------------------------------------- diff --git a/_docs/18-simple-example.md b/_docs/18-simple-example.md index 92ac35b..f7436b9 100644 --- a/_docs/18-simple-example.md +++ b/_docs/18-simple-example.md @@ -9,97 +9,60 @@ modified: 2017-04-24T15:01:43-04:00 {% include toc %} -Use Rocketmq to send ordinary messages have three ways: reliable synchronous transmission, reliable -asynchronous transmission, one-way (Oneway) send. +Use RocketMQ to send messages in three ways: reliable synchronous, reliable +asynchronous, and one-way transmission. -This paper introduces the principle of -each implementation, the use of the scene and the similarities and differences between the -three implementations, and provides a code example for reference -Reliable synchronous transmission -Principle: synchronous transmission refers to the sender of the message issued after the -data are received after the recipient sends back a packet should be made under the mode of -communication -Application scenarios: this way the application of the scene is very extensive, such as +This page introduces: +the use cases, similarities and differences between the three implementations, +and a code example for reference. + +### Reliable synchronous transmission + +Application: Reliable synchronous transmission is used in extensive scenes, such as important notification messages, SMS notification, SMS marketing system, etc.. ```java -public class Producer { - public static void main(String[] args) throws MQClientException, - InterruptedException { - /* - * Instantiate with a producer group name. - */ +public class SyncProducer { + public static void main(String[] args) throws Exception { + //Instantiate with a producer group name. DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); - /* - * Specify name server addresses. - * <p/> - * - * Alternatively, you may specify name server addresses via exporting - environmental variable: NAMESRV_ADDR - * <pre> - * {@code - * producer.setNamesrvAddr("name-server1-ip:9876;name-server2-ip:9876"); - * } - * </pre> - */ - /* - * Launch the instance. - */ + //Launch the instance. producer.start(); - for (int i = 0; i < 1000; i++) { - try { - /* - * Create a message instance, specifying topic, tag and message - body. - */ - Message msg = new Message("TopicTest" /* Topic */, - "TagA" /* Tag */, - ("Hello RocketMQ " + - i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ - ); - /* - * Call send message to deliver message to one of brokers. - */ - SendResult sendResult = producer.send(msg); - System.out.printf("%s%n", sendResult); - } catch (Exception e) { - e.printStackTrace(); - Thread.sleep(1000); - } + for (int i = 0; i < 100; i++) { + //Create a message instance, specifying topic, tag and message body. + Message msg = new Message("TopicTest" /* Topic */, + "TagA" /* Tag */, + ("Hello RocketMQ " + + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ + ); + //Call send message to deliver message to one of brokers. + SendResult sendResult = producer.send(msg); + System.out.printf("%s%n", sendResult); } - /* - * Shut down once the producer instance is not longer in use. - */ + //Shut down once the producer instance is not longer in use. producer.shutdown(); } } ``` -#### Reliable asynchronous transmission -Principle: asynchronous transmission refers to the sender sends the data, not the receiver -back to respond, and then send the next packet communication. Asynchronous send MQ, -users need to realize asynchronous callback interface (SendCallback), in the implementation -of asynchronous send message to the application server, without waiting for a response can -be returned directly to the receiving server, through the callback interface response, and -response to the server for processing results. +### Reliable asynchronous transmission - -Applications: asynchronous transmission is generally used to link time-consuming, RT -response time sensitive business scenarios, such as user video upload after notification to -start transcoding, the transcoding after push notification transcoding results. +Application: asynchronous transmission is generally used to link time-consuming, +response time sensitive business scenarios. ```java public class AsyncProducer { - public static void main(String[] args) throws MQClientException, - InterruptedException, UnsupportedEncodingException { + public static void main(String[] args) throws Exception { + //Instantiate with a producer group name. DefaultMQProducer producer = new DefaultMQProducer("Jodie_Daily_test"); + //Launch the instance. producer.start(); producer.setRetryTimesWhenSendAsyncFailed(0); - for (int i = 0; i < 10000000; i++) { - try { + for (int i = 0; i < 100; i++) { final int index = i; - Message msg = new Message("Jodie_topic_1023", + //Create a message instance, specifying topic, tag and message body. + Message msg = new Message("TopicTest", "TagA", "OrderID188", "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET)); @@ -115,73 +78,39 @@ public class AsyncProducer { e.printStackTrace(); } }); - } catch (Exception e) { - e.printStackTrace(); - } } + //Shut down once the producer instance is not longer in use. producer.shutdown(); } } ``` -Unidirectional (Oneway) transmission -Principle: one-way (Oneway) to send the message is only responsible for sending the -message, do not wait for the server to respond and no callback function to trigger, that is, -send the request does not wait for a reply. The process of sending messages in this way -takes a very short time, usually at the microsecond level. -Application scenarios: for some very short, but not high reliability requirements of the scene, +### One-way transmission + +Application: One-way transmission is used for cases requiring moderate reliability, such as log collection. ```java -public class producerOneWay { - public static void main(String[] args) throws MQClientException, - InterruptedException, MQClientException { - /* - * Instantiate with a producer group name. - */ - DefaultMQProducer producer = new - DefaultMQProducer("please_rename_unique_group_name"); - /* - * Specify name server addresses. - * <p/> - * - * Alternatively, you may specify name server addresses via exporting - environmental variable: NAMESRV_ADDR - * <pre> - * {@code - * producer.setNamesrvAddr("name-server1-ip:9876;name-server2-ip:9876"); - * } - * </pre> - */ - /* - * Launch the instance. - */ +public class OnewayProducer { + public static void main(String[] args) throws Exception{ + //Instantiate with a producer group name. + DefaultMQProducer producer = new DefaultMQProducer("example_group_name"); + //Launch the instance. producer.start(); - for (int i = 0; i < 1000; i++) { - try { - /* - * Create a message instance, specifying topic, tag and message - body. - */ - Message msg = new Message("TopicTest" /* Topic */, - "TagA" /* Tag */, - ("Hello RocketMQ " + - i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ - ); - /* - * Call send message to deliver message to one of brokers. - */ - producer.sendOneway(msg); - } catch (Exception e) { - e.printStackTrace(); - Thread.sleep(1000); - } + for (int i = 0; i < 100; i++) { + //Create a message instance, specifying topic, tag and message body. + Message msg = new Message("TopicTest" /* Topic */, + "TagA" /* Tag */, + ("Hello RocketMQ " + + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ + ); + //Call send message to deliver message to one of brokers. + producer.sendOneway(msg); + } - /* - * Shut down once the producer instance is not longer in use. - */ + //Shut down once the producer instance is not longer in use. producer.shutdown(); } } -``` \ No newline at end of file +``` http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/_docs/19-filter-by-sql92-example.md ---------------------------------------------------------------------- diff --git a/_docs/19-filter-by-sql92-example.md b/_docs/19-filter-by-sql92-example.md index 52a28ac..f7bec02 100644 --- a/_docs/19-filter-by-sql92-example.md +++ b/_docs/19-filter-by-sql92-example.md @@ -1,11 +1,11 @@ --- -title: "Filter By SQL92 Example " +title: "Filter Example " permalink: /docs/filter-by-sql92-example/ excerpt: "How to filter messages by SQL92 in Apache RocketMQ." modified: 2017-04-26T16:35:00-04:00 --- -In most cases, tag is simple and useful to select message as you want. For example: +In most cases, tag is a simple and useful design to select message you want. For example: ```java DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_EXAMPLE"); @@ -14,11 +14,11 @@ consumer.subscribe("TOPIC", "TAGA || TAGB || TAGC"); {% include toc %} -Consumer will recieve messages that contains TAGA or TAGB or TAGC. But the limitation is that one message only could has one tag, this may be not suitable for more sophisticated scenarios.At this time, you could use sql expression to select messages. +The consumer will recieve messages that contains TAGA or TAGB or TAGC. But the limitation is that one message only can have one tag, and this may not work for sophisticated scenarios. In this case, you can use SQL expression to filter out messages. ### Principle -SQL feature could do some calculation through the properties you put in messages when sending. Under the grammars defined by RocketMQ, you can implement some interesting logic as you want. Here is an example: +SQL feature could do some calculation through the properties you put in when sending messages. Under the grammars defined by RocketMQ, you can implement some interesting logic. Here is an example: <pre> ------------ @@ -39,38 +39,33 @@ SQL feature could do some calculation through the properties you put in messages ### Grammars -RocketMQ only defines some basic grammars to support this feature. Not enough ? You could also extend it easily. +RocketMQ only defines some basic grammars to support this feature. You could also extend it easily. 1. Numeric comparison, like `>`, `>=`, `<`, `<=`, `BETWEEN`, `=`; 2. Character comparison, like `=`, `<>`, `IN`; 3. `IS NULL` or `IS NOT NULL`; -4. Logical `AND`, logical `OR`, logical `NOT`; +4. Logical `AND`, `OR`, `NOT`; -Constant type are: +Constant types are: 1. Numeric, like 123, 3.1415; -2. Character, like 'abc', must be maked with single quotes; +2. Character, like 'abc', must be made with single quotes; 3. `NULL`, special constant; 4. Boolean, `TRUE` or `FALSE`; -### Interface +### Usage constraints -Only push consumer could select messages by SQL92.The interface is: +Only push consumer could select messages by SQL92. The interface is: `public void subscribe(final String topic, final MessageSelector messageSelector)` -### Examples +### Producer example You can put properties in message through method `putUserProperty` when sending. ```java DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); -try { - producer.start(); -} catch (MQClientException e) { - e.printStackTrace(); - return; -} +producer.start(); Message msg = new Message("TopicTest", tag, @@ -84,18 +79,15 @@ SendResult sendResult = producer.send(msg); producer.shutdown(); ``` +### Consumer example + Use `MessageSelector.bySql` to select messages through SQL92 when consuming. ```java DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_4"); -try { - // only subsribe messages have property a, also a >=0 and a <= 3 - consumer.subscribe("TopicTest", MessageSelector.bySql("a between 0 and 3"); -} catch (MQClientException e) { - e.printStackTrace(); - return; -} +// only subsribe messages have property a, also a >=0 and a <= 3 +consumer.subscribe("TopicTest", MessageSelector.bySql("a between 0 and 3"); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-site/blob/a84f68da/home.md ---------------------------------------------------------------------- diff --git a/home.md b/home.md index f70efeb..2790399 100644 --- a/home.md +++ b/home.md @@ -12,29 +12,29 @@ feature_row: - image_path: /assets/images/rmq-feature-lowlatency.png alt: "Low Latency" title: "Low Latency" - excerpt: "More than 99.6% response latency within 1 millisecond under high stress." + excerpt: "More than 99.6% response latency within 1 millisecond under high pressure." - image_path: /assets/images/rmq-feature-finance.png alt: "Finance Oriented" title: "Finance Oriented" - excerpt: "High availability with tracking and auditing characteristics." + excerpt: "High availability with tracking and auditing features." + - image_path: /assets/images/rmq-feature-industry.png + alt: "Industry Sustainable" + title: "Industry Sustainable" + excerpt: "Trillion-level message capacity guaranteed." + +feature_row1: + - image_path: /assets/images/rmq-feature-neutral.png + alt: "Vendor Neutral" + title: "Vendor Neutral" + excerpt: "A new open distributed messaging and streaming standard since latest 4.1 version." - image_path: /assets/images/rmq-feature-bigdata.png alt: "BigData Friendly" title: "BigData Friendly" excerpt: "Batch transferring with versatile integration for flooding throughput." - -feature_row1: - - image_path: /assets/images/rmq-feature-industry.png - alt: "Industry Sustainable" - title: "Industry Sustainable" - excerpt: "Trillions of messages capacity guarantee especially in 11.11 Global Shopping Festival." - image_path: /assets/images/rmq-feature-massiveaccumulation.png alt: "Massive Accumulation" title: "Massive Accumulation" - excerpt: "Accumulate messages as long as having enough disk without performance loss." - - image_path: /assets/images/rmq-feature-neutral.png - alt: "Vendor Neutral" - title: "Vendor Neutral" - excerpt: "A new open distributed messaging and streaming standard since latest 4.x version." + excerpt: "Given sufficient disk space, accumulate messages without performance loss." --- {% include feature_row %}
