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.
Connect to server.
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
.
connect(pid, host, port, login, password, additional_headers \\ [])
View SourceConnect to server.
host
must be inet:socket_address() | inet:hostname()
, for example {127,0,0,1}
.
Disconnect from server.
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.
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(pid, destination, ack_mode \\ :auto, additional_headers \\ [])
View SourceSubscribe 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.