Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (21 sloc) 614 Bytes
using NATS.Client;
using NerdDinner.Messaging.Messages;
namespace NerdDinner.Messaging
{
public class MessageQueue
{
public static void Publish<TMessage>(TMessage message)
where TMessage : Message
{
using (var connection = CreateConnection())
{
var data = MessageHelper.ToData(message);
connection.Publish(message.Subject, data);
}
}
public static IConnection CreateConnection()
{
return new ConnectionFactory().CreateConnection(Env.MessageQueueUrl);
}
}
}