Microsoft Message Queuing or MSMQ is a message queue implementation developed by Microsoft and deployed in its Windows Server operating systems.

MSMQ is essentially a messaging protocol that allows applications running on separate servers/processes to communicate in a failsafe manner. A queue is a temporary storage location from which messages can be sent and received reliably, as and when conditions permit. This enables communication across networks and between computers, running Windows, which may not always be connected. By contrast, sockets and other network protocols assume that direct connections always exist.

Source: Wikipedia

If everything is working, messages are added to the queue by one application, and then typically read and removed from the queue by another application.

However, sometimes messages will get 'stuck' in the queue. While this is sometimes due to networking or application changes, the queue may back up if the receiving application is not running or running slower than normal.

Once the underlying problem has been fixed, depending on your application, the receiving application may never be able to catch up with the quantity of messages currently in the queue plus those still being added.

While you can purge the full queue:
Computer Management -> Services and Applications -> Message Queuing
Select your private queue, right click, All Tasks -> Purge

You may want to only purge the "old" messages.
Depending on your application, "old" could be seconds, minutes or hours.

The following PowerShell script will iterate over your private queues and remove "old" messages.
You can set the definition of "old" and you can preview the messages without removing.


# remove old messages for all local msmq queues

# msmq = microsoft messaging queuing


# 20190530 122800

#   add options $showMsg and $dryRun

# 20190521 122800

#   initial



# config


[System.Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null

$utf8 = new-object System.Text.UTF8Encoding

$now = Get-Date

# remove messages older than

# $old = $now.AddDays(-1)

$old = $now.AddMinutes(-10)

# show details of message to be removed

$showMsg = 1

# run without removing

$dryRun = 1


# run


# get queues

$queuePaths = Get-MsmqQueue -QueueType Private | Select -Property QueueName;

if ($dryRun)


    echo "dry run; would be "


echo "removing old messages for all local msmq queues"

echo ""

echo "nbr queues: $($queuePaths.Length); checking messages older than $($old)"

$queueCounts = Get-MsmqQueue -QueueType Private | Format-Table -Property QueueName,MessageCount;

echo $queueCounts

echo ""


foreach ($queuePath in $queuePaths)


    # for proper permissions, prepend .\

    $localQueuePath = ".\$($queuePath.QueueName)"

    echo "queue: $localQueuePath"

   $queue = New-Object System.Messaging.MessageQueue $localQueuePath


    # to read ArrivedTime property



    # get snapshot of all messages, but uses memory, and slower

   # $msgs = $queue.GetAllMessages()

    # echo "  $($msgs.Length) messages"

    # get cursor to messages in queue

    $msgs = $queue.GetMessageEnumerator2()


    # add a message so can test

    # $queue.Send("<test body>", "test label")

    # pause

    $removed = 0

   # foreach ($msg in $msgs)

    while ($msgs.MoveNext([timespan]::FromSeconds(1)))


       $msg = $msgs.Current

      if ($msg.ArrivedTime -and $msg.ArrivedTime -lt $old)      


           if ($showMsg)


               echo "--------------------------------------------------"

               echo "ArrivedTime: $($msg.ArrivedTime)"

               echo "BodyStream:"

               if ($msg.BodyStream)


                   echo $utf8.GetString($msg.BodyStream.ToArray())


               echo "Properties:"

               echo $msg | Select-Object

               echo ""



           try {

               if (!$dryRun)


                   # receive ie remove message by id from queue

                   $queue.ReceiveById($msg.Id, [timespan]::FromSeconds(1))



           } catch [System.Messaging.MessageQueueException] {

               $errorMessage = $_.Exception.Message

               # ignore timeouts              

               if (!$errorMessage.ToLower().Contains("timeout"))


                   throw $errorMessage





    if ($dryRun)


       echo "dry run; would have "


    echo "removed $removed messages from $localQueuePath"

    echo ""





View on GitHub

-End of Document-

Thanks for reading

HTTP 302 responses, aka redirects, are not available to Angular as xmlHttpRequest does not support returning redirects; the browser acts before you can do anything about it.

If the response is an HTTP redirect:

If the origin of the URL conveyed by the Location header is same origin with the XMLHttpRequest origin and the redirect does not violate infinite loop precautions, transparently follow the redirect while observing the same-origin request event rules.
refernce: stackoverflow

To act upon  a 302 response, 
You could check for specific data responses, or worse, override the status code 302 with a status code that is returned, such as 403, and act upon that.

X-Redirect header
However, a more generic solution is to add a custom redirect header, such as `X-Redirect` and act upon that. The value of `X-Redirect` should be the url you want to redirect to eg

An $http example:
$http.get(orig_url).then(function(response) {
        // do stuff
    }, function (response) {
        var headers = response.headers();
        if ('x-redirect' in headers)
            document.location.href = headers['x-redirect'];
        return response;

For a more global solution, you could also use a HTTP Interceptor:
app.factory('myHttpInterceptor', function ($q, myCache) {
    return {
        request: function (config) {
            return config;

        response: function(response){
            var headers = response.headers();
            if ('x-redirect' in headers)
                document.location.href = headers['x-redirect'];
            return response;
        responseError: function(rejection) {    
                case 302:
                    // this will not occur, use the custom header X-Redirect instead
                case 403:
                    alert.error(, 'Forbidden');
            return $q.reject(rejection);

You can set the custom header server side.
For example, if you are using PHP Symfony:

$response = new Response('', 204);
$response->headers->set('X-Redirect', $this->generateUrl('other_url'));
return $response;

-End of Document-
Thanks for reading
ZeroMQ is a high-performance asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker.
Wikipedia  ZeroMQ

Steps to install zeroMQ in PHP 5.3, PHP 7.1, and 7.2 on Windows

Most likely you want your PHP version, x64, and Thread Safe
but you may have a x32 version of PHP

$ php -i | grep Architecture  
Architecture => x64
  • for PHP 5.3

download 5.3 Thread Safe (TS) x86
extract and copy the dlls

copy libzmq.dll into

there is no libsodium.dll in PHP 5.3

copy php_zmq.dll into

add the extension to your php.ini,
usually with the other Dynamic Extensions


  • for PHP 7.1

download 7.1 Thread Safe (TS) x64
extract and copy the dlls

copy libzmq.dll and libsodium.dll into
there is an extra dll libsodium.dll for PHP 7.1

copy php_zmq.dll into

add the extension to your php.ini, usually with the other Dynamic Extensions


  • for PHP 7.2

download 7.2 Thread Safe (TS) x64
extract and copy the dlls

copy libzmq.dll into
there is no libsodium.dll after PHP 7.1

copy php_zmq.dll into

add the extension to your php.ini, usually with the other Dynamic Extensions


  • verify by viewing php info
$ php -i | grep zmq  
libzmq version => 4.1.3

-End of Document-
Thanks for reading

Do you have a large collection of physical or digital media you wish was smaller and more portable in size, while still keeping viewing quality?  Try Handbrake!

HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs.

Reasons you’ll love HandBrake:

  • Convert video from nearly any format
  • Free and Open Source
  • Multi-Platform (Windows, Mac and Linux)

Official Site:

Handbrake is a way to convert/re-encode the dvd/bluray files/structure from a physical disc or a file to another smaller file - at the cost of some time, and quality (usually not noticeable)

Note: Handbrake does not decrypt encrypted dvd/bluray discs

Some video encoding background:

What is video encoding?

Video encoding is the process of converting digital video files from one format to another. Encoding is also known as “transcoding” or “video conversion.” At the time of recording, the device gives the video file a particular format and other specifications. If the video owner wants to publish the video, s/he must consider the various devices on which the video might play. All of the videos we watch on our computers, tablets, and mobile phones have gone through an encoding process that converts the original source video so that it is viewable on various output formats. This is because many device and browser types only support specific video formats. Often, the goal of the video publisher is to ensure compatibility with a variety of common formats.


The basics of compression and quality is, pick 2 (maybe just 1)

  • Encodes fast
    • The faster the encode, usually the less quality and larger file size
  • High quality
    • The higher the quality, usually the longer the encode and the large the file size
  • Smallest file size possible
    • The smaller the file, usually the longer the encode and less quality (relatively)

File sizes:

dvds are about 3gb to 5gb

blurays are about 15gb to 40gb .. depending on the movie, audio, etc

Encoding can usually reduce the files sizes to less than half while maintaining a decent quality.

Note: There is no such thing as a smaller file but the same quality!  See above and pick one.

Suggested Handbrake Configuration:

After installing and launching, Handbrake is ready to encode your videos.

But first, let’s configure it for a perhaps more optimal experience, and learn a little more about the software

Click Preferences

General Preferences

  • You can leave Check for Updates enabled, if you wish
  • Check Always clear completed queue items after an encode completes
    • This is like auto removing your todo encodes
  • Check Show the encode status in the application title bar, if you wish
  • Check Reset to ‘Do nothing’ when the app is re-launched
    • You can set actions when your video is done encoding, such as shutdown
  • You can also enable sounds on completion

Output Files Preferences

  • Handbrake can auto name your encoded files to simplify some file management.
  • To have the output file be the same as the input, change the File Format to {source}
  • Also you can set your default destination, which will save you some clicking for each encode.

Video Preferences

  • Encoding
    • You can encode video files using your video card, if supported
      • Generally, video cards will encode files faster than cpus, but the quality will be slightly less and the file size will be slightly larger
    • You can also encode video files using your cpu
      • Generally, cpus will encode files in higher quality and smaller file sizes
      • If you have a 6 core or 8 core cpu, cpu encoding time could be  comparable to encoding using a video card
    • Recommendation is to uncheck all video card options thus encode files using your cpu, but of course, try both and see which you prefer.
  • Decoding
    • Decoding options enable hardware support for specific devices, such as a specific cpu or video card; If you play back a encoded video on a unsupported device, the quality and performance may be less.
    • Recommendation is to uncheck all decoding options

Advance Preferences

  • Raise the Priority Level of the Handbrake process to Above Normal.  Video encoding is an intensive process and you should not use your pc for other tasks at the same time; but of course you can, but encoding will take longer.


  • After loading a file or disc, you can the adjust the encoding options
  • While all these options can be saved to a preset, I will go through the important ones first
  • Format
    • Choose the file extension; mkv and mp4 are file containers for the video and audio streams
    • mp4 is supported by more devices (often older hardware players), but allows only one subtitle
    • mkv allows unlimited audio, subtitles, is easily editable - preferred extension


  • Width and Height will default to the width and height of your file.  You can reduce the width/height if you are trying to achieve a small file size.  Keeping the same width/height is preferred for video archive and for optimal quality.
  • Cropping - Handbrake can auto crop top/bottom and left/right black bars, so the video will appear to fill more of the screen on playback.  Note however, that some movies will play subtitles, or foreign languages, or other information in the black bars. So it is safer to just leave the video size as is.  Choose custom and enter 0 for all dimensions.


  • Filters allow you to maybe enhance the quality of a poor quality video, such as a video from vhs, or an old camcorder, or a bad internet stream.  But often, if your source is a dvd/bluray, you will want to turn off all filters and just take the video as is.

Video (lots of options here)

Video Codec

  • x264 has been around for a while and is optimized for video archival to produce a good balance of file size and quality.  Choose x264
  • x265 is relatively newer, and is optimized to stream video at a decent quality for a small bandwidth (file size).  At some point, x265 may also be good for video archival.
  • The other codecs are older or less popular, but may be required depending on the device you need to playback the videos.  Your playback device (pc, tv streamer, phone, etc) needs to support the video codec you are using. While you can try searching the internet for your devices supported codecs, it’s usually easier to just encode a video file and try.  x264 has wide support on new and old devices while x265 has wide support on ‘newer’ devices (last few years)

Quality (everyone wants it!)

  • Constant Quality - Handbrake will try to keep a relatively constant quality throughout the video.  Simple scenes with little movement or variation will have a lower bitrate, but still look good since little is happening, while fast moving scenes or lots of variation will have a higher bitrate, averaging out to a optimal file size for a given quality.
    • Choose a Quality Rate Factor (RF) of 20
    • For testing other settings, such as subtitles or audio, choosing a much higher RF such as 40 will result in a blocky video, but it will encode much faster.
  • Average Bitrate - uses a fixed bitrate, independent of the scene, resulting in a larger file size for a relative quality.  Some older devices may require a fixed bitrate.

Handbrake documentation

Recommended settings for x264 and x265 encoders:

  • RF 18-22 for 480p/576p Standard Definition1
  • RF 19-23 for 720p High Definition2
  • RF 20-24 for 1080p Full High Definition3
  • RF 22-28 for 2160p 4K Ultra High Definition4

Raising quality minus 1-2 RF may produce better results when encoding animated Sources (anime, cartoons). Lower quality settings may be used to produce smaller files. Drastically lower settings may show significant loss of detail.

Using higher than recommended quality settings can lead to extremely large files that may not be compatible with your devices. When in doubt, stick to the recommended range or use the default setting for the Preset you selected.

Framerate (FPS)

  • The framerate the encoded video will playback on.  Unless your playback device has a specific requirement, choose Same as source

Encoder Preset

  • Determines how much time Handbrake spends analyzing a scene to optimize quality and size.
  • Choose Slow, for a good compromise of time and quality
  • Choose Faster if just testing subtitles or audio tracks

Encoder Profile and Level

  • Choose the highest values for video archivals; Only choose lower values if your playback device requires it
  • Encoder Profile - Choose High
  • Encode Level - Choose 5.2 (or highest number)


  • You can add or remove multiple audio tracks that your source video file contains.
  • Choose Auto Passthru to keep the audio quality
    • You can choose other encodings to save space and the cost of quality

Audio Defaults

  • You can set defaults for all new video files (Click Selection Behavior)
  • Select the languages you want
  • Select the audio codes you want
    • AC3 is the most common and widely supported
    • HD often increases the file size and requires supporting hardware for playback

Subtitles (understand what they are saying!)

  • You can add or remove multiple subtitles that your source video file contains
    • Even if you do not like viewing subtitles yourself, they are still useful if you are trying to figure out what an actor is trying to say! Add all subtitles for you language.
  • Some video files or discs will have foreign subtitles as a special track which Handbrake can try to find

Subtitle Defaults

  • You can set defaults for all new video files  (Click Selection Behavior)
  • Select the languages you want
  • Subtitles can be turned on or off by most video players.
  • Burning in subtitles means the subtitle is part of the video and always plays.
  • If you use mkv, you do not have to burn in subtitles
  • If you use mp4, you can have only one subtitle

Add to Queue

  • Handbrake has a queue system, which allows you to configure multiple video encodes and then let them encode automatically one after another, such as overnight, or while you do other things.
  • Click Add to Queue when you are done configuring your encoding options

View Queue

  • When you are ready to process the queue, click Queue
  • You can mouse over a queued video to see a summary
  • You can choose an action to perform when the queue is finished, such as Suspend


  • Presets allow you to apply your encoding configuration for the current video to all new videos
  • Click Presets to show the preset bar
  • Click Add to create a preset, or Options Update Preset to update a selected preset
    • Enter a name
    • Dimensions - select Always use Source, unless you are targeting a specific size
    • Audio and Subtitles will use your defaults if you’ve set them up, else do so now

Note: In the past, Handbrake presets were a little flakey when it came to editing or viewing; it took some trial and error.  But with version 1.2.0 and on, presets seem to be more stable.

Note: While you can export presets, choose Options, presets from one version may not work with the next version, so it may be good to take a screenshot of the important options, or write them down.

Sally forth and encode!

Well, that’s a good overview of Handbrake’s configuration and you now have a good start on encoding your video files. But before encoding the world, it would be smart to encode one or two videos with different settings to get a feel of the end results. Then Sally forth and encode!

For more information, reference the official docs at

Other related software which may be useful:

  • videolan- play any movie (aka vlc)
  • kodi- nice graphical interface to play movies
  • tinymediamanager- download poster,fanart,movie.nfo for library; video library browser
  • emdb- video library browser
  • mkvtoolnix- edit mkv file headers ie turn off/on subtitles, change audio labels/order/default, etc
  • filebot- rename copied/archived files (good for tv series)
  • aren- advanced file renamer
  • mediainfo lite - video file info
  • avidemux- edit video/audio
  • movie/tv info/posters

-End of Document-
Thanks for reading