amqp-0.12: examples/ExampleProducer.hs
{-# OPTIONS -XOverloadedStrings #-}
import Network.AMQP
import Control.Concurrent
import qualified Data.ByteString.Lazy.Char8 as BL
main = do
conn <- openConnection "127.0.0.1" "/" "guest" "guest"
chan <- openChannel conn
addChannelExceptionHandler chan $ \e -> do
threadDelay 1000000
print e
--declare queues, exchanges and bindings
declareQueue chan newQueue {queueName = "myQueueDE"}
declareQueue chan newQueue {queueName = "myQueueEN"}
declareExchange chan newExchange {exchangeName = "topicExchg", exchangeType = "topic"}
-- bindQueue chan "myQueueDE" "topicExcheg" "de.*"
bindQueue chan "myQueueEN" "topicExchg" "en.*"
--publish messages
publishMsg chan "topicExchg" "de.hello"
(newMsg {msgBody = (BL.pack "hallo welt"),
msgDeliveryMode = Just NonPersistent}
)
publishMsg chan "topicExchg" "en.hello"
(newMsg {msgBody = (BL.pack "hello world"),
msgDeliveryMode = Just NonPersistent}
)
-- closeChannel chan
getLine
closeConnection conn