mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
feat: 停止当前聊天输出接口功能完善
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.xboe.config;
|
||||
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jms.annotation.EnableJms;
|
||||
@@ -14,12 +15,16 @@ import javax.jms.Topic;
|
||||
@Configuration
|
||||
public class MqConfig {
|
||||
|
||||
@Value("${activemq.topic.name}")
|
||||
private String topicName;
|
||||
|
||||
|
||||
/**
|
||||
* 配置topic
|
||||
*/
|
||||
@Bean
|
||||
public Topic broadcastTopic() {
|
||||
return new ActiveMQTopic("broadcast.session.termination");
|
||||
return new ActiveMQTopic(topicName);
|
||||
}
|
||||
|
||||
// 配置JmsListenerContainerFactory为发布/订阅模式
|
||||
|
||||
@@ -19,8 +19,7 @@ public class BroadcastMessageConsumer {
|
||||
*
|
||||
* @param conversationId 会话ID
|
||||
*/
|
||||
@JmsListener(destination = "broadcast.session.termination",
|
||||
containerFactory = "jmsListenerContainerFactory")
|
||||
@JmsListener(destination = "${activemq.topic.name}")
|
||||
public void receiveSessionTerminationBroadcastMessage(String conversationId) {
|
||||
log.info("收到会话终止广播消息:{}", conversationId);
|
||||
iCaseAiChatService.eventSourceCancel(conversationId);
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.jms.Topic;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -106,8 +107,8 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
@Autowired
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
@Value("${activemq.topic.name}")
|
||||
private String topicName;
|
||||
@Autowired
|
||||
private Topic topic;
|
||||
|
||||
// 用于存储会话ID与EventSource的映射关系,以便能够中断特定会话
|
||||
private final Map<String, EventSource> conversationEventSourceMap = new ConcurrentHashMap<>();
|
||||
@@ -772,7 +773,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
log.info("收到停止会话 {} 的指令", conversationId);
|
||||
// 发送广播消息,通知中断连接
|
||||
try {
|
||||
jmsTemplate.convertAndSend(topicName, conversationId);
|
||||
jmsTemplate.convertAndSend(topic, conversationId);
|
||||
} catch (JmsException e) {
|
||||
log.error("发送停止会话 {} 输出时发生异常", conversationId, e);
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,12 @@ spring:
|
||||
connection-timeout: 30000
|
||||
max-lifetime: 1800000
|
||||
maximum-pool-size: 20
|
||||
activemq:
|
||||
broker-url: tcp://192.168.0.253:61616
|
||||
user: admin
|
||||
password: admin
|
||||
jms:
|
||||
pub-sub-domain: true
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
|
||||
@@ -40,6 +40,12 @@ spring:
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/10/static
|
||||
activemq:
|
||||
broker-url: tcp://10.251.129.51:61616
|
||||
user: admin
|
||||
password: admin
|
||||
jms:
|
||||
pub-sub-domain: true
|
||||
server:
|
||||
port: 9090
|
||||
tomcat:
|
||||
|
||||
@@ -33,6 +33,12 @@ spring:
|
||||
connection-timeout: 30000
|
||||
max-lifetime: 1800000
|
||||
maximum-pool-size: 20
|
||||
activemq:
|
||||
broker-url: tcp://10.251.113.100:61616
|
||||
user: admin
|
||||
password: admin
|
||||
jms:
|
||||
pub-sub-domain: true
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
|
||||
@@ -40,6 +40,12 @@ spring:
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/10/static
|
||||
activemq:
|
||||
broker-url: tcp://10.251.129.25:61616
|
||||
user: admin
|
||||
password: admin
|
||||
jms:
|
||||
pub-sub-domain: true
|
||||
server:
|
||||
port: 9090
|
||||
tomcat:
|
||||
|
||||
Reference in New Issue
Block a user