One high quality security device is the dog (or other creature) on a pressure plate.
You put the animal in a 1x1 pasture on a pressure plate, behind a window and/or fortification looking into the death chamber. When the enemy comes in, the animal sees them and freaks out, stepping off the pressure plate, returning whatever is linked to the pressure plate to it's default state.
So retracting bridges close, sealing the entrance and exit to the chamber and all the drains. A raising bridge lowers, letting magma into the chamber.
Or a raising bridges lower, smashing everything flat.
Or a raising bridge lowers, allowing water to enter the repeater which causes the spikes in the chamber to go up and down, up and down...
Now, the dwarves will try and catch the animal and put it back on the pressure plate. But this will only succeed once all the enemies in the death chamber are dead. This is good, because it means the system automatically resets itself once it's ready for another load of victims.
The animal powered death chamber can be very reliable, because an animal isn't thwarted by stealthy, flying or trap-avoid enemies. The exact effectiveness of the death chamber depends on what the pressure plate causes to happen. Which could be multiple things, for example it could both flood the chamber AND activate a repeater which drives the spikes, for a self-rinsing impaling chamber.