Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RocketMQ

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

RocketMQ

This document is mainly about the actual use of rocketmq code, introduction of common words, etc., to see other documents.

As soon as download

Download address of http://rocketmq.apache.org/release_notes/release-notes-4.3.2/ binary file, which can be decompressed and run directly after download

Download address of https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.3.2/rocketmq-all-4.3.2-source-release.zip source code. You need to package it yourself after downloading.

Two start 2.1Startup nameserver

Enter the bin directory of rocketmq

Nohup sh mqnamesrv &

2.2 start broker server

Enter the bin directory

Nohup sh mqbroker-n localhost:9876 autoCreateTopicEnable=true &

For cluster mode, please see Cluster configuration File RocketMQ Cluster.

2.3 Startup failed

By default, our servers are separate stand-alone servers, which will not happen, but we used a virtual machine during the test, and the configuration is not enough, so it will not be able to start.

Modify runbroker.sh and runserver.sh

Find the indicated location in the following figure respectively.

Just modify the memory size. Please adjust the memory size according to the configuration of your virtual machine. For example, I modify it to the following values.

Three graphical interfaces

It is not necessary here, it is less used in actual development.

Download rocketmq-console source code: https://github.com/apache/rocketmq-externals

Go to the subdirectory rocketmq-console

Execute the mvn command to package

Mvn clean package-DskipTests

Enter the target directory

Rocketmq-console-ng-1.0.0.jar is the springBoot project

From this directory, CMD executes the command:

Java-jar rocketmq-console-ng-1.0.0.jar-server.port=12581-rocketmq.config.namesrvAddr=10.89.0.65:9876

Among them

-- server.port is the port on which the web application is running. If it is not set, it defaults to 8080 address of RocketMQ naming service. If it is not set, it defaults to ""

OK, visit http://localhost:12581 and try it.

Or pack it into a war package and throw it into tomcat to run.

Four entry cases

In this case, a consumer is used, so there is only one consumer code

4.1 pom.xml

Org.apache.rocketmq

Rocketmq-client

4.3.2

4.2 synchronous message mode

Principle: synchronous transmission refers to the communication mode in which the sender sends the data and then sends the next data packet after receiving the response from the receiver.

Application scenarios: this method is widely used, such as important notification email, registration SMS notification, marketing SMS system and so on.

4.2.1 producer

/ * *

* Created by jackiechan on 18-8-19 / 8:37

* principle: synchronous transmission refers to the communication method in which the sender sends data and then sends the next data packet after receiving the response from the receiver.

*

* Application scenarios: this method is used in a wide range of scenarios, such as important notification email, registration SMS notification, marketing SMS system, etc.

, /

Public class SyncProducer01 {

Public static void main (String [] args) throws Exception {

/ / Instantiate with a producer group name.

DefaultMQProducer producer = new

DefaultMQProducer ("group1"); / / groupname the same group representative is a cluster

/ / Launch the instance.

Producer.setNamesrvAddr ("192.168.3.8 9876"); / / set the nameserver address

/ / set the instance name

Producer.setInstanceName ("producer"); / / does not need to be set by default. It takes ip@pid as its name. Ip is the machine ip,pid and jvmpid.

Producer.start ()

For (int I = 0; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report