The best point to start would be to look at the juce demo application.
There you have everything ready to open devices and receive Midi events (if my brain serves me well).
Filtering them is very easy in juce (sorry, all Midi handling is very easy in juce). Just read the incoming
Midi messages and select them by type and pass them on to the particular output devices, done.