Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. using System;
  2. using RabbitMQ.Client;
  3.  
  4. namespace RabbitMQ.Producer.Helper
  5. {
  6. public class RabbitHelper
  7. {
  8. static Lazy<IConnection> _connection=new Lazy<IConnection>(CreateConnection);
  9. public static IConnection GetConnection=>_connection.Value;
  10. static IConnection CreateConnection(){
  11. var factory = new ConnectionFactory() { HostName = "localhost"};
  12. var connection=factory.CreateConnection();
  13. return connection;
  14. }
  15. }
  16.  
  17.  
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement