azure-servicebus-0.1.5.0: Haskell wrapper over Microsoft Azure ServiceBus REST API

Copyright(c) Hemanth Kapila, 2014
LicenseBSD3
Maintainersaihemanth@gmail.com
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010

Web.WindowsAzure.ServiceBus.Topic

Contents

Description

Provides API to pull from and push to ServiceBus topic 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.Topic
import Web.WindowsAzure.ServiceBus
import qualified Data.ByteString.Char8 as C

topicName = "topicName"
subscriptionName = "subscriptionName"
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
  sendTopicBS topicName message sbContext
  res <- destructiveRead topicName subscriptionName 30 sbContext
  print res

see examples (available as a part of distribution) for a more detailed example.

Synopsis

Pushing data to Topic

sendTopicBS :: String -> ByteString -> SBContext -> IO () Source

publish a message containing ByteString to a topic.

The following publishes a strict bytestring bs to topic t\

sendTopicBS t bs ctx

sendTopicLBS :: String -> ByteString -> SBContext -> IO () Source

publish a message containing ByteString to a topic

The following publishes a lazy bytestring ,lbs, to topic t,

sendTopicLBS t lbs  ctx

Reading data from Topic

destructiveRead :: String -> String -> Int -> SBContext -> IO ByteString Source

Reads and deletes the message from a topic at a given subscription.

In order to destructively read the latest message from the subscription subsc on topic t (with a time out of n seconds),

destructiveRead t subsc n context

Note that the timeout can be at the most 55 seconds.

peekLockTopic :: String -> String -> Int -> SBContext -> IO (LockedMsgInfo, ByteString) Source

Peek Lock Message from a Topic. Non-Destructive Read.

Atomically retrieves the message from a topic (on a given subscription) without deleting it. The message is locked for a duration so that it is not visible to other receivers.

Refer ServiceBus documentation for semantics of the underlying REST API.