View Source Mammoth (mammoth v0.2.0)

Mammoth: A STOMP client.

Use Mammoth as the primary API and Mammoth.Message for working with received messages.

example

Example

{:ok, callback_pid} = Mammoth.DefaultCallbackHandler.start_link
{:ok, pid} = Mammoth.start_link(callback_pid)
:ok = Mammoth.DefaultCallbackHandler.set_mammoth_pid(callback_pid, pid)
Mammoth.connect(pid, {127,0,0,1}, 61613, "admin", "admin")
Mammoth.subscribe(pid, "foo.bar", :client)
Mammoth.disconnect(pid)

starting-in-a-supervision-tree

Starting in a supervision tree

children = [
  worker(Mammoth, [%{}, [name: Mammoth]])
]

intended-use

Intended use

My recommendation is to start mammoth from within your own implementation of the callback handler,
and to put the callback handler itself into a supervisor

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Disconnect from server.

Requests disconnection from the remote server

Callback implementation for GenServer.init/1.

Receive messages from the TCP socket.

Send an ACK message to the remote server for the specified frame

Send an ACK message to the remote server for the specified frame ID

Send a frame to the remote server

Send an NACK message to the remote server for the specified frame

Send an NACK message to the remote server for the specified frame ID

Send a SEND message to the remote server

Subscribe to a queue. Note that if you set ack_mode to :client_individual or :client, you must send ACK frames when you receive MESSAGE frames https://stomp.github.io/stomp-specification-1.2.html#SUBSCRIBE_ack_Header

Unsubscribe from a queue.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

connect(pid, host, port, login, password, additional_headers \\ [])

View Source

Connect to server.

host must be inet:socket_address() | inet:hostname(), for example {127,0,0,1}.

Disconnect from server.

Link to this function

handle_call(msg, from, state)

View Source

Requests disconnection from the remote server

Callback implementation for GenServer.init/1.

Receive messages from the TCP socket.

Is called automatically when necessary. Should not be called manually.

Link to this function

send_ack_frame(pid, message, additional_headers \\ [])

View Source

Send an ACK message to the remote server for the specified frame

Link to this function

send_ack_id(pid, id, additional_headers)

View Source

Send an ACK message to the remote server for the specified frame ID

Link to this function

send_frame(pid, message)

View Source

Send a frame to the remote server

Link to this function

send_nack_frame(pid, message, additional_headers \\ [])

View Source

Send an NACK message to the remote server for the specified frame

Link to this function

send_nack_id(pid, id, additional_headers)

View Source

Send an NACK message to the remote server for the specified frame ID

Link to this function

send_send(pid, destination, body, additional_headers \\ [])

View Source

Send a SEND message to the remote server

Link to this function

start_link(callback_handler, state \\ %{}, opts \\ [])

View Source
Link to this function

subscribe(pid, destination, ack_mode \\ :auto, additional_headers \\ [])

View Source

Subscribe to a queue. Note that if you set ack_mode to :client_individual or :client, you must send ACK frames when you receive MESSAGE frames https://stomp.github.io/stomp-specification-1.2.html#SUBSCRIBE_ack_Header

Link to this function

unsubscribe(pid, destination)

View Source

Unsubscribe from a queue.