Ejemplo n.º 1
0
 /// <summary>
 /// Send message to input queue of this service bus instance.
 /// Can be used for "requeueing" of message.
 /// </summary>
 /// <param name="messages"></param>
 public void SendLocal(params object[] messages)
 {
     ServiceBusMessage serviceBusMessage = new ServiceBusMessage(messages);
     TransportMessage transportMessage = _provider.TranslateToTransportMessage(serviceBusMessage);
     _errorTransportEndpoint.Send(transportMessage);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Send message. Recipient resolved by the object type.
        /// </summary>
        public void Send(params object[] messages)
        {
            // Skip if there is no messages
            if (messages == null || messages.Length < 1)
                return;

            // Create transport message
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(messages);
            serviceBusMessage.SentFromQueueName = _inputTransportEndpointAddress.GetFriendlyName();

            // Get list of endpoints we need send message to
            var endpoints = _endpointMapping.GetEndpoints(messages[0].GetType());

            foreach (var endpoint in endpoints)
            {
                // Create EndpointMessage from TransportMessage
                var provider = TransportRegistry.GetQueueProvider(endpoint.Address);
                TransportMessage transportMessage = provider.TranslateToTransportMessage(serviceBusMessage);

                // Send message
                var queue = provider.OpenEndpoint(endpoint.Address);
                queue.Send(transportMessage);
            }
        }