public void PublishBatch <T>(IEnumerable <T> enumerable, PublishOptions options) { var activity = MessageDiagnostics.StartMessageOut(options); try { var context = CreateContext <T>(options); var batch = _model.CreateBasicPublishBatch(); var messages = _serialization.SerializeBatch(enumerable, context.Properties.ContentType); foreach (var obj in messages) { batch.Add( exchange: context.Exchange, body: obj, mandatory: false, properties: context.Properties, routingKey: context.RoutingKey ); } batch.Publish(); } finally { MessageDiagnostics.StopMessageOut(activity, options); } }
public void Publish <T>(T obj, PublishOptions options) { var activity = MessageDiagnostics.StartMessageOut(options); try { var context = CreateContext <T>(options); _model.BasicPublish( basicProperties: context.Properties, body: _serialization.Serialize(obj, context.Properties.ContentType), exchange: context.Exchange, routingKey: context.RoutingKey ); } finally { MessageDiagnostics.StopMessageOut(activity, options); } }