public static object Deserializer(System.Type expected, global::Orleans.Serialization.BinaryTokenStreamReader stream) { Microsoft.AspNet.SignalR.Messaging.Message result = new Microsoft.AspNet.SignalR.Messaging.Message(); result.CommandId = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); object objResult = ((object)(result)); object temp2 = ((Encoding)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Encoding), stream))); fieldInfo2.SetValue(objResult, temp2); object temp3 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo3.SetValue(objResult, temp3); object temp4 = ((Boolean)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Boolean), stream))); fieldInfo4.SetValue(objResult, temp4); object temp5 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo5.SetValue(objResult, temp5); object temp6 = ((UInt64)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(UInt64), stream))); fieldInfo6.SetValue(objResult, temp6); object temp7 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo7.SetValue(objResult, temp7); object temp8 = ((Int32)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Int32), stream))); fieldInfo8.SetValue(objResult, temp8); object temp9 = ((ArraySegment <Byte>)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(ArraySegment <Byte>), stream))); fieldInfo9.SetValue(objResult, temp9); object temp10 = ((Boolean)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Boolean), stream))); fieldInfo10.SetValue(objResult, temp10); return(objResult); }
internal static Task Ack(this IMessageBus bus, string acker, string commandId) { // Prepare the ack var message = new Message(acker, AckSubscriber.Signal, null); message.CommandId = commandId; message.IsAck = true; return bus.Publish(message); }
public override Task Publish(Message message) { Counters.MessageBusMessagesPublishedTotal.Increment(); Counters.MessageBusMessagesPublishedPerSec.Increment(); // TODO: Implement message batching here return Send(new[] { message }); }
public static void Serializer(object untypedInput, Orleans.Serialization.BinaryTokenStreamWriter stream, System.Type expected) { Microsoft.AspNet.SignalR.Messaging.Message input = ((Microsoft.AspNet.SignalR.Messaging.Message)(untypedInput)); Orleans.Serialization.SerializationManager.SerializeInner(input.CommandId, stream, typeof(String)); Orleans.Serialization.SerializationManager.SerializeInner(input.Encoding, stream, typeof(Encoding)); Orleans.Serialization.SerializationManager.SerializeInner(input.Filter, stream, typeof(String)); Orleans.Serialization.SerializationManager.SerializeInner(input.IsAck, stream, typeof(Boolean)); Orleans.Serialization.SerializationManager.SerializeInner(input.Key, stream, typeof(String)); Orleans.Serialization.SerializationManager.SerializeInner(input.MappingId, stream, typeof(UInt64)); Orleans.Serialization.SerializationManager.SerializeInner(input.Source, stream, typeof(String)); Orleans.Serialization.SerializationManager.SerializeInner(input.StreamIndex, stream, typeof(Int32)); Orleans.Serialization.SerializationManager.SerializeInner(input.Value, stream, typeof(ArraySegment <Byte>)); Orleans.Serialization.SerializationManager.SerializeInner(input.WaitForAck, stream, typeof(Boolean)); }
void FromBytesToBytesProducesCorrectValues() { var message = new Message("source", "key", "value"); var message2 = new Message("string", "more", "str"); var message3 = new Message("s", "l", "n"); var scaleoutMessage = new ScaleoutMessage(new List<Message>() { message, message2, message3 }); var bytes = scaleoutMessage.ToBytes(); var msg = ScaleoutMessage.FromBytes(bytes); Assert.True(scaleoutMessage.Messages.Count == 3); Assert.True(scaleoutMessage.Messages[0].Source == msg.Messages[0].Source, "Source is not the same"); Assert.True(scaleoutMessage.Messages[0].Key == msg.Messages[0].Key, "Key is not the same"); Assert.True(scaleoutMessage.Messages[0].GetString() == msg.Messages[0].GetString(), "Value is not the same"); }
protected Task OnReceived(string streamId, ulong id, Message[] messages) { // Create a local dictionary for this payload var dictionary = new ConcurrentDictionary<string, LocalEventKeyInfo>(); foreach (var m in messages) { // Get the payload info var info = dictionary.GetOrAdd(m.Key, _ => new LocalEventKeyInfo()); // Save the min and max for this payload for later ulong localId = Save(m); // Set the topic pointer for this event key so we don't need to look it up later info.Store = Topics[m.Key].Store; info.MinLocal = Math.Min(localId, info.MinLocal); info.Count++; } // Create the mapping for this payload var mapping = new ScaleoutMapping(dictionary); // Get the stream for this payload var stream = _streams.GetOrAdd(streamId, _ => new Linktionary<ulong, ScaleoutMapping>()); // Publish only after we've setup the mapping fully stream.Add(id, mapping); // Schedule after we're done foreach (var eventKey in dictionary.Keys) { ScheduleEvent(eventKey); } return TaskAsyncHelper.Empty; }
public static object DeepCopier(object original) { Microsoft.AspNet.SignalR.Messaging.Message input = ((Microsoft.AspNet.SignalR.Messaging.Message)(original)); Microsoft.AspNet.SignalR.Messaging.Message result = new Microsoft.AspNet.SignalR.Messaging.Message(); Orleans.Serialization.SerializationContext.Current.RecordObject(original, result); result.CommandId = input.CommandId; object objResult = ((object)(result)); object temp2 = ((Encoding)(Orleans.Serialization.SerializationManager.DeepCopyInner(input.Encoding))); fieldInfo2.SetValue(objResult, temp2); object temp3 = input.Filter; fieldInfo3.SetValue(objResult, temp3); object temp4 = input.IsAck; fieldInfo4.SetValue(objResult, temp4); object temp5 = input.Key; fieldInfo5.SetValue(objResult, temp5); object temp6 = input.MappingId; fieldInfo6.SetValue(objResult, temp6); object temp7 = input.Source; fieldInfo7.SetValue(objResult, temp7); object temp8 = input.StreamIndex; fieldInfo8.SetValue(objResult, temp8); object temp9 = ((ArraySegment <Byte>)(Orleans.Serialization.SerializationManager.DeepCopyInner(input.Value))); fieldInfo9.SetValue(objResult, temp9); object temp10 = input.WaitForAck; fieldInfo10.SetValue(objResult, temp10); return(objResult); }
private bool ExcludeMessage(Message message) { if (String.IsNullOrEmpty(message.Filter)) { return false; } string[] exclude = message.Filter.Split('|'); return exclude.Any(signal => Identity.Equals(signal, StringComparison.OrdinalIgnoreCase) || _signals.Contains(signal) || _groups.Contains(signal)); }
private Message CreateMessage(string key, object value) { var command = value as Command; ArraySegment<byte> messageBuffer = GetMessageBuffer(value); var message = new Message(_connectionId, key, messageBuffer); if (command != null) { // Set the command id message.CommandId = command.Id; message.WaitForAck = command.WaitForAck; } return message; }
public Task Publish(Message message) { Debug.WriteLine("Publish: " + message.Value); return _messageBus.Publish(message); }
public Task Publish(Message message) { Debug.WriteLine("Publish: " + message.Encoding.GetString(message.Value.Array)); return _messageBus.Publish(message); }
public Task SendMany(Message[] messages) { return Send(messages); }
protected ulong Save(Message message) { if (message == null) { throw new ArgumentNullException("message"); } // Don't mark topics as active when publishing Topic topic = GetTopic(message.Key); return topic.Store.Add(message); }
/// <summary> /// Publishes a new message to the specified event on the bus. /// </summary> /// <param name="message">The message to publish.</param> public virtual Task Publish(Message message) { if (message == null) { throw new ArgumentNullException("message"); } Topic topic; if (Topics.TryGetValue(message.Key, out topic)) { topic.Store.Add(message); ScheduleTopic(topic); } Counters.MessageBusMessagesPublishedTotal.Increment(); Counters.MessageBusMessagesPublishedPerSec.Increment(); return TaskAsyncHelper.Empty; }
public RedisMessage(long id, Message[] message) { Id = id; Messages = message; }
public override Task Publish(Message message) { // TODO: Buffer messages here and make it configurable return Send(new[] { message }); }
protected override Task Send(Message[] messages) { foreach (var g in messages.GroupBy(m => m.Source)) { int topic = Math.Abs(g.Key.GetHashCode()) % _topicsIndexes.Length; OnReceived(topic.ToString(), (ulong)Interlocked.Increment(ref _topicsIndexes[topic]), g.ToArray()).Wait(); } return TaskAsyncHelper.Empty; }
private static PersistentResponse GetWrappedResponse(string raw) { var data = Encoding.Default.GetBytes(raw); var message = new Message("foo", "key", new ArraySegment<byte>(data)); var response = new PersistentResponse { Messages = new List<ArraySegment<Message>> { new ArraySegment<Message>(new Message[] { message }) } }; return response; }
public static Message ReadFrom(Stream stream) { var message = new Message(); var binaryReader = new BinaryReader(stream); message.Source = binaryReader.ReadString(); message.Key = binaryReader.ReadString(); int bytes = binaryReader.ReadInt32(); message.Value = new ArraySegment<byte>(binaryReader.ReadBytes(bytes)); message.CommandId = binaryReader.ReadString(); message.WaitForAck = binaryReader.ReadBoolean(); message.IsAck = binaryReader.ReadBoolean(); message.Filter = binaryReader.ReadString(); return message; }
/// <summary> /// Sends messages to the backplane /// </summary> /// <param name="messages"></param> /// <returns></returns> protected abstract Task Send(Message[] messages);
public static object Deserializer(System.Type expected, global::Orleans.Serialization.BinaryTokenStreamReader stream) { Microsoft.AspNet.SignalR.Messaging.Message result = new Microsoft.AspNet.SignalR.Messaging.Message(); result.CommandId = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); object objResult = ((object)(result)); object temp2 = ((Encoding)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Encoding), stream))); fieldInfo2.SetValue(objResult, temp2); object temp3 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo3.SetValue(objResult, temp3); object temp4 = ((Boolean)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Boolean), stream))); fieldInfo4.SetValue(objResult, temp4); object temp5 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo5.SetValue(objResult, temp5); object temp6 = ((UInt64)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(UInt64), stream))); fieldInfo6.SetValue(objResult, temp6); object temp7 = ((String)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(String), stream))); fieldInfo7.SetValue(objResult, temp7); object temp8 = ((Int32)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Int32), stream))); fieldInfo8.SetValue(objResult, temp8); object temp9 = ((ArraySegment<Byte>)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(ArraySegment<Byte>), stream))); fieldInfo9.SetValue(objResult, temp9); object temp10 = ((Boolean)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(Boolean), stream))); fieldInfo10.SetValue(objResult, temp10); return objResult; }
protected ulong Save(Message message) { if (message == null) { throw new ArgumentNullException("message"); } // Don't mark topics as active when publishing Topic topic = GetTopic(message.Key); ulong id = topic.Store.Add(message); Counters.MessageBusMessagesPublishedTotal.Increment(); Counters.MessageBusMessagesPublishedPerSec.Increment(); return id; }
protected override Task Send(Message[] messages) { return _sender.Send(messages); }
protected ulong Save(Message message) { if (message == null) { throw new ArgumentNullException("message"); } // GetTopic will return a topic for the given key. If topic exists and is Dying, // it will revive it and mark it as NoSubscriptions Topic topic = GetTopic(message.Key); // Mark the topic as used so it doesn't immediately expire (if it was in that state before). topic.MarkUsed(); return topic.Store.Add(message); }
private Message CreateMessage(string key, object value) { var command = value as Command; var message = new Message(_connectionId, key, _serializer.Stringify(value)); if (command != null) { // Set the command id message.CommandId = command.Id; message.WaitForAck = command.WaitForAck; } return message; }
public static object DeepCopier(object original) { Microsoft.AspNet.SignalR.Messaging.Message input = ((Microsoft.AspNet.SignalR.Messaging.Message)(original)); Microsoft.AspNet.SignalR.Messaging.Message result = new Microsoft.AspNet.SignalR.Messaging.Message(); Orleans.Serialization.SerializationContext.Current.RecordObject(original, result); result.CommandId = input.CommandId; object objResult = ((object)(result)); object temp2 = ((Encoding)(Orleans.Serialization.SerializationManager.DeepCopyInner(input.Encoding))); fieldInfo2.SetValue(objResult, temp2); object temp3 = input.Filter; fieldInfo3.SetValue(objResult, temp3); object temp4 = input.IsAck; fieldInfo4.SetValue(objResult, temp4); object temp5 = input.Key; fieldInfo5.SetValue(objResult, temp5); object temp6 = input.MappingId; fieldInfo6.SetValue(objResult, temp6); object temp7 = input.Source; fieldInfo7.SetValue(objResult, temp7); object temp8 = input.StreamIndex; fieldInfo8.SetValue(objResult, temp8); object temp9 = ((ArraySegment<Byte>)(Orleans.Serialization.SerializationManager.DeepCopyInner(input.Value))); fieldInfo9.SetValue(objResult, temp9); object temp10 = input.WaitForAck; fieldInfo10.SetValue(objResult, temp10); return objResult; }
protected override Task Send(Message[] messages) { return _connectTask.Then(msgs => { var taskCompletionSource = new TaskCompletionSource<object>(); // Group messages by source (connection id) var messagesBySource = msgs.GroupBy(m => m.Source); SendImpl(messagesBySource.GetEnumerator(), taskCompletionSource); return taskCompletionSource.Task; }, messages); }
public void Send(Message[] message) { this.action(message); }
protected override Task Send(Message[] messages) { return this.bus.SendAsync(messages); }