+49 228 5552576-0


info@predic8.com

STOMP over WebSockets intercepting

Membrane Service Proxy can route and intercept WebSocket traffic. For further information on this please visit the WebSocket routing and intercepting page.

As STOMP over WebSockets utilizes WebSockets to send its messages one can also route and intercept STOMP messages. The same tool kit that is used for WebSocket routing and intercepting can also be used for STOMP over WebSocket.

To make this process easier Membrane Service Proxy has its own WebSocket interceptor to read and manipulate STOMP messages. STOMP behaves similiar to HTTP and so the wsStompReassembler converts a STOMP message to the known Membrane exchange format and thus makes it easy to manipulate the STOMP message.

The wsStompReassembler

The wsStompReassembler is a WebSocket interceptor with the purpose to make manipulating STOMP message easier. For this it maps the content of a STOMP message to a Membrane exchange (specifically: to the request of an exchange)

The following mapping is done:

You can then access the content of a STOMP message through the properties of the request object of the exchange. STOMP up to version 1.2 is supported.

The wsStompReassembler has its own interceptor chain that uses standard Membrane interceptors. Interceptors can be added as child elements to the wsStompReassembler. The following listing shows an example configuration.

					<serviceProxy port="8080">
						<webSocket>
							<wsStompReassembler>
								<groovy>
									if(!"secretPassword“.equals(exc.getRequest().getHeader().getFirstValue("password“))
										RETURN;
								</groovy>
							</ wsStompReassembler>
						</ webSocket>
						<target host="localhost" port="2001" />
					</serviceProxy>
Listing 1: STOMP over WebSockets intercepting with groovy interceptor

In this listing a groovy interceptor is used to check if the provided password is equal to „secretPassword“. If it is not, then the request is blocked.

Limitations

The wsStompReassembler can run normal Membrane interceptors on STOMP messages. This comes not without limitations as the mapping of STOMP messages to Membrane exchanges is not perfect. The following limitations apply to STOMP message intercepting through the wsStompReassembler:

Getting Started

See $MEMBRANE_HOME/examples/stomp-over-websocket-intercepting in the Membrane Service Proxy distribution for a working example.

Copyright © 2008-2017 predic8 GmbH
Koblenzerstr. 65, 53173 Bonn, Tel. +49 (228) 555 25 76-0