本文整理汇总了C#中IBus.Request方法的典型用法代码示例。如果您正苦于以下问题:C# IBus.Request方法的具体用法?C# IBus.Request怎么用?C# IBus.Request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBus
的用法示例。
在下文中一共展示了IBus.Request方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessages
public override IEnumerable<Task> SendMessages(IBus bus)
{
for (var i = 0; i < NumMessagesToSend; i++)
{
yield return bus.Request(new FooRequest());
Console.Write(".");
}
Console.WriteLine();
}
示例2: SendMessages
public override async Task SendMessages(IBus bus, Func<bool> shouldKeepSending)
{
while (shouldKeepSending())
{
var response = await bus.Request(new FooRequest(), TimeSpan.FromSeconds(TimeoutSeconds));
StressTestMessageHandler.RecordResponseMessageReceipt(response);
IncrementExpectedMessageCount();
}
}
示例3: Initialize
public void Initialize(IBus bus)
{
bus.Subscribe<StartMessage>("id", startMessage =>
{
var request = new TestRequestMessage {Text = startMessage.Text};
bus.Request<TestRequestMessage, TestResponseMessage>(request, response =>
{
var endMessage = new EndMessage {Text = response.Text};
bus.Publish(endMessage);
});
});
}
示例4: SendObjectMessage
static async void SendObjectMessage(IBus bus)
{
#region SendObjectMessage
ObjectMessage message = new ObjectMessage();
SendOptions sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
ObjectResponseMessage response = await bus.Request<ObjectResponseMessage>(message, sendOptions);
Console.WriteLine("Callback received with response property value:" + response.Property);
#endregion
Console.WriteLine("Message sent");
}
示例5: SendEnumMessage
static async void SendEnumMessage(IBus bus)
{
#region SendEnumMessage
SendOptions sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
EnumMessage message = new EnumMessage();
Status status = await bus.Request<Status>(message, sendOptions);
Console.WriteLine("Callback received with status:" + status);
#endregion
Console.WriteLine("Message sent");
}
示例6: SendIntMessage
static async void SendIntMessage(IBus bus)
{
#region SendIntMessage
IntMessage message = new IntMessage();
SendOptions sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
int response = await bus.Request<int>(message, sendOptions);
Console.WriteLine("Callback received with response:" + response);
#endregion
Console.WriteLine("Message sent");
}
示例7: Initialize
public void Initialize(IBus bus)
{
bus.Subscribe<StartMessage>("simpleSaga", startMessage =>
{
Console.WriteLine("StartMessage: {0}", startMessage.Text);
var firstProcessedMessage = startMessage.Text + " - initial process ";
var request = new TestRequestMessage { Text = firstProcessedMessage };
bus.Request<TestRequestMessage, TestResponseMessage>(request, response =>
{
Console.WriteLine("TestResponseMessage: {0}", response.Text);
var secondProcessedMessage = response.Text + " - final process ";
var endMessage = new EndMessage { Text = secondProcessedMessage };
bus.Publish(endMessage);
});
});
}
示例8: SendCommand
static async void SendCommand(IBus bus)
{
Guid commandId = Guid.NewGuid();
SendOptions sendOptions = new SendOptions();
sendOptions.SetCorrelationId(commandId.ToString());
MyCommand message = new MyCommand();
var response = await bus.Request<CommandStatus>(new MyCommand
{
CommandId = commandId,
EncryptedString = "Some sensitive information"
}, sendOptions);
Console.WriteLine("Callback received with response:" + response);
Console.WriteLine("Command sent id: " + commandId);
}