If a process starts swapping, it's either very poorly coded and not releasing RAM when it should or your server doesn't have enough RAM available to handle all the tasks it's currently performing and you should expand the RAM capacity.
If that's really not an option budget-wise or if the machine is already at maximum RAM capacity, you could schedule a task that kills and restarts the process every hour or so (or more frequent if needed). Note that this should really be a last-resort and temporary solution, as it's not really so much of a solution, but just a work-around.
As for the core of your question, there is no way that I know of to prevent a program from swapping. It's basic OS behaviour when a process runs out of physical memory to use to prevent your machine from crashing.