@@ -38,6 +38,18 @@ public static DeliveryMessage<T> WithTenantId<T>(this T message, string tenantId
3838 return new DeliveryMessage < T > ( message , new DeliveryOptions { TenantId = tenantId } ) ;
3939 }
4040
41+ /// <summary>
42+ /// Create a cascading message tagged to a specific tenant id
43+ /// </summary>
44+ /// <param name="message"></param>
45+ /// <param name="tenantId"></param>
46+ /// <returns></returns>
47+ public static DeliveryMessage < T > WithTenantId < T > ( this DeliveryMessage < T > message , string tenantId )
48+ {
49+ message . Options . TenantId = tenantId ;
50+ return message ;
51+ }
52+
4153 /// <summary>
4254 /// Create a cascading message tagged to a specific group id
4355 /// </summary>
@@ -49,6 +61,19 @@ public static DeliveryMessage<T> WithGroupId<T>(this T message, string groupId)
4961 {
5062 return new DeliveryMessage < T > ( message , new DeliveryOptions { GroupId = groupId } ) ;
5163 }
64+
65+ /// <summary>
66+ /// Create a cascading message tagged to a specific group id
67+ /// </summary>
68+ /// <param name="message"></param>
69+ /// <param name="groupId"></param>
70+ /// <typeparam name="T"></typeparam>
71+ /// <returns></returns>
72+ public static DeliveryMessage < T > WithGroupId < T > ( this DeliveryMessage < T > message , string groupId )
73+ {
74+ message . Options . GroupId = groupId ;
75+ return message ;
76+ }
5277
5378 /// <summary>
5479 /// Create a cascading message tagged to a specific group id and scheduled for a set time
@@ -99,16 +124,40 @@ public static ScheduledMessage<T> ScheduledAt<T>(this T message, DateTimeOffset
99124 {
100125 return new ScheduledMessage < T > ( message , time ) ;
101126 }
127+
128+ /// <summary>
129+ /// Schedule the inner outgoing message to be sent at the specified time
130+ /// </summary>
131+ /// <param name="message"></param>
132+ /// <param name="time"></param>
133+ /// <returns></returns>
134+ public static DeliveryMessage < T > ScheduledAt < T > ( this DeliveryMessage < T > message , DateTimeOffset time )
135+ {
136+ message . Options . ScheduledTime = time ;
137+ return message ;
138+ }
102139
103140 /// <summary>
104141 /// Schedule the inner outgoing message to be sent after the specified delay
105142 /// </summary>
106143 /// <param name="message"></param>
107144 /// <param name="delay"></param>
108145 /// <returns></returns>
109- public static DelayedMessage < T > DelayedFor < T > ( this T message , TimeSpan delay )
146+ public static DeliveryMessage < T > DelayedFor < T > ( this T message , TimeSpan delay )
110147 {
111- return new DelayedMessage < T > ( message , delay ) ;
148+ return new DeliveryMessage < T > ( message , new DeliveryOptions { ScheduleDelay = delay } ) ;
149+ }
150+
151+ /// <summary>
152+ /// Schedule the inner outgoing message to be sent after the specified delay
153+ /// </summary>
154+ /// <param name="message"></param>
155+ /// <param name="delay"></param>
156+ /// <returns></returns>
157+ public static DeliveryMessage < T > DelayedFor < T > ( this DeliveryMessage < T > message , TimeSpan delay )
158+ {
159+ message . Options . ScheduleDelay = delay ;
160+ return message ;
112161 }
113162
114163 /// <summary>
@@ -121,7 +170,18 @@ public static RoutedToEndpointMessage<T> ToEndpoint<T>(this T message, string en
121170 {
122171 return new RoutedToEndpointMessage < T > ( endpointName , message , options ) ;
123172 }
124-
173+
174+ /// <summary>
175+ /// Send a message directly to the named endpoint as a cascading message
176+ /// </summary>
177+ /// <param name="message"></param>
178+ /// <param name="endpointName"></param>
179+ /// <returns></returns>
180+ public static RoutedToEndpointMessage < T > ToEndpoint < T > ( this DeliveryMessage < T > message , string endpointName )
181+ {
182+ return new RoutedToEndpointMessage < T > ( endpointName , message . Message , message . Options ) ;
183+ }
184+
125185 /// <summary>
126186 /// Send a message directly to the specific destination as a cascading message
127187 /// </summary>
@@ -133,6 +193,17 @@ public static RoutedToEndpointMessage<T> ToDestination<T>(this T message, Uri de
133193 return new RoutedToEndpointMessage < T > ( destination , message , options ) ;
134194 }
135195
196+ /// <summary>
197+ /// Send a message directly to the specific destination as a cascading message
198+ /// </summary>
199+ /// <param name="message"></param>
200+ /// <param name="destination"></param>
201+ /// <returns></returns>
202+ public static RoutedToEndpointMessage < T > ToDestination < T > ( this DeliveryMessage < T > message , Uri destination )
203+ {
204+ return new RoutedToEndpointMessage < T > ( destination , message . Message , message . Options ) ;
205+ }
206+
136207 /// <summary>
137208 /// Send a message to the supplied topic
138209 /// </summary>
@@ -145,6 +216,19 @@ public static TopicMessage<T> ToTopic<T>(this T message, string topic, DeliveryO
145216 {
146217 return new TopicMessage < T > ( message , topic , options ) ;
147218 }
219+
220+ /// <summary>
221+ /// Send a message to the supplied topic
222+ /// </summary>
223+ /// <param name="message"></param>
224+ /// <param name="topic">The topic name for the underlying message broker</param>
225+ /// <param name="options">Optional delivery options</param>
226+ /// <typeparam name="T"></typeparam>
227+ /// <returns></returns>
228+ public static TopicMessage < T > ToTopic < T > ( this DeliveryMessage < T > message , string topic )
229+ {
230+ return new TopicMessage < T > ( message . Message , topic , message . Options ) ;
231+ }
148232}
149233
150234public record TopicMessage < T > ( T Message , string Topic , DeliveryOptions ? Options ) : ISendMyself
@@ -155,16 +239,6 @@ ValueTask ISendMyself.ApplyAsync(IMessageContext context)
155239 }
156240}
157241
158- /// <summary>
159- /// Wrapper for a cascading message that has delayed delivery
160- /// </summary>
161- public class DelayedMessage < T > : DeliveryMessage < T >
162- {
163- public DelayedMessage ( T message , TimeSpan delay ) : base ( message , new DeliveryOptions { ScheduleDelay = delay } )
164- {
165- }
166- }
167-
168242public class ScheduledMessage < T > : DeliveryMessage < T >
169243{
170244 public ScheduledMessage ( T message , DateTimeOffset time ) : base ( message ,
0 commit comments