What's the best Java based API (JCMSP, JMS or new Java) to achieve blocking publish behaviour?

Thanks @rlawrence ,
That’s the answer I was looking for!
Just to add a bit more detail for future reference, I found the following code example in the Solace repositories, but it only publishes one message and doesn’t do any error handling:
solace-samples-jms/src/main/java/com/solace/samples/TopicPublisher.java at master · SolaceSamples/solace-samples-jms · GitHub
How would one enhance that to get the behaviour as described above?
My coding skills are a bit rusty, but from memory, the messageProducer.send() method does throw an Exception, if a message nack instead of an ack was received back from the broker, correct?
So you would have to wrap that in an exception handling block and loop to achieve the functionality described above, correct?