How to successfully publish a Windows service for MSMQ

Source: Internet
Author: User
Tags msmq

Because the use of MSMQ need to constantly check whether the queue has new messages, so it is generally combined with Windows services, of course, you can also use a non-closed WinForm program, but the former better, not afraid of being mistaken.

After you complete the Windowsservice project for MSMQ, add the service project to the Windows service.

① If you are accessing a queue that already exists, you will be reporting an error when you start it "stops after the XXXX service on the local computer starts. Some services will stop automatically when they are not being used by other services or programs.

This is because no permissions are assigned.

How to: Right-click the queue you want to access, security

Check the full control of Everyone and ANONYMOUS LOGON separately

② sending a message to a remote queue

The path format and use of the queue when accessing local queues

var @" . \PRIVATE$\MYMQ " ; MessageQueue _mq; if (Messagequeue.exists (Mqpath)) {    new  MessageQueue (Mqpath);} Else {    = messagequeue.create (mqpath);}

When accessing a remote queue, the code is slightly different:

1. path format for remote queues:string path = @ "formatname:direct=tcp:192.168.1.11\private$\mymq " ; Keyword is case insensitive

2.MSMQ method for determining whether a queue exists (messagequeue.exists (string path)) and creating a queue (messagequeue.create ( String path), is not supported for remote queues.

1. An error occurs using the Exists method " Unable to determine whether a queue with the specified format name exists. "

2. The error " unable to create a queue with path Formatname:direct=tcp:192.168.1.11\private$\mymq " appears with the Create method

3. Due to the limitations of the first two, if you want to access a remote private queue, you must ensure that the queue is present on the remote machine beforehand.

var @" FORMATNAME:DIRECT=TCP:192.168.1.11\PRIVATE$\MYMQ "  New MessageQueue (QueuePath);

4. When sending a message to a remote queue, the system creates a temporary queue under the native's outgoing queue, with each message being sent with a temporary queue, which is intended to prevent the loss of a message because the remote queue is inaccessible.

It is important to note, however, that if the remote machine does not connect successfully, the message is kept in the temporary queue, and if the connection is successful, the message sender does not get an error even if the queue to be accessed does not exist, and the message in the temporary queue is deleted.

so make sure you build the queue on the remote server first. Outgoing queue specific information such as:

5. If the transactional properties do not match, the message cannot be delivered. The system does not return any errors, but the message is discarded.

 MSMQ denied access error

How to successfully publish a Windows service for MSMQ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.