/// <summary> /// Sends a message to the specified destination. /// </summary> /// <param name = "m">The message to send.</param> /// <param name = "destination">The address of the destination to send the message to.</param> public void Send(TransportMessage m, string destination) { var xmsDestination = Aliases.GetIfDefined(destination).ToXmsDestination(); if (producerProvider == null) { producerProvider = new XmsProducerProvider(IsTransactional); } using(var producer = producerProvider.GetProducer(xmsDestination)) { var toSend = producer.CreateBytesMessage(); XmsUtilities.Convert(m, toSend, MessageSerializer); producer.Send(toSend); m.Id = toSend.JMSMessageID; } /* catch (Exception) //TODO: sasha - exception if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound) throw new ConfigurationErrorsException("The destination queue '" + destination + "' could not be found. You may have misconfigured the destination for this kind of message (" + m.Body[0].GetType().FullName + ") in the MessageEndpointMappings of the UnicastBusConfig section in your configuration file." + "It may also be the case that the given queue just hasn't been created yet, or has been deleted." , ex); throw; */ }
/// <summary> /// Starts the transport. /// </summary> public void Start() { producerProvider = new XmsProducerProvider(IsTransactional); consumerProvider = new XmsConsumerProvider(IsTransactional); CheckConfiguration(); inputDestination = Aliases.GetIfDefined(InputQueue).ToXmsDestination(); errorDestination = Aliases.GetIfDefined(ErrorQueue).ToXmsDestination(); if (ForwardReceivedMessagesTo != null) { forwardDestination = Aliases.GetIfDefined(ForwardReceivedMessagesTo).ToXmsDestination(); } if (PurgeOnStartup) { XmsUtilities.Purge(inputDestination); } for (int i = 0; i < numberOfWorkerThreads; i++) AddWorkerThread().Start(); }