本文整理汇总了C#中IBus.Receive方法的典型用法代码示例。如果您正苦于以下问题:C# IBus.Receive方法的具体用法?C# IBus.Receive怎么用?C# IBus.Receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBus
的用法示例。
在下文中一共展示了IBus.Receive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageBusInputChannel
public MessageBusInputChannel(
BufferManager bufferManager, MessageEncoderFactory encoder, ChannelManagerBase parent,
EndpointAddress localAddress,
IBus bus)
: base(bufferManager, encoder, parent)
{
_localAddress = localAddress;
_bus = bus;
_aLock = new object();
_tryReceiveDelegate = (TimeSpan timeout, out Message message) =>
{
message = null;
try
{
var requestMessage = _bus.Receive(true, null);
if (requestMessage != null)
{
message = GetWcfMessageFromString(requestMessage.Content);
OnAfterTryReceive(requestMessage);
}
}
catch (Exception ex)
{
throw new CommunicationException(ex.Message, ex);
}
return true;
};
_receiveDelegate = (TimeSpan timeout) =>
{
var requestMessage = _bus.Receive(false, ChannelID);
return GetWcfMessageFromString(requestMessage.Content);
};
}
示例2: MessageBusDuplexChannel
public MessageBusDuplexChannel(
BufferManager bufferManager, MessageEncoderFactory encoder, EndpointAddress remoteAddress,
ChannelManagerBase parent, Uri via,
IBus bus, bool isClient)
: base(bufferManager, encoder, parent)
{
_serverAddress = remoteAddress;
_via = via;
_bus = bus;
_isClient = isClient;
_replyTos = new ConcurrentDictionary<UniqueId, string>();
_tryReceiveDelegate = (TimeSpan timeout, out Message message) =>
{
message = null;
try
{
// listen the message bus based on the sticky mode:
// channel: only receive the message that reply to this channel's id
// scaling gourp: receive the message the reply to this channel's id and the scaling group id of this channel
var requestMessage = _bus.Receive(!_isClient, ChannelID);
if (requestMessage != null)
{
message = GetWcfMessageFromString(requestMessage.Content);
if (message.Headers.MessageId != null)
{
_replyTos.AddOrUpdate(message.Headers.MessageId, requestMessage.From, (key, value) => requestMessage.From);
}
OnAfterTryReceive(requestMessage);
}
}
catch (Exception ex)
{
throw new CommunicationException(ex.Message, ex);
}
return true;
};
}
示例3: MessageBusReplyChannel
public MessageBusReplyChannel(
BufferManager bufferManager, MessageEncoderFactory encoder, ChannelManagerBase parent,
EndpointAddress localAddress,
IBus bus)
: base(bufferManager, encoder, parent)
{
_localAddress = localAddress;
_bus = bus;
_aLock = new object();
_tryReceiveRequestDelegate = (TimeSpan t, out RequestContext rc) =>
{
rc = null;
// receive the request message from the bus
var busMsg = _bus.Receive(true, null);
// box the wcf message
var message = GetWcfMessageFromString(busMsg.Content);
// initialize the request context and return
rc = new MessageBusRequestContext(message, this, _localAddress, _bus, busMsg.MessageID);
OnAfterTryReceiveRequest(busMsg);
return true;
};
}