public bool Send(IMessage message)
        {
            IProducer producer;

            if (!producerContainer.ContainsKey(message.Headers[BuiltinKeys.Topic]))
            {
                MessagingAccessPoint        accessPoint = MessagingAccessPointFactory.getMessagingAccessPoint();
                Dictionary <string, string> properties  = new Dictionary <string, string>();
                if (message.Headers.TryGetValue(BuiltinKeys.Exchange, out string exchange))
                {
                    properties.Add(BuiltinKeys.Exchange, exchange);
                }
                if (message.Headers.TryGetValue(BuiltinKeys.Topic, out string topic))
                {
                    properties.Add(BuiltinKeys.Topic, topic);
                }
                producer = accessPoint.createProducer(properties);
                producer.startup();
                producerContainer.TryAdd(message.Headers[BuiltinKeys.Topic], producer);
            }
            else
            {
                producer = producerContainer[message.Headers[BuiltinKeys.Topic]];
            }
            return(producer.Send(message));
        }
예제 #2
0
 public static void Init(IProducerContainer _producerContainer, IConsumerContainer _consumerContainer, ILogger logger = null)
 {
     producerContainer = _producerContainer;
     consumerContainer = _consumerContainer;
     if (logger != null)
     {
         MessagingAccessPointFactory.getMessagingAccessPoint().addLogger(logger);
     }
 }
예제 #3
0
 public static void Init(IMonitor _monitor, ILogger logger = null)
 {
     producerContainer = new RabbitMQProducerContainer();
     consumerContainer = new RabbitMQConsumerContainer(_monitor);
     if (logger != null)
     {
         MessagingAccessPointFactory.getMessagingAccessPoint().addLogger(logger);
     }
 }
예제 #4
0
 public void Add(string exchange, string topic)
 {
     if (!consumerContainer.ContainsKey(topic))
     {
         Dictionary <string, string> properties = new Dictionary <string, string>();
         properties.Add(BuiltinKeys.Exchange, exchange);
         properties.Add(BuiltinKeys.Topic, topic);
         MessagingAccessPoint accessPoint = MessagingAccessPointFactory.getMessagingAccessPoint(configuration.GetConnectionString("MTConnectionString"));
         IConsumer            consumer    = accessPoint.createConsumer(properties);
         consumer.startup();
         consumer.resume();
         consumerContainer.TryAdd(topic, consumer);
     }
 }
예제 #5
0
        public bool Send(IMessage message)
        {
            IProducer producer;

            if (!producerContainer.ContainsKey(message.Headers[BuiltinKeys.Topic]))
            {
                MessagingAccessPoint accessPoint = MessagingAccessPointFactory.getMessagingAccessPoint(configuration.GetConnectionString("MTConnectionString"));
                producer = accessPoint.createProducer(message.Headers);
                producer.startup();
                producerContainer.TryAdd(message.Headers[BuiltinKeys.Topic], producer);
            }
            else
            {
                producer = producerContainer[message.Headers[BuiltinKeys.Topic]];
            }
            return(producer.Send(message));
        }
 public void Add(string exchange, string topic)
 {
     if (!consumerContainer.ContainsKey(topic))
     {
         Dictionary <string, string> properties = new Dictionary <string, string>();
         properties.Add(BuiltinKeys.Exchange, exchange);
         properties.Add(BuiltinKeys.Topic, topic);
         MessagingAccessPoint accessPoint = MessagingAccessPointFactory.getMessagingAccessPoint();
         IConsumer            consumer    = accessPoint.createConsumer(properties);
         consumer.setProcessor(new RestApiProcessor());
         if (monitor != null)
         {
             consumer.addMonitor(monitor);
         }
         consumer.startup();
         consumer.resume();
         consumerContainer.TryAdd(topic, consumer);
     }
 }