parent
11f5226fe6
commit
fc37221eee
@ -1,33 +0,0 @@
|
||||
package com.dsideal.aiSupport.Config;
|
||||
|
||||
import org.apache.rocketmq.client.apis.ClientConfiguration;
|
||||
import org.apache.rocketmq.client.apis.ClientConfigurationBuilder;
|
||||
import org.apache.rocketmq.client.apis.ClientServiceProvider;
|
||||
|
||||
public class RocketMQConfig {
|
||||
// RocketMQ服务器地址
|
||||
private static final String ENDPOINT = "10.10.14.14:8081";
|
||||
// 默认主题
|
||||
private static final String DEFAULT_TOPIC = "TestTopic";
|
||||
|
||||
private static ClientServiceProvider provider;
|
||||
private static ClientConfiguration configuration;
|
||||
|
||||
static {
|
||||
provider = ClientServiceProvider.loadService();
|
||||
ClientConfigurationBuilder builder = ClientConfiguration.newBuilder().setEndpoints(ENDPOINT);
|
||||
configuration = builder.build();
|
||||
}
|
||||
|
||||
public static ClientServiceProvider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static ClientConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public static String getDefaultTopic() {
|
||||
return DEFAULT_TOPIC;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.dsideal.aiSupport.Test;
|
||||
|
||||
import com.dsideal.aiSupport.Config.RocketMQConfig;
|
||||
import org.apache.rocketmq.client.apis.ClientException;
|
||||
import org.apache.rocketmq.client.apis.message.Message;
|
||||
import org.apache.rocketmq.client.apis.producer.Producer;
|
||||
import org.apache.rocketmq.client.apis.producer.SendReceipt;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessageProducer.class);
|
||||
private Producer producer;
|
||||
|
||||
public MessageProducer() {
|
||||
try {
|
||||
producer = RocketMQConfig.getProvider().newProducerBuilder()
|
||||
.setTopics(RocketMQConfig.getDefaultTopic())
|
||||
.setClientConfiguration(RocketMQConfig.getConfiguration())
|
||||
.build();
|
||||
} catch (ClientException e) {
|
||||
logger.error("Failed to create producer", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(String topic, String tag, String key, String body) {
|
||||
try {
|
||||
Message message = RocketMQConfig.getProvider().newMessageBuilder()
|
||||
.setTopic(topic)
|
||||
.setKeys(key)
|
||||
.setTag(tag)
|
||||
.setBody(body.getBytes())
|
||||
.build();
|
||||
|
||||
SendReceipt sendReceipt = producer.send(message);
|
||||
logger.info("Send message successfully, messageId={}", sendReceipt.getMessageId());
|
||||
} catch (ClientException e) {
|
||||
logger.error("Failed to send message", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (producer != null) {
|
||||
producer.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.dsideal.aiSupport.Test;
|
||||
|
||||
import com.dsideal.aiSupport.Config.RocketMQConfig;
|
||||
import org.apache.rocketmq.client.apis.ClientException;
|
||||
import org.apache.rocketmq.client.apis.consumer.FilterExpression;
|
||||
import org.apache.rocketmq.client.apis.consumer.FilterExpressionType;
|
||||
import org.apache.rocketmq.client.apis.consumer.MessageListener;
|
||||
import org.apache.rocketmq.client.apis.consumer.PushConsumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
public class MessagePushConsumer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessagePushConsumer.class);
|
||||
private PushConsumer pushConsumer;
|
||||
|
||||
public MessagePushConsumer(String consumerGroup, String topic, String tag, MessageListener messageListener) {
|
||||
try {
|
||||
FilterExpression filterExpression = new FilterExpression(tag, FilterExpressionType.TAG);
|
||||
pushConsumer = RocketMQConfig.getProvider().newPushConsumerBuilder()
|
||||
.setClientConfiguration(RocketMQConfig.getConfiguration())
|
||||
.setConsumerGroup(consumerGroup)
|
||||
.setSubscriptionExpressions(Collections.singletonMap(topic, filterExpression))
|
||||
.setMessageListener(messageListener)
|
||||
.build();
|
||||
|
||||
logger.info("Consumer started successfully");
|
||||
} catch (ClientException e) {
|
||||
logger.error("Failed to create consumer", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (pushConsumer != null) {
|
||||
pushConsumer.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.dsideal.aiSupport.Test;
|
||||
|
||||
import org.apache.rocketmq.client.apis.consumer.ConsumeResult;
|
||||
import org.apache.rocketmq.client.apis.consumer.MessageListener;
|
||||
import org.apache.rocketmq.client.apis.message.MessageView;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MyMessageListener implements MessageListener {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MyMessageListener.class);
|
||||
|
||||
@Override
|
||||
public ConsumeResult consume(MessageView messageView) {
|
||||
try {
|
||||
String messageId = String.valueOf(messageView.getMessageId());
|
||||
String topic = messageView.getTopic();
|
||||
String tag = String.valueOf(messageView.getTag());
|
||||
byte[] body = messageView.getBody().array();
|
||||
String content = new String(body);
|
||||
|
||||
logger.info("Received message: messageId={}, topic={}, tag={}, content={}",
|
||||
messageId, topic, tag, content);
|
||||
|
||||
// 处理消息的业务逻辑
|
||||
|
||||
return ConsumeResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to consume message", e);
|
||||
return ConsumeResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
# 官网
|
||||
https://docmee.cn/
|
||||
|
||||
# 用户名与密码
|
||||
18686619970
|
||||
密码:手机验证码
|
||||
|
||||
# 体验
|
||||
https://www.veasion.cn/AiPPT/
|
||||
|
||||
# 充值
|
||||
https://open.docmee.cn/open/workspace/top-up
|
||||
未充值
|
||||
|
||||
# 模板选择【展示】
|
||||
https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202505131336410.png
|
@ -0,0 +1 @@
|
||||
https://help.aliyun.com/zh/model-studio/emo-api?spm=a2c4g.11186623.help-menu-2400256.d_2_3_4_1.7d8a5f84mfOU9j
|
@ -0,0 +1 @@
|
||||
https://www.volcengine.com/docs/82379/1520757
|
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 891 KiB |
@ -0,0 +1,3 @@
|
||||
https://goapi.gptnb.ai/account/profile
|
||||
littlehb
|
||||
mdcija780522
|
Loading…
Reference in new issue