Copyright | (c) Hemanth Kapila, 2014 |
---|---|
License | BSD3 |
Maintainer | saihemanth@gmail.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Provides API to pull from and push to ServiceBus queue Please refer to Service Bus Rest API for information on the API provided by Microsoft Service bus.
Simple example for how to use this library is as below
import Web.WindowsAzure.ServiceBus.Queue import Web.WindowsAzure.ServiceBus import qualified Data.ByteString.Char8 as C queueName = "queueName" sbNamespace = "namespace" sbIssuerKey = C.pack "1287361251262as=" sbIssuerName = C.pack "owner" sbinfo = SBInfo sbNamespace sbIssuerName sbIssuerKey message = C.pack "Hello from Haskell" main = do sbContext <- sbContext sbinfo enQueueBS queueName message sbContext res <- deQueue queueName 30 sbContext print res
see examples (available as a part of distribution) for a more detailed example.
- data QLockedMsgInfo
- enQueueBS :: String -> ByteString -> SBContext -> IO ()
- enQueueLBS :: String -> ByteString -> SBContext -> IO ()
- enQueueBodySrc :: String -> Int64 -> Source IO ByteString -> SBContext -> IO ()
- deQueue :: String -> Int -> SBContext -> IO ByteString
- peekLockQueue :: String -> Int -> SBContext -> IO (QLockedMsgInfo, ByteString)
- unlockMessage :: String -> QLockedMsgInfo -> SBContext -> IO ()
- deleteMessage :: String -> QLockedMsgInfo -> SBContext -> IO ()
- renewLock :: String -> QLockedMsgInfo -> SBContext -> IO ()
Documentation
data QLockedMsgInfo Source
QLockedMsgInfo
provides Information of the locked message from a queue.
Pushing data to Queue
enQueueBS :: String -> ByteString -> SBContext -> IO () Source
publish a message containing ByteString
to queue.
The following publishes a strict bytestring bs to queue q\
enQueueBS q bs ctx
enQueueLBS :: String -> ByteString -> SBContext -> IO () Source
publish a message containing ByteString
to queue
The following publishes a lazy bytestring ,lbs, to queue q,
enQueueLBS q lbs ctx
enQueueBodySrc :: String -> Int64 -> Source IO ByteString -> SBContext -> IO () Source
publish from a Source
(refer to requestBodySource
)
Reading data from Queue
deQueue :: String -> Int -> SBContext -> IO ByteString Source
Reads and deletes the message from a queue.
In order to destructively read the latest message from the queue (with a time out of n seconds),
deQueue queueName n context
Note that the timeout can be at the most 55 seconds. This silently ignores the timeouts greater than 55
peekLockQueue :: String -> Int -> SBContext -> IO (QLockedMsgInfo, ByteString) Source
Peek Lock Message from a Queue. Non-Destructive Read.
Atomically retrieves the next message from a queue and locks it for further processing. The message is guaranteed not to be delivered to other receivers (on the same subscription) during the duration of the lock.
Refer ServiceBus documentation for semantics of the underlying REST API.
unlockMessage :: String -> QLockedMsgInfo -> SBContext -> IO () Source
Unlock a messages that has been locked earlier.
Given a queueName and the broker properties of the message that has been locked before,
unlockMessage
removes the lock so that the message can be consumed by other consumers.
see peekLockQueue
and ServiceBus documentation for details on the underlying API.
deleteMessage :: String -> QLockedMsgInfo -> SBContext -> IO () Source
Delete a message that has been locked earlier.
Given a queueName and the locked message info, deleteMessage
deletes the message from the queue
see peekLockQueue
and ServiceBus documentation for details on the underlying API.
renewLock :: String -> QLockedMsgInfo -> SBContext -> IO () Source
Renews lock on a locked message
Given a queueName and the locked-message info, renewLock
renews the lock
deleteMessage
deletes the message from the queue
see peekLockQueue
and ServiceBus documentation for details on the underlying API.