JCSMP Blocking Publisher Example: Timeout configurable

ChristianHoltfurth
ChristianHoltfurth Member, Employee Posts: 73 Solace Employee

Hi Community,

I have a question on the JCSMP BlockingSynchronousSendGuaranteed.java sample:

What happens, if the broker doesn't respond with either an ACK or a NACK?

Is this even possible or under which conditions could that occur?

(I read something about disk full could be one potential situation.)


Is there a timeout for how long the call will block?

In the comments I can see that PUB_ACK_TIME is set to 2000ms after which the API would retransmit a message. But does it ever timeout and return control to the application, if the broker isn't responding with an ACK or a NACK?

// asynchronous send method and associated event callbacks. Calls to blockingSend() can

// block indefinitely waiting for receipt of an ACK or NACK for the message sent.

// If the API fails to receive either an ACK or NACK from the broker within the

// the JCSMPProperties.PUB_ACK_TIME timeout (default 2000ms) the API retransmits the

// message. The API will retransmit the message every JCSMPProperties.PUB_ACK_TIME milliseconds

// until an ACK or NACK is received. Typically the broker only fails to respond with an ACK

// or NACK if it is out of disk space to persist the received message.

//

// This method uses a CyclicBarrier to synchronize between sending the message and receiving

// either an ACK, in the ResponseReceivedEx callback, or a NACK, in the

// handleErrorEx callback.

public synchronized void blockingSend(XMLMessage message, Topic topic) throws Exception {

publishException = null;

CyclicBarrier barrier = new CyclicBarrier(2);

message.setCorrelationKey(barrier);

producer.send(message, topic);




try {

barrier.await();

} catch (InterruptedException e) {

throw(e);

} catch (BrokenBarrierException e) {

throw(e);

}




if (publishException != null) {

throw publishException;

}

}
// This is the blocking, synchronous send method implemented using the JCSMP API's non-blocking,

This sounds like a potential rare edge case, but I'm curious what would happen in this situation.