Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- consumeMsgs :: MonadBaseControl IO m => Channel -> Text -> Ack -> ((Message, Envelope) -> m ()) -> m ConsumerTag
- consumeMsgs' :: MonadBaseControl IO m => Channel -> Text -> Ack -> ((Message, Envelope) -> m ()) -> (ConsumerTag -> m ()) -> FieldTable -> m ConsumerTag
Documentation
:: MonadBaseControl IO m | |
=> Channel | |
-> Text | Specifies the name of the queue to consume from. |
-> Ack | |
-> ((Message, Envelope) -> m ()) | |
-> m ConsumerTag |
consumeMsgs chan queueName ack callback
subscribes to the given queue and returns a consumerTag. For any incoming message, the callback will be run. If ack ==
you will have to acknowledge all incoming messages (see Ack
ackMsg
and ackEnv
)
NOTE: The callback will be run on the same thread as the channel thread (every channel spawns its own thread to listen for incoming data) so DO NOT perform any request on chan
inside the callback (however, you CAN perform requests on other open channels inside the callback, though I wouldn't recommend it).
Functions that can safely be called on chan
are ackMsg
, ackEnv
, rejectMsg
, recoverMsgs
. If you want to perform anything more complex, it's a good idea to wrap it inside forkIO
.
In addition, while the callback function ((
has access to the captured state, all its side-effects in m are discarded.Message
, Envelope
) -> m ())
:: MonadBaseControl IO m | |
=> Channel | |
-> Text | Specifies the name of the queue to consume from. |
-> Ack | |
-> ((Message, Envelope) -> m ()) | |
-> (ConsumerTag -> m ()) | |
-> FieldTable | |
-> m ConsumerTag |
an extended version of consumeMsgs
that allows you to define a consumer cancellation callback and include arbitrary arguments.