File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed
Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ # Haskell code for RabbitMQ tutorials
2+
3+ Here you can find Clojure code examples from
4+ [ RabbitMQ tutorials] ( http://www.rabbitmq.com/getstarted.html ) .
5+
6+ ## Requirements
7+
8+ To run this code you need [ Network.AMQP] ( http://hackage.haskell.org/package/amqp-0.6.0/docs/Network-AMQP.html ) .
9+
10+ ## Code
11+
12+ Code examples are executed via ` runhaskell ` :
13+
14+ [ Tutorial one: "Hello World!"] ( http://www.rabbitmq.com/tutorial-one-python.html ) :
15+
16+ runhaskell send.hs
17+ runhaskell receive.hs
18+
19+ [ Tutorial two: Work Queues] ( http://www.rabbitmq.com/tutorial-two-python.html ) :
20+
21+ runhaskell new_task.hs
22+ runhaskell worker.hs
23+
24+ [ Tutorial three: Publish/Subscribe] ( http://www.rabbitmq.com/tutorial-three-python.html )
25+
26+ runhaskell receive_logs.hs
27+ runhaskell emit_log.hs
28+
29+ [ Tutorial four: Routing] ( http://www.rabbitmq.com/tutorial-four-python.html )
30+
31+ runhaskell receive_logs_direct.hs
32+ runhaskell emit_log_direct.hs
33+
34+ [ Tutorial five: Topics] ( http://www.rabbitmq.com/tutorial-five-python.html )
35+
36+ runhaskell receive_logs_topic.hs
37+ runhaskell emit_log_topic.hs
38+
39+ [ Tutorial six: RPC] ( http://www.rabbitmq.com/tutorial-six-python.html )
40+
41+ TBD
42+
43+ To learn more, visit [ Langohr documentation] ( http://clojurerabbitmq.info ) site.
Original file line number Diff line number Diff line change 1+ {-# OPTIONS -XOverloadedStrings #-}
2+
3+ import Network.AMQP
4+ import qualified Data.ByteString.Lazy.Char8 as BL
5+
6+ main :: IO ()
7+ main = do
8+ conn <- openConnection " 127.0.0.1" " /" " guest" " guest"
9+ ch <- openChannel conn
10+
11+ declareQueue ch newQueue {queueName = " hello" ,
12+ queuePassive = False ,
13+ queueDurable = False }
14+
15+ putStrLn " [*] Waiting for messages. to Exit press CTRL+C"
16+ consumeMsgs ch " hello" NoAck deliveryHandler
17+
18+ -- waits for keypresses
19+ getLine
20+ closeConnection conn
21+
22+ deliveryHandler :: (Message , Envelope ) -> IO ()
23+ deliveryHandler (msg, metadata) = do
24+ putStrLn $ " [x] Received " ++ (BL. unpack $ msgBody msg)
Original file line number Diff line number Diff line change 1+ {-# OPTIONS -XOverloadedStrings #-}
2+
3+ import Network.AMQP
4+ import qualified Data.ByteString.Lazy.Char8 as BL
5+
6+ main :: IO ()
7+ main = do
8+ conn <- openConnection " 127.0.0.1" " /" " guest" " guest"
9+ ch <- openChannel conn
10+
11+ declareQueue ch newQueue {queueName = " hello" ,
12+ queuePassive = False ,
13+ queueDurable = False }
14+
15+ publishMsg ch " " " hello"
16+ (newMsg {msgBody = (BL. pack " Hello World!" ),
17+ msgDeliveryMode = Just NonPersistent })
18+
19+ putStrLn " [x] Sent 'Hello World!'"
20+ closeConnection conn
You can’t perform that action at this time.
0 commit comments