View Source Mammoth (mammoth v0.3.0)
Mammoth: A STOMP client.
Use Mammoth
as the primary API and Mammoth.Message
for working with received messages.
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
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]])
]
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 (referenced in the MESSAGE ack
header)
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 (referenced in the MESSAGE ack
header)
Send a SEND message to the remote server. content-length header will be automatically added.
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 (not required with :auto) 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, virtual_host, login, password, additional_headers \\ [])
View SourceConnect to server.
host
must be inet:socket_address() | inet:hostname()
, for example {127,0,0,1}
or 'example.com'
.
virtual_host
(host
header) is mandatory in STOMP 1.2, behaviour is server defined. Default on RabbitMQ would be "/"
.
https://stomp.github.io/stomp-specification-1.2.html#CONNECT_or_STOMP_Frame
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 (referenced in the MESSAGE ack
header)
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 (referenced in the MESSAGE ack
header)
Send a SEND message to the remote server. content-length header will be automatically added.
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 (not required with :auto) https://stomp.github.io/stomp-specification-1.2.html#SUBSCRIBE_ack_Header
Unsubscribe from a queue.