]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
set message props
authorFrank Doepper <[email protected]>
Tue, 26 Jun 2018 15:14:19 +0000 (17:14 +0200)
committerFrank Doepper <[email protected]>
Tue, 26 Jun 2018 15:14:19 +0000 (17:14 +0200)
Network/AMQP/Utils/Options.hs
agitprop.hs

index 004e97612c2e6ec163493fc5b39e701190ecd510..e96fd8bb8826cdb7960209945525c8505642819d 100644 (file)
@@ -2,7 +2,9 @@ module Network.AMQP.Utils.Options where
 
 import Data.Default.Class
 import Data.Maybe
+import Data.Text (Text)
 import Data.Version (showVersion)
+import Network.AMQP.Types
 import Paths_amqp_utils (version)
 import System.Console.GetOpt
 
@@ -31,6 +33,18 @@ data Args = Args
   , inputFile :: String
   , lineMode :: Bool
   , confirm :: Bool
+  , msgtimestamp :: Maybe Timestamp
+  , msgid :: Maybe Text
+  , msgtype :: Maybe Text
+  , msguserid :: Maybe Text
+  , msgappid :: Maybe Text
+  , msgclusterid :: Maybe Text
+  , msgcontenttype :: Maybe Text
+  , msgcontentencoding :: Maybe Text
+  , msgreplyto :: Maybe Text
+  , msgprio :: Maybe Octet
+  , msgcorrid :: Maybe Text
+  , msgexp :: Maybe Text
   }
 
 instance Default Args where
@@ -59,6 +73,18 @@ instance Default Args where
       "/dev/stdin"
       False
       False
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
+      Nothing
 
 -- | Common options
 cOptions :: [OptDescr (Args -> Args)]
index 7f52a28561ad36374d17208229419a867a51c306..2a1529130fd289a6a5307deee6dc80c3f52473a3 100644 (file)
@@ -37,14 +37,7 @@ main = do
       confirmSelect chan False
       addConfirmationListener chan confirmCallback
     else return ()
-  let publishOneMsg f = do
-        r <-
-          publishMsg
-            chan
-            (T.pack $ currentExchange args)
-            (T.pack $ rKey args)
-            newMsg {msgBody = f, msgDeliveryMode = Just Persistent}
-        printparam "sent" $ fmap show r
+  let publishOneMsg = publishOneMsg' chan args
   X.catch
     (if isDir
        then do
@@ -98,3 +91,29 @@ handleFile f x =
     (\exception ->
        printparam' "exception in handleFile" $
        show (exception :: X.SomeException))
+
+-- | Publish one message with our settings
+publishOneMsg' :: Channel -> Args -> BL.ByteString -> IO ()
+publishOneMsg' c a f = do
+      r <-
+        publishMsg
+          c
+          (T.pack $ currentExchange a)
+          (T.pack $ rKey a)
+          newMsg { msgBody = f
+                 , msgDeliveryMode = Just Persistent
+                 , msgTimestamp = msgtimestamp a
+                 , msgID = msgid a
+                 , msgType = msgtype a
+                 , msgUserID = msguserid a
+                 , msgApplicationID = msgappid a
+                 , msgClusterID = msgclusterid a
+                 , msgContentType = msgcontenttype a
+                 , msgContentEncoding = msgcontentencoding a
+                 , msgReplyTo = msgreplyto a
+                 , msgPriority = msgprio a
+                 , msgCorrelationID = msgcorrid a
+                 , msgExpiration = msgexp a
+                 -- , msgHeaders =
+                 }
+      printparam "sent" $ fmap show r