/// <summary> /// Create the transacted MSMQ queue if necessary. /// </summary> /// <param name="queuePath"></param> void CreateQueue(string queuePath) { try { if (!MessageQueue.Exists(queuePath)) { MessageQueue.Create(queuePath, true); // Create a new trustee to represent the "system" user group. Trustee tr = new Trustee("SYSTEM"); MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow); // Apply the MessageQueueAccessControlEntry to the queue. SysEventQueue.SetPermissions(entry); if (!string.IsNullOrEmpty(Properties.Settings.Default.AdministratorGroupName)) { tr = new Trustee(Properties.Settings.Default.AdministratorGroupName); entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow); SysEventQueue.SetPermissions(entry); } } } catch (MessageQueueException ex) { ReceivedInfoProc.LogError(ex); } }
/// <summary> /// Initializes Mqueue instance to exchange messages /// </summary> /// <param name="label">Label associated to the queue</param> /// <returns>an instance of a Mqueue</returns> private MessageQueue InitMqueue(string queue, string label) { _readerWriteLockSlim.EnterWriteLock(); try { if (MessageQueue.Exists(queue) == false) { _log.Info(string.Format("{0} ==> ERROR: No existe la Cola [{1}], se procede a crearla", MethodBase.GetCurrentMethod().Name, queue)); // Si no existe crea la cola de comunicacion MessageQueue.Create(queue); } // Abre la cola de comunicacion _adquisitionQueue = new MessageQueue(queue); // Create a new trustee to represent the "Everyone" user group. SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); var account = (NTAccount)everyone.Translate(typeof(NTAccount)); Trustee tr = new Trustee(account.Value); // Create a MessageQueueAccessControlEntry, granting the trustee the right to receive messages from the queue. MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow); // Apply the MessageQueueAccessControlEntry to the queue. _adquisitionQueue.SetPermissions(entry); _adquisitionQueue.Label = string.Format("POINTS - {0}", label); _adquisitionQueue.DefaultPropertiesToSend.TimeToReachQueue = new TimeSpan(0, 0, 1); // Timeout 1 segundo if (_adquisitionQueue != null) { Point point = new Point(); Object o = new Object(); System.Type[] arrTypes = new System.Type[2]; arrTypes[0] = point.GetType(); arrTypes[1] = o.GetType(); _adquisitionQueue.Formatter = new XmlMessageFormatter(arrTypes); } return(_adquisitionQueue); } finally { _readerWriteLockSlim.ExitWriteLock(); } }
public void SetPermissions_Accesscontrolentry() { // <snippet24> // Connect to a queue on the local computer. MessageQueue queue = new MessageQueue(".\\exampleQueue"); // Create a new trustee to represent the "Everyone" user group. Trustee tr = new Trustee("Everyone"); // Create a MessageQueueAccessControlEntry, granting the trustee the // right to receive messages from the queue. MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry( tr, MessageQueueAccessRights.ReceiveMessage, AccessControlEntryType.Allow); // Apply the MessageQueueAccessControlEntry to the queue. queue.SetPermissions(entry); // </snippet24> }
static void MSMQTest() { MessageQueue mq; string path = ".\\private$\\td365_offcommitdata_" + type; if (MessageQueue.Exists(path)) { mq = new MessageQueue(path); } else { mq = MessageQueue.Create(path); } mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) }); Trustee tr = new Trustee("Everyone"); MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry( tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow ); mq.SetPermissions(entry); mq.Send("test"); }
public void SetPermissions(MessageQueueAccessControlEntry ace) {}
public void SetPermissions(MessageQueueAccessControlEntry ace) { }
public void SetPermissions(MessageQueueAccessControlEntry ace) { CheckDisposed(); _wrapped.SetPermissions(ace); }