本文整理汇总了C#中IMessage.SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.SetHeader方法的具体用法?C# IMessage.SetHeader怎么用?C# IMessage.SetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessage
的用法示例。
在下文中一共展示了IMessage.SetHeader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
var bus = MockRepository.GenerateStub<IBus>();
headerManager = new MessageHeaderManager();
bus.Stub(x => x.CurrentMessageContext).Return(new FakeMessageConext
{
Id = idOfIncommingMessage
});
ExtensionMethods.SetHeaderAction = headerManager.SetHeader;
ExtensionMethods.GetHeaderAction = headerManager.GetHeader;
incomingMessage = new TestMessage();
incomingMessage.SetOriginatingSiteHeader(originatingSite);
addressOfOriginatingEndpoint = "EnpointLocatedInSiteA";
incomingMessage.SetHeader("ReturnAddress",addressOfOriginatingEndpoint);
gatewayHeaderManager = new GatewayHeaderManager
{
Bus = bus
};
gatewayHeaderManager.MutateIncoming(incomingMessage);
responseMessage = new TransportMessage
{
Headers = new Dictionary<string, string>(),
CorrelationId = idOfIncommingMessage
};
}
示例2: AppendHeaders
private static void AppendHeaders(IMessage message, IEnumerable<KeyValuePair<string, object>> headers)
{
headers = headers.Where(x => x.Key.StartsWith(BusPrefixKey));
foreach (var header in headers)
{
var key = header.Key.Substring(BusPrefixKey.Length);
var value = (header.Value ?? string.Empty).ToString();
message.SetHeader(key, value);
}
}
示例3: using
IMessage IMutateOutgoingMessages.MutateOutgoing(IMessage message)
{
var timeToBeReceived = message.TimeToBeReceived();
using (new TransactionScope(TransactionScopeOption.Suppress))
foreach (var dataBusProperty in message.DataBusPropertiesWithValues())
{
using (var stream = new MemoryStream())
{
serializer.Serialize(dataBusProperty.GetValue(), stream);
stream.Position = 0;
dataBusProperty.Key = dataBus.Put(stream, timeToBeReceived);
//we use the headers to in order to allow the infrastructure (eg. the gateway) to modify the actual key
message.SetHeader(DATABUS_PREFIX + dataBusProperty.Key, dataBusProperty.Key);
}
}
return message;
}
示例4: AddHeaders
/// <summary>
/// Adds the headers.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="data">The data.</param>
public void AddHeaders (IMessage message, IAdditionalMessageData data)
{
message.SetHeader(_headers.StandardHeaders.FirstPossibleDeliveryDate, new ValueTypeWrapper<DateTime>(_getFirstMessageDeliveryTime.GetTime(message, data)));
}
示例5: Push
internal static void Push(RtmpConnection connection, IMessage message, IMessageClient messageClient)
{
if (connection != null)
{
object response = message;
if (message is BinaryMessage)
{
BinaryMessage binaryMessage = message as BinaryMessage;
binaryMessage.Update(messageClient);
byte[] binaryContent = binaryMessage.body as byte[];
//byte[] destClientBinaryId = messageClient.GetBinaryId();
//Array.Copy(destClientBinaryId, 0, binaryContent, binaryMessage.PatternPosition, destClientBinaryId.Length);
RawBinary result = new RawBinary(binaryContent);
response = result;
}
else
{
//This should be a clone of the original message
message.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
message.clientId = messageClient.ClientId;
}
RtmpChannel channel = connection.GetChannel(3);
FlexInvoke reply = new FlexInvoke();
Call call = new Call("receive", new object[] { response });
reply.ServiceCall = call;
//reply.Cmd = "receive";
//reply.Response = response;
reply.InvokeId = connection.InvokeId;
channel.Write(reply);
}
}
示例6: MutateOutgoing
public IMessage MutateOutgoing(IMessage message)
{
if(message is ICommand)
message.SetHeader("CommandId",Guid.NewGuid().ToString());
return message;
}
示例7: Send
/// <summary>
/// Sends the specified message.
/// </summary>
/// <param name="messageToSend">The message to send.</param>
/// <param name="data">The data.</param>
/// <returns></returns>
/// <exception cref="DotNetWorkQueueException">An error occurred while sending a message</exception>
public IQueueOutputMessage Send(IMessage messageToSend, IAdditionalMessageData data)
{
try
{
//TODO - temp - fail all messages with routes, as they are not supported yet
if (!string.IsNullOrEmpty(data.Route))
{
throw new NotImplementedException("Redis transport does not yet support routes");
}
//correlationID must be stored as a message header
messageToSend.SetHeader(_headers.CorelationId, new RedisQueueCorrelationIdSerialized((Guid)data.CorrelationId.Id.Value));
var messageId = _sendMessage.Handle(new SendMessageCommand(messageToSend, data));
if (messageId == "JobAlreadyExists")
{
return new QueueOutputMessage(_sentMessageFactory.Create(null, data.CorrelationId), new DotNetWorkQueueException("Failed to enqueue a record. The job already exists"));
}
return new QueueOutputMessage(_sentMessageFactory.Create(new RedisQueueId(messageId), data.CorrelationId));
}
catch (Exception exception)
{
return new QueueOutputMessage(_sentMessageFactory.Create(null, data.CorrelationId), exception);
}
}