@@ -16,22 +16,24 @@ namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure
1616 public class EventBus : IEventBus
1717 {
1818 private readonly string _brokerName = "event_bus" ;
19+ private readonly string _connectionString ;
1920 private readonly Dictionary < string , List < IIntegrationEventHandler > > _handlers ;
2021 private readonly List < Type > _eventTypes ;
2122
2223 private Tuple < IModel , IConnection > _connection ;
2324 private string _queueName ;
2425
2526
26- public EventBus ( )
27+ public EventBus ( string connectionString )
2728 {
29+ _connectionString = connectionString ;
2830 _handlers = new Dictionary < string , List < IIntegrationEventHandler > > ( ) ;
2931 _eventTypes = new List < Type > ( ) ;
3032 }
3133 public void Publish ( IIntegrationEvent @event )
3234 {
3335 var eventName = @event . GetType ( ) . Name ;
34- var factory = new ConnectionFactory ( ) { HostName = "172.20.0.1" } ;
36+ var factory = new ConnectionFactory ( ) { HostName = _connectionString } ;
3537 using ( var connection = factory . CreateConnection ( ) )
3638 using ( var channel = connection . CreateModel ( ) )
3739 {
@@ -105,7 +107,7 @@ private IModel GetChannel()
105107 }
106108 else
107109 {
108- var factory = new ConnectionFactory ( ) { HostName = "172.20.0.1" } ;
110+ var factory = new ConnectionFactory ( ) { HostName = _connectionString } ;
109111 var connection = factory . CreateConnection ( ) ;
110112 var channel = connection . CreateModel ( ) ;
111113
0 commit comments