<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
message	B-Operating_System
queues	I-Operating_System
and	O
mailboxes	B-Operating_System
are	O
software-engineering	B-General_Concept
components	B-Architecture
typically	O
used	O
for	O
inter-process	B-Operating_System
communication	I-Operating_System
(	O
IPC	O
)	O
,	O
or	O
for	O
inter-thread	B-Operating_System
communication	I-Operating_System
within	O
the	O
same	O
process	O
.	O
</s>
<s>
They	O
use	O
a	O
queue	B-Application
for	O
messaging	O
–	O
the	O
passing	O
of	O
control	O
or	O
of	O
content	O
.	O
</s>
<s>
Group	B-Operating_System
communication	I-Operating_System
systems	I-Operating_System
provide	O
similar	O
kinds	O
of	O
functionality	O
.	O
</s>
<s>
The	O
message	B-Operating_System
queue	I-Operating_System
paradigm	O
is	O
a	O
sibling	O
of	O
the	O
publisher/subscriber	B-Operating_System
pattern	O
,	O
and	O
is	O
typically	O
one	O
part	O
of	O
a	O
larger	O
message-oriented	B-Application
middleware	I-Application
system	O
.	O
</s>
<s>
Most	O
messaging	B-Operating_System
systems	I-Operating_System
support	O
both	O
the	O
publisher/subscriber	B-Operating_System
and	O
message	B-Operating_System
queue	I-Operating_System
models	O
in	O
their	O
API	B-Application
,	O
e.g.	O
</s>
<s>
Java	B-Language
Message	I-Language
Service	I-Language
(	O
JMS	B-Language
)	O
.	O
</s>
<s>
Message	B-Operating_System
queues	I-Operating_System
implement	O
an	O
asynchronous	B-Operating_System
communication	I-Operating_System
pattern	I-Operating_System
between	O
two	O
or	O
more	O
processes/threads	O
whereby	O
the	O
sending	O
and	O
receiving	O
party	O
do	O
not	O
need	O
to	O
interact	O
with	O
the	O
message	B-Operating_System
queue	I-Operating_System
at	O
the	O
same	O
time	O
.	O
</s>
<s>
Messages	O
placed	O
onto	O
the	O
queue	B-Application
are	O
stored	O
until	O
the	O
recipient	O
retrieves	O
them	O
.	O
</s>
<s>
Message	B-Operating_System
queues	I-Operating_System
have	O
implicit	O
or	O
explicit	O
limits	O
on	O
the	O
size	O
of	O
data	O
that	O
may	O
be	O
transmitted	O
in	O
a	O
single	O
message	O
and	O
the	O
number	O
of	O
messages	O
that	O
may	O
remain	O
outstanding	O
on	O
the	O
queue	B-Application
.	O
</s>
<s>
Many	O
implementations	O
of	O
message	B-Operating_System
queues	I-Operating_System
function	O
internally	O
within	O
an	O
operating	B-General_Concept
system	I-General_Concept
or	O
within	O
an	O
application	B-Application
.	O
</s>
<s>
Such	O
queues	B-Application
exist	O
for	O
the	O
purposes	O
of	O
that	O
system	O
only	O
.	O
</s>
<s>
Other	O
implementations	O
allow	O
the	O
passing	O
of	O
messages	O
between	O
different	O
computer	O
systems	O
,	O
potentially	O
connecting	O
multiple	O
applications	O
and	O
multiple	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
These	O
message	B-Operating_System
queuing	I-Operating_System
systems	O
typically	O
provide	O
resilience	B-General_Concept
functionality	O
to	O
ensure	O
that	O
messages	O
do	O
not	O
get	O
"	O
lost	O
"	O
in	O
the	O
event	O
of	O
a	O
system	O
failure	O
.	O
</s>
<s>
Examples	O
of	O
commercial	O
implementations	O
of	O
this	O
kind	O
of	O
message	B-Operating_System
queuing	I-Operating_System
software	O
(	O
also	O
known	O
as	O
message-oriented	B-Application
middleware	I-Application
)	O
include	O
IBM	B-Application
MQ	I-Application
(	O
formerly	O
MQ	B-Application
Series	I-Application
)	O
and	O
Oracle	B-Application
Advanced	I-Application
Queuing	I-Application
(	O
AQ	O
)	O
.	O
</s>
<s>
There	O
is	O
a	O
Java	B-Device
standard	O
called	O
Java	B-Language
Message	I-Language
Service	I-Language
,	O
which	O
has	O
several	O
proprietary	B-Application
and	O
free	B-Application
software	I-Application
implementations	O
.	O
</s>
<s>
Real-time	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
(	O
RTOSes	O
)	O
such	O
as	O
VxWorks	B-Operating_System
and	O
QNX	B-Operating_System
encourage	O
the	O
use	O
of	O
message	B-Operating_System
queuing	I-Operating_System
as	O
the	O
primary	O
inter-process	O
or	O
inter-thread	B-Operating_System
communication	I-Operating_System
mechanism	O
.	O
</s>
<s>
Early	O
examples	O
of	O
commercial	O
RTOSes	O
that	O
encouraged	O
a	O
message-queue	O
basis	O
to	O
inter-thread	B-Operating_System
communication	I-Operating_System
also	O
include	O
VRTX	B-Operating_System
and	O
pSOS+	B-Operating_System
,	O
both	O
of	O
which	O
date	O
to	O
the	O
early	O
1980s	O
.	O
</s>
<s>
The	O
Erlang	B-Operating_System
programming	I-Operating_System
language	I-Operating_System
uses	O
processes	O
to	O
provide	O
concurrency	O
;	O
these	O
processes	O
communicate	O
asynchronously	O
using	O
message	B-Operating_System
queuing	I-Operating_System
.	O
</s>
<s>
The	O
message	B-Operating_System
queue	I-Operating_System
software	O
can	O
be	O
either	O
proprietary	B-Application
,	O
open	O
source	O
or	O
a	O
mix	O
of	O
both	O
.	O
</s>
<s>
It	O
is	O
then	O
run	O
either	O
on	O
premise	O
in	O
private	O
servers	O
or	O
on	O
external	O
cloud	O
servers	O
(	O
message	B-General_Concept
queuing	I-General_Concept
service	I-General_Concept
)	O
.	O
</s>
<s>
Proprietary	B-Application
options	O
have	O
the	O
longest	O
history	O
,	O
and	O
include	O
products	O
from	O
the	O
inception	O
of	O
message	B-Operating_System
queuing	I-Operating_System
,	O
such	O
as	O
IBM	B-Application
MQ	I-Application
,	O
and	O
those	O
tied	O
to	O
specific	O
operating	B-General_Concept
systems	I-General_Concept
,	O
such	O
as	O
Microsoft	B-Application
Message	I-Application
Queuing	I-Application
(	O
MSMQ	B-Application
)	O
.	O
</s>
<s>
Cloud	O
service	O
providers	O
also	O
provide	O
their	O
proprietary	B-Application
solutions	O
such	O
as	O
Amazon	B-Operating_System
Simple	I-Operating_System
Queue	I-Operating_System
Service	I-Operating_System
(	O
SQS	B-Operating_System
)	O
,	O
StormMQ	O
,	O
Solace	O
,	O
and	O
IBM	B-Application
MQ	I-Application
.	O
</s>
<s>
Open	O
source	O
choices	O
of	O
messaging	B-Application
middleware	I-Application
systems	O
includes	O
Apache	B-Language
ActiveMQ	I-Language
,	O
Apache	B-Language
Kafka	I-Language
,	O
Apache	B-Application
Qpid	I-Application
,	O
Apache	B-Application
RocketMQ	I-Application
,	O
Enduro/X	B-Application
,	O
JBoss	B-Language
Messaging	I-Language
,	O
JORAM	O
,	O
RabbitMQ	B-Application
,	O
Sun	B-Language
Open	I-Language
Message	I-Language
Queue	I-Language
,	O
and	O
Tarantool	B-Operating_System
.	O
</s>
<s>
Examples	O
on	O
hardware-based	O
messaging	B-Application
middleware	I-Application
vendors	O
are	O
Solace	O
,	O
Apigee	B-General_Concept
,	O
and	O
IBM	B-Application
MQ	I-Application
.	O
</s>
<s>
In	O
a	O
typical	O
message-queueing	O
implementation	O
,	O
a	O
system	B-Application
administrator	I-Application
installs	O
and	O
configures	O
message-queueing	O
software	O
(	O
a	O
queue	B-General_Concept
manager	I-General_Concept
or	O
broker	O
)	O
,	O
and	O
defines	O
a	O
named	O
message	B-Operating_System
queue	I-Operating_System
.	O
</s>
<s>
Or	O
they	O
register	O
with	O
a	O
message	B-General_Concept
queuing	I-General_Concept
service	I-General_Concept
.	O
</s>
<s>
An	O
application	B-Application
then	O
registers	O
a	O
software	O
routine	O
that	O
"	O
listens	O
"	O
for	O
messages	O
placed	O
onto	O
the	O
queue	B-Application
.	O
</s>
<s>
Second	O
and	O
subsequent	O
applications	O
may	O
connect	O
to	O
the	O
queue	B-Application
and	O
transfer	O
a	O
message	O
onto	O
it	O
.	O
</s>
<s>
The	O
queue-manager	O
software	O
stores	O
the	O
messages	O
until	O
a	O
receiving	O
application	B-Application
connects	O
and	O
then	O
calls	O
the	O
registered	O
software	O
routine	O
.	O
</s>
<s>
The	O
receiving	O
application	B-Application
then	O
processes	O
the	O
message	O
in	O
an	O
appropriate	O
manner	O
.	O
</s>
<s>
Routing	O
policies	O
–	O
in	O
a	O
system	O
with	O
many	O
queue	B-Application
servers	O
,	O
what	O
servers	O
should	O
receive	O
a	O
message	O
or	O
a	O
queue	B-Application
's	O
messages	O
?	O
</s>
<s>
When	O
one	O
queue	B-Application
has	O
it	O
?	O
</s>
<s>
Or	O
when	O
it	O
has	O
been	O
forwarded	O
to	O
at	O
least	O
one	O
remote	O
queue	B-Application
?	O
</s>
<s>
Or	O
to	O
all	O
queues	B-Application
?	O
</s>
<s>
Historically	O
,	O
message	B-Operating_System
queuing	I-Operating_System
has	O
used	O
proprietary	B-Application
,	O
closed	O
protocols	O
,	O
restricting	O
the	O
ability	O
for	O
different	O
operating	B-General_Concept
systems	I-General_Concept
or	O
programming	O
languages	O
to	O
interact	O
in	O
a	O
heterogeneous	O
set	O
of	O
environments	O
.	O
</s>
<s>
An	O
early	O
attempt	O
to	O
make	O
message	B-Operating_System
queuing	I-Operating_System
more	O
ubiquitous	O
was	O
Sun	O
Microsystems	O
 '	O
JMS	B-Language
specification	O
,	O
which	O
provided	O
a	O
Java-only	O
abstraction	O
of	O
a	O
client	O
API	B-Application
.	O
</s>
<s>
This	O
allowed	O
Java	B-Device
developers	O
to	O
switch	O
between	O
providers	O
of	O
message	B-Operating_System
queuing	I-Operating_System
in	O
a	O
fashion	O
similar	O
to	O
that	O
of	O
developers	O
using	O
SQL	B-Language
databases	I-Language
.	O
</s>
<s>
In	O
practice	O
,	O
given	O
the	O
diversity	O
of	O
message	B-Operating_System
queuing	I-Operating_System
techniques	O
and	O
scenarios	O
,	O
this	O
was	O
n't	O
always	O
as	O
practical	O
as	O
it	O
could	O
be	O
.	O
</s>
<s>
Three	O
standards	O
have	O
emerged	O
which	O
are	O
used	O
in	O
open	O
source	O
message	B-Operating_System
queue	I-Operating_System
implementations	O
:	O
</s>
<s>
The	O
first	O
two	O
operate	O
at	O
the	O
same	O
level	O
as	O
HTTP	B-Protocol
,	O
MQTT	B-Application
at	O
the	O
level	O
of	O
TCP/IP	B-Protocol
.	O
</s>
<s>
Some	O
proprietary	B-Application
implementations	O
also	O
use	O
HTTP	B-Protocol
to	O
provide	O
message	B-Operating_System
queuing	I-Operating_System
by	O
some	O
implementations	O
,	O
such	O
as	O
Amazon	B-Application
's	O
SQS	B-Operating_System
.	O
</s>
<s>
This	O
is	O
because	O
it	O
is	O
always	O
possible	O
to	O
layer	O
asynchronous	O
behaviour	O
(	O
which	O
is	O
what	O
is	O
required	O
for	O
message	B-Operating_System
queuing	I-Operating_System
)	O
over	O
a	O
synchronous	O
protocol	O
using	O
request-response	O
semantics	O
.	O
</s>
<s>
The	O
HTTP	B-Protocol
protocol	I-Protocol
–	O
used	O
in	O
the	O
World	O
Wide	O
Web	O
and	O
in	O
web	O
services	O
–	O
offers	O
an	O
obvious	O
example	O
where	O
a	O
user	O
sends	O
a	O
request	O
for	O
a	O
web	O
page	O
and	O
then	O
waits	O
for	O
a	O
reply	O
.	O
</s>
<s>
For	O
example	O
,	O
AJAX	B-Device
(	O
Asynchronous	O
JavaScript	B-Language
and	O
XML	B-Protocol
)	O
can	O
be	O
used	O
to	O
asynchronously	O
send	O
text	O
,	O
JSON	O
or	O
XML	B-Protocol
messages	O
to	O
update	O
part	O
of	O
a	O
web	O
page	O
with	O
more	O
relevant	O
information	O
.	O
</s>
<s>
Google	B-Application
uses	O
this	O
approach	O
for	O
their	O
Google	B-Application
Suggest	O
,	O
a	O
search	O
feature	O
which	O
sends	O
the	O
user	O
's	O
partially	O
typed	O
queries	O
to	O
Google	B-Application
's	I-Application
servers	O
and	O
returns	O
a	O
list	O
of	O
possible	O
full	O
queries	O
the	O
user	O
might	O
be	O
interested	O
in	O
the	O
process	O
of	O
typing	O
.	O
</s>
<s>
Other	O
asynchronous	O
examples	O
exist	O
in	O
event	O
notification	O
systems	O
and	O
publish/subscribe	B-Operating_System
systems	O
.	O
</s>
<s>
An	O
application	B-Application
may	O
need	O
to	O
notify	O
another	O
that	O
an	O
event	O
has	O
occurred	O
,	O
but	O
does	O
not	O
need	O
to	O
wait	O
for	O
a	O
response	O
.	O
</s>
<s>
In	O
publish/subscribe	B-Operating_System
systems	O
,	O
an	O
application	B-Application
"	O
publishes	O
"	O
information	O
for	O
any	O
number	O
of	O
clients	O
to	O
read	O
.	O
</s>
<s>
An	O
interactive	O
application	B-Application
may	O
need	O
to	O
respond	O
to	O
certain	O
parts	O
of	O
a	O
request	O
immediately	O
(	O
such	O
as	O
telling	O
a	O
customer	O
that	O
a	O
sales	O
request	O
has	O
been	O
accepted	O
,	O
and	O
handling	O
the	O
promise	O
to	O
draw	O
on	O
inventory	O
)	O
,	O
but	O
may	O
queue	B-Application
other	O
parts	O
(	O
such	O
as	O
completing	O
calculation	O
of	O
billing	O
,	O
forwarding	O
data	O
to	O
the	O
central	O
accounting	O
system	O
,	O
and	O
calling	O
on	O
all	O
sorts	O
of	O
other	O
services	O
)	O
to	O
be	O
done	O
some	O
time	O
later	O
.	O
</s>
<s>
In	O
all	O
these	O
sorts	O
of	O
situations	O
,	O
having	O
a	O
subsystem	O
which	O
performs	O
message-queuing	O
(	O
or	O
alternatively	O
,	O
a	O
broadcast	O
messaging	B-Operating_System
system	I-Operating_System
)	O
can	O
help	O
improve	O
the	O
behavior	O
of	O
the	O
overall	O
system	O
.	O
</s>
<s>
There	O
are	O
two	O
common	O
message	B-Operating_System
queue	I-Operating_System
implementations	O
in	O
UNIX	B-Application
.	O
</s>
<s>
One	O
is	O
part	O
of	O
the	O
SYS	O
V	O
API	B-Application
,	O
the	O
other	O
one	O
is	O
part	O
of	O
POSIX	O
.	O
</s>
<s>
UNIX	B-Application
SYS	O
V	O
implements	O
message	O
passing	O
by	O
keeping	O
an	O
array	O
of	O
linked	O
lists	O
as	O
message	B-Operating_System
queues	I-Operating_System
.	O
</s>
<s>
Each	O
message	B-Operating_System
queue	I-Operating_System
is	O
identified	O
by	O
its	O
index	O
in	O
the	O
array	O
,	O
and	O
has	O
a	O
unique	O
descriptor	O
.	O
</s>
<s>
UNIX	B-Application
gives	O
standard	O
functions	O
to	O
access	O
the	O
message	O
passing	O
feature	O
.	O
</s>
<s>
msgget( )	O
This	O
system	O
call	O
takes	O
a	O
key	O
as	O
an	O
argument	O
and	O
returns	O
a	O
descriptor	O
of	O
the	O
queue	B-Application
with	O
the	O
matching	O
key	O
if	O
it	O
exists	O
.	O
</s>
<s>
If	O
it	O
does	O
not	O
exist	O
,	O
and	O
the	O
IPC_CREAT	O
flag	O
is	O
set	O
,	O
it	O
makes	O
a	O
new	O
message	B-Operating_System
queue	I-Operating_System
with	O
the	O
given	O
key	O
and	O
returns	O
its	O
descriptor	O
.	O
</s>
<s>
msgrcv( )	O
Used	O
to	O
receive	O
a	O
message	O
from	O
a	O
given	O
queue	B-Application
descriptor	O
.	O
</s>
<s>
The	O
caller	O
process	O
must	O
have	O
read	O
permissions	O
for	O
the	O
queue	B-Application
.	O
</s>
<s>
It	O
sleeps	O
until	O
another	O
message	O
is	O
posted	O
in	O
the	O
queue	B-Application
,	O
and	O
then	O
wakes	O
up	O
to	O
check	O
again	O
.	O
</s>
<s>
msgctl( )	O
Used	O
to	O
change	O
message	B-Operating_System
queue	I-Operating_System
parameters	O
like	O
the	O
owner	O
.	O
</s>
<s>
Most	O
importantly	O
,	O
it	O
is	O
used	O
to	O
delete	O
the	O
message	B-Operating_System
queue	I-Operating_System
by	O
passing	O
the	O
IPC_RMID	O
flag	O
.	O
</s>
<s>
A	O
message	B-Operating_System
queue	I-Operating_System
can	O
be	O
deleted	O
only	O
by	O
its	O
creator	O
,	O
owner	O
,	O
or	O
the	O
superuser	O
.	O
</s>
<s>
The	O
POSIX.1-2001	O
message	B-Operating_System
queue	I-Operating_System
API	B-Application
is	O
the	O
later	O
of	O
the	O
two	O
UNIX	B-Application
message	B-Operating_System
queue	I-Operating_System
APIs	B-Application
.	O
</s>
<s>
It	O
is	O
distinct	O
from	O
the	O
SYS	O
V	O
API	B-Application
,	O
but	O
provides	O
similar	O
function	O
.	O
</s>
<s>
The	O
unix	B-Application
man	O
page	O
mq_overview(7 )	O
provides	O
an	O
overview	O
of	O
POSIX	O
message	B-Operating_System
queues	I-Operating_System
.	O
</s>
<s>
Graphical	B-Application
user	I-Application
interfaces	I-Application
(	O
GUIs	B-Application
)	O
employ	O
a	O
message	B-Operating_System
queue	I-Operating_System
,	O
also	O
called	O
an	O
event	B-Operating_System
queue	I-Operating_System
or	O
input	O
queue	B-Application
,	O
to	O
pass	O
graphical	O
input	O
actions	O
,	O
such	O
as	O
mouse	O
clicks	O
,	O
keyboard	O
events	O
,	O
or	O
other	O
user	O
inputs	O
,	O
to	O
the	O
application	B-Application
program	I-Application
.	O
</s>
<s>
The	O
windowing	O
system	O
places	O
messages	O
indicating	O
user	O
or	O
other	O
events	O
,	O
such	O
as	O
timer	O
ticks	O
or	O
messages	O
sent	O
by	O
other	O
threads	B-Operating_System
,	O
into	O
the	O
message	B-Operating_System
queue	I-Operating_System
.	O
</s>
<s>
The	O
GUI	B-Application
application	B-Application
removes	O
these	O
events	O
one	O
at	O
a	O
time	O
by	O
calling	O
a	O
routine	O
called	O
getNextEvent( )	O
or	O
similar	O
in	O
an	O
event	B-General_Concept
loop	I-General_Concept
,	O
and	O
then	O
calling	O
the	O
appropriate	O
application	B-Application
routine	O
to	O
process	O
that	O
event	O
.	O
</s>
