public void Publish(object msg) { _log.Trace("Publishing {@Message} to transport", msg); _bus.Publish(msg); //for backward compability - a lot of legacy code publish bare messages and expect some results back //and new actors \ sagas work only with IMessageMetadataEnvelop Publish(msg, MessageMetadata.Empty()); }
public void Subscribe(Type messageType, IActorRef actor, IActorRef subscribeNotificationWaiter) { var topic = messageType.FullName; //TODO: replace wait with actor call var ack = _transport.Ask <SubscribeAck>(new Subscribe(topic, actor), _timeout).Result; subscribeNotificationWaiter.Tell(ack); _log.Trace("Subscribing handler actor {Path} to topic {Topic}", actor.Path, topic); }
private void Clear() { var now = BusinessDateTime.UtcNow; var childsToTerminate = Children.Where(c => now > c.Value.ExpiresAt) .Select(ch => ch.Key) .ToArray(); foreach (var childId in childsToTerminate) { //TODO: wait for child termination Children[childId].Ref.Tell(GracefullShutdownRequest.Instance); Children.Remove(childId); } Logger.Trace("Clear childs process finished, removed {childsToTerminate} childs", childsToTerminate.Length); }
public virtual void Handle(IMessageMetadataEnvelop <TMessage> msg) { _monitor.IncrementMessagesReceived(); _log.Trace("Handler actor got message: {@Message}", msg); try { var handlerWithMetadata = _handler as IHandlerWithMetadata <TMessage>; if (handlerWithMetadata != null) { handlerWithMetadata.Handle(msg.Message, msg.Metadata); } else { _handler.Handle(msg.Message); } } catch (Exception e) { _log.Error(e, "Handler actor raised an error on message process: {@Message}", msg); var metadata = msg.Metadata.CreateChild(Guid.Empty, new ProcessEntry(typeof(THandler).Name, MessageHandlingStatuses.PublishingFault, MessageHandlingStatuses.MessageProcessCasuedAnError)); var fault = Fault.New(msg.Message, e, GetSagaId(msg.Message), typeof(THandler)); _publisher.Publish(fault, metadata); } }
private void Apply(AccountBalanceReplenishEvent e) { _log.Trace("Balance {Id} with amount {AccountAmount} increased from event by {EventAmount}", Id, Amount, e.Amount); Amount += e.Amount; }
[HandleProcessCorruptedStateExceptions] // sometimes legacy wire deserializer can throw System.AccessViolationException public object FromBinary(byte[] bytes, Type type, JsonSerializerSettings settings = null) { try { using (var stream = new MemoryStream(bytes)) using (var reader = new StreamReader(stream, Encoding.Unicode)) { var jsonString = reader.ReadToEnd(); if (string.IsNullOrEmpty(jsonString)) { return(null); } var deserializeObject = JsonConvert.DeserializeObject(jsonString, settings ?? JsonSerializerSettings); if (deserializeObject == null) { throw new SerializationException("json string: " + jsonString); } return(deserializeObject); } } catch (Exception ex) { if (!UseWire) { ExceptionDispatchInfo.Capture(ex).Throw(); } _log.Trace("Received an error while deserializing {type} by json, switching to legacy wire. {Error}", type, ex); foreach (var serializer in WireSerializers) { try { using (var stream = new MemoryStream(bytes)) return(serializer.Item2().Deserialize(stream)); } catch (Exception ex1) { _log.Trace( "Received an error while deserializing {type} by new wire {wireName}, switching to next options variant. {Error}", type, serializer.Item1, ex1); } } foreach (var serializer in OldWireSerializers) { try { return(serializer.Item2().Deserialize(bytes, type)); } catch (Exception ex1) { _log.Trace( "Received an error while deserializing {type} by legacy wire {wireName}, switching to next options variant. {Error}", type, serializer.Item1, ex1); } } _log.Trace("Received an error while deserializing {type} by old wire, switching to new wire.", type); throw new SerializationException("Cannot deserialize message with any serializer"); } }
public void LogSuccess(string jobName) { _coreLogger.Trace("Job {JobName} sucessfully finished", jobName); }
private void Handle(object msg) { Log.Trace("got message from transpot: {@msg}", msg); }
public void JobScheduled(ITrigger trigger) { _log.Trace("Job {JobKey} scheduled for next execution {NextFireTime}", trigger.JobKey, trigger.GetNextFireTimeUtc()); }