Ejemplo n.º 1
0
 public void Handle(Message01 message, IMessageTransportationContext context)
 {
     Thread.Sleep(600);
     if (message.Sequence % 2 == 1)
     {
         throw new ApplicationException("业务逻辑执行报错");
     }
     Console.WriteLine($"Message01 sequence {message.Sequence} from queue {context.QueueName}");
 }
Ejemplo n.º 2
0
 public CommandExecuteContext(IRepository repository, IAggregateStorage aggregateRootStorage, CommandMessage commandMessage, SendReplyService sendReplyService, IMessageTransportationContext messageContext, ILogger logger)
 {
     _trackingAggregateRootDict = new ConcurrentDictionary <string, IAggregateRoot>();
     _repository           = repository;
     _aggregateRootStorage = aggregateRootStorage;
     _sendReplyService     = sendReplyService;
     _messageContext       = messageContext;
     _commandMessage       = commandMessage;
     _logger = logger;
 }
 /// <summary>
 /// 消息已处理 事件参数
 /// </summary>
 /// <param name="messageHandlerCategory">消息处理器分类</param>
 /// <param name="receiverType">接收者类型</param>
 /// <param name="context">消息传输上下文</param>
 public MessageReceivedEventArgs(string messageHandlerCategory, MessageReceiverType receiverType, IMessageTransportationContext context)
 {
     MessageHandlerCategory = messageHandlerCategory;
     ReceiverType           = receiverType;
     Context = context;
 }
Ejemplo n.º 4
0
 public void Handle(Message03 message, IMessageTransportationContext context)
 {
     Thread.Sleep(700);
     Console.WriteLine($"Message03 from queue {context.QueueName}");
 }
 public CommandExecutingContext(ILogger logger, IMessageTransportationContext transportationContext)
 {
     _logger = logger;
     _transportationContext = transportationContext;
 }
 public DomainEventStreamProcessContext(DomainEventConsumer eventConsumer, DomainEventStreamMessage domainEventStreamMessage, IMessageTransportationContext messageContext)
 {
     _messageContext           = messageContext;
     _eventConsumer            = eventConsumer;
     _domainEventStreamMessage = domainEventStreamMessage;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取响应队列,用于RPC调用
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetReplyTo(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.CORRELATION_ID) ? (string)context.Properties[MessagePropertyConstants.REPLY_TO] : "");
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 获取关联ID,用于RPC调用
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetCorrelationId(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.CORRELATION_ID) ? (string)context.Properties[MessagePropertyConstants.CORRELATION_ID] : "");
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取路由Key
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetRoutingKey(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.ROUTING_KEY) ? (string)context.Properties[MessagePropertyConstants.ROUTING_KEY] : "");
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取消息重放数据
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetPayload(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.PAYLOAD) ? (string)context.Properties[MessagePropertyConstants.PAYLOAD] : "");
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 获取MIME内容类型
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetContentType(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.CONTENT_TYPE) ? (string)context.Properties[MessagePropertyConstants.CONTENT_TYPE] : "");
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 获取消息时间戳(如果未设置,则返回当前时间)
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static DateTime GetTimestamp(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.TIMESTAMP) ? (DateTime)context.Properties[MessagePropertyConstants.TIMESTAMP] : DateTime.Now);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 获取消息ID
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static string GetMessageId(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.MESSAGE_ID) ? (string)context.Properties[MessagePropertyConstants.MESSAGE_ID] : "");
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 消息已接受事件参数
 /// </summary>
 /// <param name="context"></param>
 public MessageReceivedEventArgs(IMessageTransportationContext context)
 {
     Context = context;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 消息已发送 事件参数
 /// </summary>
 /// <param name="senderType">发送者类型</param>
 /// <param name="context">消息传输上下文</param>
 public MessageSentEventArgs(MessageSenderType senderType, IMessageTransportationContext context)
 {
     SenderType = senderType;
     Context    = context;
 }
 /// <summary>
 /// 获取消息重放数据
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static byte[] GetBody(this IMessageTransportationContext context)
 {
     return(context.Properties.ContainsKey(MessagePropertyConstants.BODY) ? (byte[])context.Properties[MessagePropertyConstants.BODY] : null);
 }