You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by aa...@apache.org on 2022/07/31 12:46:18 UTC
[rocketmq-clients] branch master updated: Add apache parent pom (#115)
This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 2f624a3 Add apache parent pom (#115)
2f624a3 is described below
commit 2f624a3a35d91df90a0e08ec61026f4f1d948ca4
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Sun Jul 31 20:46:13 2022 +0800
Add apache parent pom (#115)
---
java/README.md | 2 +-
java/example.md | 141 --------------------------------------------------------
java/pom.xml | 6 +++
3 files changed, 7 insertions(+), 142 deletions(-)
diff --git a/java/README.md b/java/README.md
index 20e6728..9248a92 100644
--- a/java/README.md
+++ b/java/README.md
@@ -33,7 +33,7 @@ the no-shaded client.
</dependency>
```
-You can see more code examples [here](./example.md).
+You can see more code examples [here](./client/src/main/java/org/apache/rocketmq/client/java/example).
## Logging System
diff --git a/java/example.md b/java/example.md
deleted file mode 100644
index 9f0683a..0000000
--- a/java/example.md
+++ /dev/null
@@ -1,141 +0,0 @@
-# Code Example
-
-## Provider
-
-There is a provider based on the Java SPI mechanism, the provider here can derive specific implementations.
-
-```java
-// Find the implementation of APIs according to SPI mechanism.
-final ClientServiceProvider provider = ClientServiceProvider.loadService();
-StaticSessionCredentialsProvider staticSessionCredentialsProvider =
- new StaticSessionCredentialsProvider(accessKey, secretKey);
-ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder()
- .setEndpoints(endpoints)
- .setCredentialProvider(staticSessionCredentialsProvider)
- .build();
-```
-
-## Producer
-
-There are examples for 4 types of message.
-
-### Publish NORMAL Message
-
-```java
-// Build your message.
-final Message message = provider.newMessageBuilder()
- .setTopic(normalTopic)
- .setBody(body)
- .setTag(tag)
- .build();
-// Build your producer.
-Producer producer = provider.newProducerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setTopics(topic)
- .build();
-final SendReceipt sendReceipt = producer.send(message);
-// Close it when you don't need the producer anymore.
-producer.close();
-```
-
-### Publish FIFO Message
-
-```java
-// Build your message.
-final Message message = provider.newMessageBuilder()
- .setTopic(fifoTopic)
- .setBody(body)
- // Set the message group for FIFO message.
- .setMessageGroup(messageGroup)
- .setTag(tag)
- .build();
-// Build your producer.
-Producer producer = provider.newProducerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setTopics(topic)
- .build();
-final SendReceipt sendReceipt = producer.send(message);
-// Close it when you don't need the producer anymore.
-producer.close();
-```
-
-### Publish DELAY Message
-
-```java
-// Build your message.
-final Message message = provider.newMessageBuilder()
- .setTopic(delayTopic)
- .setBody(body)
- // Set the delivery timestamp to 3 seconds later (Time unit: milliseconds).
- .setDeliveryTimestamp(System.currentTimeMillis() + 3 * 1000)
- .setTag(tag)
- .build();
-// Build your producer.
-Producer producer = provider.newProducerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setTopics(topic)
- .build();
-final SendReceipt sendReceipt = producer.send(message);
-// Close it when you don't need the producer anymore.
-producer.close();
-```
-
-### Publish TRANSACTIONAL Message
-
-```java
-// Build your message.
-final Message message = provider.newMessageBuilder()
- .setTopic(transactionalTopic)
- .setBody(body)
- .setTag(tag)
- .build();
-// Build your producer.
-Producer producer = provider.newProducerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setTopics(transactionalTopic)
- // Set transactional checker.
- .setTransactionChecker(messageView -> TransactionResolution.COMMIT)
- .build();
-Transaction transaction = producer.beginTransaction();
-SendReceipt receipt = producer.send(message, transaction);
-transaction.commit();
-// Close it when you don't need the producer anymore.
-producer.close();
-```
-
-## PushConsumer
-
-```java
-// Build your push consumer.
-PushConsumer pushConsumer = provider.newPushConsumerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setConsumerGroup(consumerGroup)
- .setSubscriptionExpressions(Collections.singletonMap(topic, filterExpression))
- .setMessageListener(messageView -> {
- // Handle the received message and return the consume result.
- return ConsumeResult.SUCCESS;
- })
- .build();
-// Close it when you don't need the consumer anymore.
-pushConsumer.close();
-```
-
-## SimpleConsumer
-
-```java
-// Build your simple consumer.
-SimpleConsumer simpleConsumer = provider.newSimpleConsumerBuilder()
- .setClientConfiguration(clientConfiguration)
- .setConsumerGroup(consumerGroup)
- .setAwaitDuration(awaitDuration)
- .setSubscriptionExpressions(Collections.singletonMap(topic, filterExpression))
- .build();
-// Try to receive message from server.
-final List<MessageView> messageViews = simpleConsumer.receive(1, invisibleDuration);
-for (MessageView messageView : messageViews) {
- // Ack or change invisible time according to your needs.
- simpleConsumer.ack(messageView);
-}
-// Close it when you don't need the consumer anymore.
-simpleConsumer.close();
-```
diff --git a/java/pom.xml b/java/pom.xml
index 576da30..8a30f8d 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -17,6 +17,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>18</version>
+ </parent>
+
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.rocketmq</groupId>