title: How to close a STOMP websocket in a spring server
body: <p><br>
  I am using spring-websocket and spring-messaging (version 4.2.2.RELEASE) to implement STOMP over websockets with a fully-featured broker (Apache ActiveMQ 5.10.0). <br>
  My clients are meant to SUBSCRIBE to destinations only - that is they should should not be able to SEND messages. Furthermore, I would like to implement a stricter control over what destinations my clients can subscribe to. In either case (that is when a client tries to send a message or subscribe to an invalid destination) I would like to be able to</p>
  
  <ol>
  <li>send an appropriate error, and/or</li>
  <li>close the websocket</li>
  </ol>
  
  <p>Please note that all my destinations are forwarded to ActiveMQ. I thought that I could implement a <a href="https://docs.spring.io/spring/docs/4.2.2.RELEASE/javadoc-api/org/springframework/messaging/support/ChannelInterceptor.html" rel="noreferrer">ChannelInterceptor</a> on the inbound channel, but looking at the API I cannot figure out how to achieve what I want. Is this possible, and what is the best way to go about validating client requests?
  My websocket configuration is below:</p>
  
  <pre><code>&lt;websocket:message-broker
      application-destination-prefix="/app"&gt;
      &lt;websocket:stomp-endpoint path="/pushchannel"/&gt;
      &lt;websocket:stomp-broker-relay relay-host="localhost"
          relay-port="61613" prefix="/topic"
          heartbeat-receive-interval="300000" heartbeat-send-interval="300000" /&gt;
      &lt;websocket:client-inbound-channel&gt;
          &lt;websocket:interceptors&gt;
              &lt;bean class="MyClientMessageInterceptor"/&gt;
          &lt;/websocket:interceptors&gt;
      &lt;/websocket:client-inbound-channel&gt;
  &lt;/websocket:message-broker&gt;
  </code></pre>