小编Afr*_*ikh的帖子

SimpMessagingTemplate不向websocket发送消息

我有以下控制器

@Controller
public class GreetingController 
{
        @MessageMapping("/hello")
        @SendTo("/topic/greetings")
        public Person greeting(String message) throws Exception {
                Person person=new Person();
                person.setAge(10);
                return person;
        }
        @Autowired
        private SimpMessagingTemplate template;

        @RequestMapping(path="/meeting",method=RequestMethod.POST)
        public  @ResponseBody void greet() {
            this.template.convertAndSend("/topic/greetings", "message");
         }
    }
Run Code Online (Sandbox Code Playgroud)

我的配置是

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig1 extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/hello").withSockJS();
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,根据spring doc template.convertAndSend("/ topic/greetings","message")应该调用代理并调用映射的Web套接字.

使用SockJS的前端代码

var socket = new SockJS('/hello');
                     stompClient = Stomp.over(socket);
                     stompClient.connect({}, function(frame) {
                         console.log('Connected: …
Run Code Online (Sandbox Code Playgroud)

spring-websocket

5
推荐指数
1
解决办法
2291
查看次数

cassandra 2.2 CQl Shell支持python 2.7

尝试启动cql Shell时出现错误

>cqlsh
CQL Shell supports only Python 2.7
>
Run Code Online (Sandbox Code Playgroud)

我已经安装了python2.7,但它仍然给出相同的错误。我必须设置一些路径吗?我已经使用以下命令从datastax安装了Cassandra 2.2

sudo yum install dsc22
Run Code Online (Sandbox Code Playgroud)

cql cassandra-2.0

1
推荐指数
1
解决办法
4490
查看次数

标签 统计

cassandra-2.0 ×1

cql ×1

spring-websocket ×1