【发布时间】:2018-07-07 08:58:47
【问题描述】:
如果用户未订阅,我如何从 activeMQ 中删除队列,我的系统中有很多用户,所以我认为如果用户未从 activeMQ 中删除,将会是性能问题,我使用的是 spring boot 和 WebSocketConfig,这是我的实现:
@Service
public class NotificationWebSocketService {
@Autowired
private SimpMessagingTemplate messagingTemplate;
public void initiateNotification(WebSocketNotification notificationData) throws InterruptedException {
Map<String, Object> headers = new HashMap<>();
headers.put("expires", System.currentTimeMillis() + 20000);
messagingTemplate.convertAndSendToUser(notificationData.getUserID(), "/reply", notificationData.getMessage(),headers);
}
}
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config
.setApplicationDestinationPrefixes("/app")
.setUserDestinationPrefix("/user")
.enableStompBrokerRelay("/topic","/queue","/user")
.setRelayHost("localhost")
.setRelayPort(61613);
}
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/websocket").withSockJS();
}
}
【问题讨论】:
标签: spring spring-boot activemq stomp spring-websocket