Java Client SDK

Info

This section introduces sending and receiving messages using Apache RocketMQ 5.0 gRPC protocol Java SDK.

Java Client SDK - 图1info

  • This sample code is built based on the gRPC protocol SDK. Therefore, the server needs to be upgraded to at least version 5.0 and enable gRPC Proxy to be compatible. Please refer to the quick start guide for deploying Proxy.
  • If you are using the Remoting protocol SDK, it is recommended to refer to the example code of the previous version 4.x for running. To identify the type of SDK you are using, please refer to the overview.

CodeExample

Here is the link to the sample code for message sending and receiving using the Apache RocketMQ gRPC protocol Java SDK. The complete code project and runtime environment can be found in the rocketmq-clients repository. Please refer to it for configuration and running.

MessageTypesProducer ExamplesPushConsumer ExamplesSimpleConsumer Examples
NormalMessageSync Send Example:ProducerNormalMessageExample.java
Async Send Example:AsyncProducerExample.java
PushConsumerExample.javaSync Sub Message: SimpleConsumerExample.java
Async Sub Message: AsyncSimpleConsumerExample.java
FIFOMessageProducerFifoMessageExample.javaPushConsumerExample.javaSync Sub Message: SimpleConsumerExample.java
Async Sub Message: AsyncSimpleConsumerExample.java
DelayMessageProducerDelayMessageExample.javaPushConsumerExample.javaSync Sub Message: SimpleConsumerExample.java
Async Sub Message: AsyncSimpleConsumerExample.java
TransactionMessageProducerTransactionMessageExample.javaPushConsumerExample.javaSync Sub Message: SimpleConsumerExample.java
Async Sub Message: AsyncSimpleConsumerExample.java