Esempio n. 1
0
 private Func <object, string> Route <T>()
 {
     try
     {
         return(_catalog[typeof(T)]);
     }
     catch (KeyNotFoundException e)
     {
         var excp = new PayQueueException("Can not find publish event");
         excp.Data["Event"] = typeof(T).FullName;
         throw excp;
     }
 }
Esempio n. 2
0
 private ICallbackExecutor GetExecutor(string messageType, ConsumeMessageMetadata metadata)
 {
     try
     {
         return(_consumers[messageType]);
     }
     catch (KeyNotFoundException)
     {
         var excp = new PayQueueException("Received message was not defined in contract.");
         excp.Data["Queue"]    = metadata.Queue;
         excp.Data["Exchange"] = metadata.Exchange;
         excp.Data["Type"]     = messageType;
         throw excp;
     }
 }
Esempio n. 3
0
 private byte[] Serialize <T>(T value)
 {
     try
     {
         return(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(value)));
     }
     catch (ArgumentException inner)
     {
         var excp = new PayQueueException("Can not serialize message", inner);
         excp.Data["MessageType"] = typeof(T);
         throw excp;
     }
     catch (NotSupportedException inner)
     {
         var excp = new PayQueueException("Can not serialize message", inner);
         excp.Data["MessageType"] = typeof(T);
         throw excp;
     }
 }