IMessage.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. using System;
  18. using System.Threading.Tasks;
  19. namespace Apache.NMS
  20. {
  21. /// <summary>
  22. /// Represents a message either to be sent to a message broker or received from a message broker.
  23. /// </summary>
  24. public interface IMessage
  25. {
  26. /// <summary>
  27. /// If using client acknowledgement mode on the session, then this method will acknowledge that the
  28. /// message has been processed correctly.
  29. /// </summary>
  30. void Acknowledge();
  31. /// <summary>
  32. /// If using client acknowledgement mode on the session, then this method will acknowledge that the
  33. /// message has been processed correctly.
  34. /// </summary>
  35. Task AcknowledgeAsync();
  36. /// <summary>
  37. /// Clears out the message body. Clearing a message's body does not clear its header
  38. /// values or property entries.
  39. ///
  40. /// If this message body was read-only, calling this method leaves the message body in
  41. /// the same state as an empty body in a newly created message.
  42. /// </summary>
  43. void ClearBody();
  44. /// <summary>
  45. /// Clears a message's properties.
  46. ///
  47. /// The message's header fields and body are not cleared.
  48. /// </summary>
  49. void ClearProperties();
  50. /// <summary>
  51. /// Provides access to the message properties (headers).
  52. /// </summary>
  53. IPrimitiveMap Properties { get; }
  54. /// <summary>
  55. /// The correlation ID used to correlate messages from conversations or long running business processes.
  56. /// </summary>
  57. string NMSCorrelationID { get; set; }
  58. /// <summary>
  59. /// The destination of the message. This property is set by the IMessageProducer.
  60. /// </summary>
  61. IDestination NMSDestination { get; set; }
  62. /// <summary>
  63. /// The amount of time for which this message is valid. Zero if this message does not expire.
  64. /// </summary>
  65. TimeSpan NMSTimeToLive { get; set; }
  66. /// <summary>
  67. /// The message ID which is set by the provider.
  68. /// </summary>
  69. string NMSMessageId { get; set; }
  70. /// <summary>
  71. /// Whether or not this message is persistent.
  72. /// </summary>
  73. MsgDeliveryMode NMSDeliveryMode { get; set; }
  74. /// <summary>
  75. /// The Priority of this message.
  76. /// </summary>
  77. MsgPriority NMSPriority { get; set; }
  78. /// <summary>
  79. /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.
  80. /// </summary>
  81. bool NMSRedelivered { get; set; }
  82. /// <summary>
  83. /// The destination that the consumer of this message should send replies to
  84. /// </summary>
  85. IDestination NMSReplyTo { get; set; }
  86. /// <summary>
  87. /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting
  88. /// the timestamp on the message, the time will be set to the start of the UNIX epoc (1970-01-01 00:00:00).
  89. /// </summary>
  90. DateTime NMSTimestamp { get; set; }
  91. /// <summary>
  92. /// The type name of this message.
  93. /// </summary>
  94. string NMSType { get; set; }
  95. /// <summary>
  96. /// When a message is sent, the NMSDeliveryTime header field is
  97. /// left unassigned. After completion of the send or
  98. /// publish method, it holds the delivery time of the message.
  99. /// This is the the difference, measured in milliseconds,
  100. /// between the delivery time and midnight, January 1, 1970 UTC.
  101. ///
  102. /// A message's delivery time is the earliest time when a JMS provider may
  103. /// deliver the message to a consumer. The provider must not deliver messages
  104. /// before the delivery time has been reached.
  105. /// <summary>
  106. DateTime NMSDeliveryTime { get; set; }
  107. T Body<T>();
  108. bool IsBodyAssignableTo(Type type);
  109. }
  110. }