What Is MSMQ?

MSMQ (Microsoft Message Queuing) is a Windows-based messaging infrastructure that enables different applications and computers to communicate with each other through messages.

In traditional application communication, the sending application attempts to connect directly to the receiving application to deliver data. With the MSMQ approach, the sender places the message in a queue instead of sending it directly to the application. The receiving application can then read the message from the queue.

This eliminates the requirement for both applications to be running at the same time. Even if the receiving application is temporarily unavailable, the message can remain in the queue and be processed when the application starts again.

In Microsoft's documentation, MSMQ is described as a messaging service that provides features such as asynchronous and reliable messaging, persistent message storage in queues, routing, security, and prioritization.

How Does MSMQ Work?

The easiest way to understand how MSMQ works is to think of a mailbox. The sending application places a message in the queue. The message is stored by the queue, and the receiving application retrieves it when it is ready.

1. A Message Is Sent

An application creates a message containing data or a command and sends it to the target queue.

2. The Message Waits in the Queue

The message is placed in the queue by the Queue Manager and waits until the receiving application is ready.

3. The Receiver Reads the Message

The receiving application connects to the queue, reads the pending messages, and processes them.

4. The Message Is Processed

Depending on the message content, data can be stored, an operation can be initiated, or the message can be transferred to another system.

MSMQ Data Addressing for EOS Software (Q#)

In the EOS SCADA MSMQ client, the data address is specified using the row number in the MSMQ data structure.

Q#ROW_NO

For example, to access the data in row number 27:

Q#27

The row number in the MSMQ data address must be a numeric value.

Queue and Queue Manager

One of the fundamental components of the MSMQ architecture is the Queue Manager. The Queue Manager is responsible for managing message queues on the computer and for operations related to sending, receiving, and processing messages.

When an application wants to send or receive messages using MSMQ, it communicates with the Queue Manager. The Queue Manager also plays a role in transferring messages between Queue Manager components running on different computers.

Queue

A logical mailbox where messages are stored temporarily or persistently. One application can send messages to a queue while another application can read those messages later.

Queue Manager

An MSMQ service component responsible for managing queues and messages. It is one of the main communication layers between applications and the message queue.

MSMQ Features

Asynchronous Messaging

Messages can be exchanged without requiring the sending and receiving applications to run at the same time.

Message Storage in Queues

Messages can remain in the queue until the receiving application is ready. This reduces timing dependencies between applications.

Reliable Messaging

MSMQ provides a message queuing infrastructure for reliable message delivery in distributed applications.

Message Priority

Messages can be managed with priority information. Critical messages can be processed with higher priority.

Message Routing

Distributed systems can support the transfer of messages between different computers and queues.

Security

Access to messaging systems can be controlled using Windows security mechanisms and the security features provided by MSMQ.

Distributed Applications

A loosely coupled and asynchronous communication infrastructure can be established between applications running on different computers.

Windows Integration

MSMQ is a messaging infrastructure that can be used with the Windows operating system and .NET-based applications.

MSMQ Messages

In MSMQ, a message is a unit of information sent from one application to another. A message can contain data defined by the application as well as properties related to how the message is delivered and processed.

For example, in an industrial application, the message content may include an alarm notification, device status, measurement value, operator command, or event record.

How the message content is interpreted is determined by the sending and receiving applications. Therefore, MSMQ is not an industrial data model that defines what a message means from an application perspective.

MSMQ Queue Types

Private Queue

Private queues are managed by the local Queue Manager and are not published as public queues in Active Directory. They can be used especially for messaging between applications running on a specific computer.

Public Queue

Public queues can be configured for broader use in a network environment and can be discovered in environments integrated with Active Directory.

The appropriate queue type is determined according to the application's architecture, network environment, and security requirements.

Reliable Messaging

One of the important advantages of MSMQ is that it can decouple communication between applications from direct connections. After placing a message in the queue, the sending application does not have to wait for the receiving application to respond immediately.

This approach can be particularly useful in situations involving temporary network interruptions, application restarts, or systems that need to communicate while operating at different speeds.

For example, a fast data collection application can transfer data to a slower recording or analysis application through a message queue without requiring a direct connection between them.

Communication Structure Used by MSMQ

Rather than thinking of MSMQ as a single network protocol, it is more accurate to consider it a protocol family used by the Message Queuing service.

Microsoft's MSMQ protocol documentation defines various protocols for different purposes, including message transfer, communication between the Queue Manager and clients, management, remote queue reading, and directory services.

  • Queue Manager Client Protocol
  • Binary Reliable Messaging Protocol
  • SOAP Reliable Messaging Protocol (SRMP)
  • Queue Manager Management Protocol
  • Queue Manager Remote Read Protocol
  • Directory Service protocols

This architecture enables MSMQ to support not only queue operations within applications, but also message transfer and management operations between Queue Manager components running on different computers.

MSMQ and Network Communication

MSMQ can use different communication mechanisms. Traditional MSMQ message transfer can use TCP/IP and UDP-based communication. Microsoft's Windows Server network requirements documentation lists TCP/UDP 1801 among the main service ports used by MSMQ.

SRMP (SOAP Reliable Messaging Protocol), MSMQ's HTTP-based communication mechanism, can transfer SOAP messages over HTTP or HTTPS.

HTTP/HTTPS-based communication provides an alternative that can be used especially in communication scenarios across different networks.

Using MSMQ in Industrial Systems

MSMQ is not a communication protocol for PLCs or field devices. Instead, it can be used by industrial software applications to exchange data and events reliably with each other.

For example, instead of sending data collected from field devices directly to another application, a SCADA system can place the data into an MSMQ queue. Data processing, reporting, archiving, or analysis applications can then read these messages from the queue.

SCADA and Data Collection

Transferring data and status messages from SCADA or Data Logger applications to other applications.

Alarm Distribution

Sending SCADA alarm events to queues for notification, analysis, or processing by another application.

Event Recorder

Reliably transferring and queuing event records for processing by another application.

Data Analysis

Transferring collected data to analysis, reporting, or artificial intelligence applications through a message queue.

Distributed Software Architectures

Enabling industrial software components running on different computers to communicate independently of each other.

Background Processes

Providing communication between data processing, recording, reporting, and notification services that operate independently of the user interface.

Difference Between MSMQ and MQTT

Although both MSMQ and MQTT can be used for messaging, they are not the same technology.

Feature MSMQ MQTT
Basic approach Message queue Publish / Subscribe
Platform Windows / Microsoft ecosystem Platform independent
Typical use Distributed applications and Windows services IoT and industrial device messaging
Message structure Queue-based Topic-based
Communication model Queue Broker / Topic

Therefore, in SCADA or industrial software architectures, MSMQ and MQTT do not necessarily have to be direct alternatives to each other. Depending on the use case, both technologies can also be used for different purposes within the same system.

Advantages of MSMQ

  • Enables asynchronous communication between applications.
  • Sending and receiving applications do not have to be running at the same time.
  • Messages can be stored in queues.
  • Provides a communication model suitable for distributed applications.
  • Provides message prioritization capabilities.
  • Can be used together with the Windows security infrastructure.
  • Can be integrated with Windows services and .NET applications.
  • Can transfer data, event, and command messages between industrial software applications.

Considerations When Using MSMQ

Although MSMQ is a powerful messaging infrastructure, it is not necessarily the most suitable technology for every application. When designing a new system, factors such as the operating system, application architecture, network environment, security, and interoperability requirements should be considered.

MSMQ can be a meaningful option, particularly in environments with a large number of Windows-based applications. On the other hand, for projects requiring support for different operating systems, IoT devices, or a wide range of platforms, MQTT, AMQP, or other modern messaging technologies may be more appropriate.

In addition, when implementing a message queuing system, issues such as queue growth, messages that cannot be consumed, network failures, authorization, and error handling should be addressed separately in the application design.

Summary

MSMQ (Microsoft Message Queuing) is a message queuing technology developed to provide reliable and asynchronous messaging between applications in Windows environments.

The basic idea is simple: One application places a message in a queue, the message is stored there, and another application reads and processes it when it is ready.

This architecture enables communication between SCADA, Data Logger, Event Recorder, reporting, data analysis, and other industrial software components without requiring direct connections between them.

Particularly in Windows-based distributed industrial software architectures, MSMQ can be considered a reliable messaging layer between applications.

MSMQ Tools

This section will provide tools that can be used to work with MSMQ, manage queues, send and receive messages, test connections, and develop MSMQ-based applications.

MSMQ tools that will be developed or shared as part of the EOS Industrial Software Portal will be added to this section over time.

MSMQ Tools Coming Soon

Downloadable MSMQ tools, utility applications, testing tools, and example projects will be published here as they become available.