Giter Club home page Giter Club logo

rocketmq-spring-boot-starter's Introduction

rocketmq-spring-boot-starter

AliYun RocketMQ Spring Book Edition

δΈ­ζ–‡

Support function:

  • Three modes of sending ordinary messages: synchronous, asynchronous and one-way
  • Subscribe to Message Cluster, Broadcast
  • Send and receive sequential messages
  • Transaction messages
  • Delay message
  • receive and receive timing messages

Tips:

Delay message and timing message: In the official case, delayed news is much the same as regular news, essentially ordinary news. If delay message and timing message are needed, it is recommended to use timing task (timing task scheduling platform) To achieve the purpose of delay or timing.

Quick Start

<!--Adding dependencies to pom. XML-->
        <dependency>
            <artifactId>rocketmq-spring-boot-starter</artifactId>
            <groupId>com.github.thierrysquirrel</groupId>
            <version>2.0.2-RELEASE</version>
        </dependency>

configuration file

## application.properties
thierrysquirrel.access-key= #The Access Key you created in the AliYun Account Management Console for authentication
thierrysquirrel.secret-key= #The SecretKey you created in the AliYun Account Management Console for authentication
thierrysquirrel.name-srv-addr= #Set up TCP protocol access point and get it from console

Start RocketMQ

@SpringBootApplication
@EnableRocketMQ
public class DemoApplication{
    public static void main(String[] args){
        SpringApplication.run(DemoApplication.class, args);
    }
   
}

Three Ways to Send Common Messages

@RestController
@RocketMessage(groupID = "GID_common")
public class Common {

	@GetMapping("/commonA")
	@CommonMessage(topic = "commonA", tag = "commonA",messageSendType = MessageSendType.SEND)
	public String h() {
		return "commonA";
	}
	@GetMapping("/commonB")
	@CommonMessage(topic = "commonB", tag = "commonB",messageSendType = MessageSendType.SEND_ASYNC)
	public String hh() {
		return "commonB";
	}
	@GetMapping("/commonC")
	@CommonMessage(topic = "commonC", tag = "commonC",messageSendType = MessageSendType.SEND_ONE_WAY)
	public String hhh() {
		return "commonC";
	}
}

Send sequential messages

@RestController
@RocketMessage(groupID = "GID_order")
public class Order {
	@GetMapping("/order")
	@OrderMessage(topic = "order",tag = "order")
	public String order() {
		return "order";
	}
}

Send Transaction Messages

@RestController
@RocketMessage(groupID = "GID_transaction")
public class Transaction {
	@GetMapping("/transaction")
	@TransactionMessage(topic = "transaction",tag = "transaction")
	public String transaction() {
		return "transaction";
	}
}

Delay message or timing message

@RestController
@RocketMessage(groupID = "GID_delayed")
public class Delayed {
	@GetMapping("/delayed")
	@CommonMessage(topic = "delayed", tag = "delayed",startDeliverTime = 10)
	public String delayed() {
		return "delayed";
	}
}

Subscribe to regular, transactional, delayed, timed messages

@RocketListener(groupID = "GID_message")
public class Delayed {
    @MessageListener(topic = "message",tag = "message")	
    public void delayed(String message) {
            return "message";
    }
}

Subscription order message

@RocketListener(groupID = "GID_message")
public class Delayed {
    @MessageListener(topic = "message",tag = "message", orderConsumer = true)
    public void delayed(String message) {
            return "message";
    }
}

rocketmq-spring-boot-starter's People

Contributors

thierrysquirrel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.