niho / elm-stomp / Stomp.Subscription

A subscription on a topic.

Subscriptions


type alias Subscription msg =
Stomp.Internal.Batch.Batch (Stomp.Internal.Subscription.Sub msg)

Describes a subscription.

init : String -> Subscription msg

Construct a subscription on a specific topic.

Response

onMessage : Stomp.Internal.Callback.Callback msg -> Subscription msg -> Subscription msg

Set a callback to be triggered when a message is received.

expectJson : (Result String a -> msg) -> Json.Decode.Decoder a -> Subscription msg -> Subscription msg

Set a callback to be triggered when a message is received and a JSON decoder to be used to decode the message body.

Subscription Identifier

withSubscriptionId : String -> Subscription msg -> Subscription msg

Set the id of the subscription to differentiate between multiple subscriptions to the same topic (default is to use the topic name).

Acknowledgement

autoAck : Subscription msg -> Subscription msg

Set the message acknowledgment mode to "auto" (the default).

When the ack mode is "auto", then the client does not need to send the server acknowledgements for the messages it receives. The server will assume the client has received the message as soon as it sends it to the client. This acknowledgment mode can cause messages being transmitted to the client to get dropped.

clientAck : Subscription msg -> Subscription msg

Set the message acknowledgment mode to "client".

When the ack mode is "client", then the client must send the server acknowledgements for the messages it processes. If the connection fails before a client sends an acknowledgement for the message the server will assume the message has not been processed and may redeliver the message to another client.

clientIndividualAck : Subscription msg -> Subscription msg

Set the message acknowledgment mode to "client-individual".

When the ack mode is "client-individual", the acknowledgment operates just like the "client" acknowledgment mode except that the ack or nack sent by the client are not cumulative. This means that an ack or nack for a subsequent message does not cause a previous message to get acknowledged.

Batching

batch : List (Subscription msg) -> Subscription msg

Batch multiple subscriptions together.

none : Subscription msg

Return a subscription that does nothing.