Skip to content
Guy M. Allard edited this page Aug 14, 2018 · 8 revisions

Original Issue

This section will discuss stompngo Issue 25. The original title of the issue is:

Potential blocking on unsubscribe with message in flight

A link to that issue is here:

https://github.com/gmallard/stompngo/issues/25

Client Operation

Suppose that N queues (say 10) are filled with messages (say 100 messages). The client wishes to:

  • Read 1 message from queue 1, then UNSUBSCRIBE
  • Read 2 message from queue 2, then UNSUBSCRIBE
  • Read 3 message from queue 3, then UNSUBSCRIBE
  • etc.

Under these conditions, an unmodified stompngo package will block / hang attempting to execute UNSUBSCRIBE.

Workaround 1

In order to provide a client with the ability to implement the above described behavior, 9bc3158 was comitted.

Client Requirements

This essentially implements a stompngo specific extension to the STOMP protocol. This extension operates per below.

The client must know a priori how many messages are to be received from a given queue.

SUBSCRIBE Requirements

The stompngo client program must add a user header to the initial SUBSCRIBE for a queue. An example of such a header is:

sng_drafter:xxxx

The header key sng_drafter is meant to mean "stompngo drain after".

The header value xxxx is a numeric value which is the number of messages to receive before beginning a draining operation.

stompngo READER operation

The stompngo READER functionality keeps a running count of the messages received for each subscription. After the number specified by sng_drafter the READER routine will discard all subsequent MESSAGE frames.

Note that RECEIPT and ERROR frames are never discarded.

UNSUBSCRIBE Requirements

The client issues UNSUBSCRIBE normally.

Limitations

If this extension is used, expect that applications depending on proper flows of RECEIPT frames are unlikely to work as designed.

Example Client

An example client that uses this extension functionality can be found here:

Variable Message Getter

Workaround 2

In order to provide a client with an alternative to implement the above described behavior, 512e8d8 was comitted.

Client Requirements

This essentially implements a stompngo specific extension to the STOMP protocol. This extension operates per below.

SUBSCRIBE Requirements

The client uses SUBSCRIBE as per normal.

UNSUBSCRIBE Requirements

The stompngo client program must add a user header to the UNSUBSCRIBE for a queue. An example of such a header is:

sng_drnow:xxxx

The header key sng_drnow is meant to mean "stompngo drain now".

The header value xxxx is a numeric value which is the maximum number of milliseconds the extension will wait before assuming the queue is totally drained. The extension then sends the UNSUBSCRIBE frame as normal.

Limitations

If this extension is used, expect that applications depending on proper flows of RECEIPT frames are unlikely to work as designed.

Example Client

An example client that uses this extension functionality can be found here:

Variable Message Getter 2