public void Publish <TEvent>(TEvent @event, string topic = "#") { Preconditions.Require(@event, "event"); Preconditions.Require(topic, "topic"); var messageTypeUri = registry.GetUri <TEvent>(); using (var channel = ChannelFactory.PublishTopic(topic)) { channel.Put(MessageSerializer.SerializeDefault(@event, messageTypeUri), messageTypeUri.ToString()); } }
public void Send <TCommand>(string destination, TCommand command) { Preconditions.Require(destination, "destination"); Preconditions.Require(command, "command"); var messageTypeUri = registry.GetUri <TCommand>(); try { using (var channel = ChannelFactory.PointToPointSend(destination)) { channel.Put(MessageSerializer.SerializeDefault(command, messageTypeUri), messageTypeUri.ToString()); } } catch (OperationInterruptedException oie) { throw new SkuttException( string.Format("Queue: {0} does not exist so you can't send a command to it", destination), oie); } catch (Exception e) { throw; } }