use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-client by iitsoftware.
the class SessionImpl method close.
public void close() throws JMSException {
if (closed)
return;
if (messageListener == null && !isSessionStarted()) {
_close();
return;
}
CloseSession request = new CloseSession();
request._sem = new Semaphore();
if (messageListener == null)
serviceRequest(request);
else {
addMessageChunk(request);
}
request._sem.waitHere(5000);
if (!request._sem.isNotified())
_close();
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-client by iitsoftware.
the class MessageConsumerImpl method close.
public void close() throws JMSException {
if (closed)
return;
if (!mySession.isSessionStarted()) {
close(null);
return;
}
CloseConsumer request = new CloseConsumer(consumerId);
request._sem = new Semaphore();
mySession.serviceRequest(request);
request._sem.waitHere();
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-client by iitsoftware.
the class ConnectionImpl method reconnectAndWait.
private void reconnectAndWait() {
if (reconnector.isDebug())
System.out.println(toString() + ": initiate reconnect and wait ...");
lastConnectionLost = System.currentTimeMillis();
Semaphore sem = new Semaphore();
POReconnect po = new POReconnect(sem, this);
connector.dispatch(po);
sem.waitHere();
if (reconnector.isDebug())
System.out.println(toString() + ": reconnect done, connection =" + connection);
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-client by iitsoftware.
the class ConnectionImpl method handOver.
public void handOver(com.swiftmq.net.client.Connection connection) {
this.connection = connection;
if (connection != null) {
connectionId++;
myHostname = connection.getLocalHostname();
connection.setInboundHandler(this);
connection.setExceptionHandler(this);
outStream = new DataStreamOutputStream(connection.getOutputStream());
if (connectionQueue != null) {
connectionQueue.clear();
connectionQueue.startQueue();
}
// Blocks new XA Requests
setSessionBlockState(true);
if (requestRegistry != null) {
requestRegistry.setPaused(false);
Semaphore retrySem = new Semaphore();
requestRegistry.retryAllRequests(retrySem);
retrySem.waitHere();
}
resetSessions(false);
notifyReconnectListener();
setSessionBlockState(false);
}
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-client by iitsoftware.
the class MessageConsumerImpl method close.
public void close() throws JMSException {
if (closed)
return;
if (!mySession.isSessionStarted()) {
close(null);
return;
}
CloseConsumer request = new CloseConsumer(consumerId);
request._sem = new Semaphore();
mySession.serviceRequest(request);
request._sem.waitHere();
}
Aggregations