public void Send(TransportMessage message, Address address)
        {
            try
            {
                XmsAddress addr = address.ToXmsAddress();
                using (var producer = provider.GetProducer(addr))
                {
                    var xmsMessage = producer.CreateBytesMessage();
                    XmsUtilities.Convert(message, xmsMessage);
                    producer.Send(xmsMessage);
                    message.Id = xmsMessage.JMSMessageID;
                   
                }
            }
            // TODO: QueueNotFoundException
            catch (Exception ex)
            {
                if (address == null)
                    throw new FailedToSendMessageException("Failed to send message.", ex);

                throw new FailedToSendMessageException(
                    string.Format("Failed to send message to address: {0}@{1}", address.Queue, address.Machine), ex);
            }
         
        }
 public void Init(Address address, bool transactional)
 {
     this.address = address.ToXmsAddress();
     if (PurgeOnStartup)
         XmsUtilities.Purge(this.address);
     this.useTransactions = transactional;
     this.consumerProducer = new XmsConsumerProvider(transactional);
 }
Пример #3
0
 public void GIVEN_existing_ns_address_WHEN_parsed_to_xms_THEN_values_match()
 {
     var address = new Address("QUEUE", "MANAGER:HOSTNAME:42:CHANNEL");
     var xms = address.ToXmsAddress();
     Assert.That(xms.Queue, Is.EqualTo("QUEUE"));
     Assert.That(xms.Host.Manager, Is.EqualTo("MANAGER"));
     Assert.That(xms.Host.HostName, Is.EqualTo("HOSTNAME"));
     Assert.That(xms.Host.Port, Is.EqualTo(42));
     Assert.That(xms.Host.Channel, Is.EqualTo("CHANNEL"));
     Assert.That(xms.Host.ConnectionName, Is.EqualTo("HOSTNAME(42)"));
 }
Пример #4
0
 public void GIVEN_invalid_address_WHEN_parsing_THE_throws()
 {
     var address = new Address("foo", "blahhh");
     var ex = Assert.Throws<Exception>(()=>address.ToXmsAddress());
     Assert.That(ex.Message, Is.EqualTo("Unable to parse foo@blahhh to xms address."));
 }