本文整理汇总了C#中IEndpointInstance.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IEndpointInstance.Send方法的具体用法?C# IEndpointInstance.Send怎么用?C# IEndpointInstance.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEndpointInstance
的用法示例。
在下文中一共展示了IEndpointInstance.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendOrder
static async Task SendOrder(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press '1' to send PlaceOrder - defer message handling");
Console.WriteLine("Press '2' to send PlaceDelayedOrder - defer message delivery");
Console.WriteLine("Press enter key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
Guid id = Guid.NewGuid();
switch (key.Key)
{
case ConsoleKey.D1:
#region SendOrder
PlaceOrder placeOrder = new PlaceOrder
{
Product = "New shoes",
Id = id
};
await endpointInstance.Send("Samples.DelayedDelivery.Server", placeOrder);
Console.WriteLine("[Defer Message Handling] Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
#endregion
continue;
case ConsoleKey.D2:
#region DeferOrder
PlaceDelayedOrder placeDelayedOrder = new PlaceDelayedOrder
{
Product = "New shoes",
Id = id
};
SendOptions options = new SendOptions();
options.SetDestination("Samples.DelayedDelivery.Server");
options.DelayDeliveryWith(TimeSpan.FromSeconds(5));
await endpointInstance.Send(placeDelayedOrder, options);
Console.WriteLine("[Defer Message Delivery] Deferred a new PlaceDelayedOrder message with id: {0}", id.ToString("N"));
#endregion
continue;
case ConsoleKey.Enter:
return;
default:
return;
}
}
}
示例2: SendOrder
static async Task SendOrder(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
Guid id = Guid.NewGuid();
PlaceOrder placeOrder = new PlaceOrder
{
Product = "New shoes",
Id = id
};
await endpointInstance.Send("Samples.StepByStep.Server", placeOrder);
Console.WriteLine("Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
}
}
示例3: Expiration
// Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
static async Task Expiration(IEndpointInstance endpointInstance)
{
await endpointInstance.Send(new MessageThatExpires
{
RequestId = new Guid()
});
Console.WriteLine("message with expiration was sent");
}
示例4: SendJsonMessage
static async Task SendJsonMessage(IEndpointInstance endpointInstance)
{
MessageWithJson message = new MessageWithJson
{
SomeProperty = "Some content in a json message",
};
await endpointInstance.Send("Samples.MultiSerializer.Receiver", message);
Console.WriteLine("Json Message sent");
}
示例5: SendXmlMessage
static async Task SendXmlMessage(IEndpointInstance endpointInstance)
{
var message = new MessageWithXml
{
SomeProperty = "Some content in a Xml message",
};
await endpointInstance.Send("Samples.MultiSerializer.Receiver", message)
.ConfigureAwait(false);
Console.WriteLine("XML message sent");
}
示例6: Expiration
// Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
static async Task Expiration(IEndpointInstance endpointInstance)
{
var messageThatExpires = new MessageThatExpires
{
RequestId = new Guid()
};
await endpointInstance.Send(messageThatExpires)
.ConfigureAwait(false);
Console.WriteLine("message with expiration was sent");
}
示例7: Express
static async Task Express(IEndpointInstance endpointInstance)
{
Guid requestId = Guid.NewGuid();
await endpointInstance.Send(new RequestExpress
{
RequestId = requestId
});
Console.WriteLine("Request sent id: " + requestId);
}
示例8: SendDelayedMessage
async Task SendDelayedMessage(IEndpointInstance endpoint, IMessageHandlerContext handlerContext)
{
#region delayed-delivery-datetime
SendOptions options = new SendOptions();
options.DoNotDeliverBefore(new DateTime(2016, 12, 25));
await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await endpoint.Send(new MessageToBeSentLater(), options);
#endregion
}
示例9: Data
static async Task Data(IEndpointInstance endpointInstance)
{
Guid requestId = Guid.NewGuid();
await endpointInstance.Send(new LargeMessage
{
RequestId = requestId,
LargeDataBus = new byte[1024*1024*5]
});
Console.WriteLine("Request sent id: " + requestId);
}
示例10: SendMessageTooLargePayload
static async Task SendMessageTooLargePayload(IEndpointInstance endpointInstance)
{
#region SendMessageTooLargePayload
AnotherMessageWithLargePayload message = new AnotherMessageWithLargePayload
{
LargeBlob = new byte[1024*1024*5] //5MB
};
await endpointInstance.Send("Samples.DataBus.Receiver", message);
#endregion
}
示例11: Data
static async Task Data(IEndpointInstance endpointInstance)
{
var requestId = Guid.NewGuid();
var largeMessage = new LargeMessage
{
RequestId = requestId,
LargeDataBus = new byte[1024*1024*5]
};
await endpointInstance.Send(largeMessage)
.ConfigureAwait(false);
Console.WriteLine("Request sent id: " + requestId);
}
示例12: SendMessageLargePayload
static async Task SendMessageLargePayload(IEndpointInstance endpointInstance)
{
#region SendMessageLargePayload
MessageWithLargePayload message = new MessageWithLargePayload
{
SomeProperty = "This message contains a large blob that will be sent on the data bus",
LargeBlob = new DataBusProperty<byte[]>(new byte[1024*1024*5]) //5MB
};
await endpointInstance.Send("Samples.DataBus.Receiver", message);
#endregion
Console.WriteLine("Message sent, the payload is stored in: ..\\..\\..\\storage");
}
示例13: PlaceOrder
static void PlaceOrder(IEndpointInstance endpoint)
{
#region SendMessage
ClientOrder order = new ClientOrder
{
OrderId = Guid.NewGuid()
};
endpoint.Send("Samples.SqlServer.MultiInstanceReceiver", order);
#endregion
Console.WriteLine("ClientOrder message sent with ID {0}", order.OrderId);
}
示例14: SendMessageWithFileStream
static async Task SendMessageWithFileStream(IEndpointInstance endpointInstance)
{
#region send-message-with-file-stream
MessageWithStream message = new MessageWithStream
{
SomeProperty = "This message contains a stream",
StreamProperty = File.OpenRead("FileToSend.txt")
};
await endpointInstance.Send("Samples.PipelineStream.Receiver", message);
#endregion
Console.WriteLine();
Console.WriteLine("Message with file stream sent");
}
示例15: SendDelayedMessage
async Task SendDelayedMessage(EndpointConfiguration endpointConfiguration, IEndpointInstance endpoint, IMessageHandlerContext handlerContext)
{
#region configure-persistence-timeout
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
#endregion
#region delayed-delivery-timespan
SendOptions options = new SendOptions();
options.DelayDeliveryWith(TimeSpan.FromMinutes(30));
await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await endpoint.Send(new MessageToBeSentLater(), options);
#endregion
}