private Message BuildMsmqMessage(Int32 command, string descriptor, object message, IMessageEndpoint responseEndpoint, TimeSpan?timeToLive) { if (responseEndpoint != null && !(responseEndpoint is MsmqMessageEndpoint)) { throw new NotSupportedException("MSMQ endpoints can only talk to each other!"); } MessageQueue responseQueue = null; var msmqResponseEndpoint = responseEndpoint as MsmqMessageEndpoint; if (msmqResponseEndpoint != null) { responseQueue = msmqResponseEndpoint.MessageQueue; } var msmqMessage = new Message { AppSpecific = (int)command, Body = message, Formatter = (IMessageFormatter)MessageFormatter.Clone(), Label = descriptor, Recoverable = true, ResponseQueue = responseQueue, }; if (timeToLive.HasValue) { msmqMessage.TimeToBeReceived = timeToLive.Value; } return(msmqMessage); }
public async Task DimeSchedulerClient_MessageEndpoint_ShouldCreate() { const string uri = "http://mydimescheduler.io"; IAuthenticator authenticator = new MockAuthenticator(); DimeSchedulerClient client = new(uri, authenticator); IMessageEndpoint endpoint = await client.Messages.Request(); Assert.NotNull(endpoint); }
public async Task NotifyDown <T>(IMessageEndpoint <T> endpoint) where T : class { var receiveEndpoint = await _receiveEndpoint.Task.ConfigureAwait(false); await receiveEndpoint.CreatePublishEndpoint(_instanceAddress.Value).Publish <Down <T> >(new { endpoint.ServiceAddress, Endpoint = endpoint.EndpointInfo }).ConfigureAwait(false); }
public async Task NotifyUp <T>(IMessageEndpoint <T> endpoint) where T : class { var receiveEndpoint = await _receiveEndpoint.Task.ConfigureAwait(false); await receiveEndpoint.CreatePublishEndpoint(_instanceAddress.Value).Publish <Up <T> >(new { __CorrelationId = NewId.NextGuid(), endpoint.ServiceAddress, Endpoint = endpoint.EndpointInfo }).ConfigureAwait(false); }
public void ConfigureMessageEndpoint <T>(IMessageEndpoint <T> endpoint) where T : class { if (_messageTypes.ContainsKey(typeof(T))) { throw new ArgumentException($"The message type was already added by another service endpoint: {TypeMetadataCache<T>.ShortName}", nameof(T)); } _messageTypes.Add(typeof(T), endpoint); _configurator.Consumer(() => new LinkConsumer <T>(endpoint)); }
public async Task NotifyUp <T>(IMessageEndpoint <T> endpoint) where T : class { var receiveEndpoint = await _receiveEndpoint.Task.ConfigureAwait(false); var sendEndpoint = await receiveEndpoint.GetPublishSendEndpoint <Up <T> >().ConfigureAwait(false); await sendEndpoint.Send <Up <T> >(new { __CorrelationId = NewId.NextGuid(), endpoint.ServiceAddress, Endpoint = endpoint.EndpointInfo }).ConfigureAwait(false); }
public async Task NotifyDown <T>(IMessageEndpoint <T> endpoint) where T : class { var receiveEndpoint = await _receiveEndpoint.Task.ConfigureAwait(false); var initializeContext = await MessageInitializerCache <Down <T> > .Initialize(new { __CorrelationId = NewId.NextGuid(), endpoint.ServiceAddress, Endpoint = endpoint.EndpointInfo }).ConfigureAwait(false); await receiveEndpoint.CreatePublishEndpoint(_instanceAddress.Value).Publish(initializeContext.Message).ConfigureAwait(false); await endpoint.NotifyClients(receiveEndpoint, initializeContext.Message).ConfigureAwait(false); }
public void Send <TMessage>(TMessage message, IMessageEndpoint responseEndpoint = null, TimeSpan?timeToLive = null) { var msmqMessage = BuildMsmqMessage( MessageCommand, typeof(TMessage).Name, message, responseEndpoint, timeToLive ); using (var transaction = new MessageQueueTransaction()) { transaction.Begin(); MessageQueue.Send(msmqMessage, transaction); transaction.Commit(); } Trace.WriteLine(string.Format("Sent {0} message {1}", typeof(TMessage).Name, msmqMessage.Id)); }
public async Task Execute() { try { IAuthenticator authenticator = new FormsAuthenticator (DimeSchedulerCredentials.Uri, DimeSchedulerCredentials.User, DimeSchedulerCredentials.Password); DimeSchedulerClient client = new(DimeSchedulerCredentials.Uri, authenticator); IMessageEndpoint endpoint = await client.Messages.Request(); await endpoint.PostAsync(new MessageRequest() { Text = "Danger!", User = "******", Severity = Severity.Warning }); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public Program(string localUri, string remoteUri) { _localEndpoint = new MsmqMessageEndpoint(localUri); _remoteEndpoint = new MsmqMessageEndpoint(remoteUri); }
public void SendControlCommand(Int32 command, string descriptor, object message, IMessageEndpoint responseEndpoint = null, TimeSpan?timeToLive = null) { var msmqMessage = BuildMsmqMessage(command, descriptor, message, responseEndpoint, timeToLive); using (var transaction = new TransactionScope()) { MessageQueue.Send(msmqMessage, MessageQueueTransactionType.Automatic); transaction.Complete(); } Trace.WriteLine(string.Format("Sent command: {0}", command.ToString())); }
public ConductorMessageFilter(IMessageEndpoint <TMessage> endpoint) { _endpoint = endpoint; }
public LinkConsumer(IMessageEndpoint <T> messageEndpoint) { _messageEndpoint = messageEndpoint; }
public MessageViewModel(IMessageEndpoint messageEndpoint, ILoggedInUserModel loggedInUser, IMessagePostEndpoint messagePost) { _messageEndpoint = messageEndpoint; _loggedInUser = loggedInUser; _messagePostEndpoint = messagePost; }