I've witnessed 2 methods for taking eggs that keep the fish alive.

1) An air-injected needle is inserted into the belly. With minimal air pressure the eggs squirt out and are collected

2) A hatchery technician simply strokes the belly of a ripe fish, thus producing eggs.

In both instances, the fish often swims away if care is taken.