use of com.swiftmq.amqp.v100.client.po.POSendClose in project swiftmq-ce by iitsoftware.
the class AMQPHandler method visit.
public void visit(POSendClose po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
CloseFrame frame = new CloseFrame(0);
if (po.getErrorCondition() != null) {
com.swiftmq.amqp.v100.generated.transport.definitions.Error error = new Error();
error.setCondition(po.getErrorCondition());
if (po.getDescription() != null)
error.setDescription(po.getDescription());
frame.setError(error);
connectionDisabled = true;
}
frame.setCallback(new AsyncCompletionCallback() {
public void done(boolean b) {
ctx.networkSwiftlet.getConnectionManager().removeConnection(versionedConnection.getConnection());
}
});
versionedConnection.send(frame);
closeFrameSent = true;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
use of com.swiftmq.amqp.v100.client.po.POSendClose in project swiftmq-client by iitsoftware.
the class Connection method close.
protected void close(String condition, String description) {
if (closed)
return;
if (condition == null) {
Semaphore sem = new Semaphore();
POSendClose po = new POSendClose(sem, condition == null ? null : new AMQPSymbol(condition), description == null ? null : new AMQPString(description));
connectionDispatcher.dispatch(po);
sem.waitHere();
} else {
POSendClose po = new POSendClose(null, condition == null ? null : new AMQPSymbol(condition), description == null ? null : new AMQPString(description));
connectionDispatcher.dispatch(po);
}
cancel();
if (exceptionListener != null && condition != null && description != null)
exceptionListener.onException(new ConnectionClosedException(condition + " / " + description));
}
use of com.swiftmq.amqp.v100.client.po.POSendClose in project swiftmq-client by iitsoftware.
the class ConnectionDispatcher method visit.
public void visit(POSendClose po) {
if (pTracer.isEnabled())
pTracer.trace(toString(), ", visit, po=" + po + " ...");
if (po.getSemaphore() != null)
closePO = po;
try {
CloseFrame closeFrame = new CloseFrame(0);
if (po.getCondition() != null) {
com.swiftmq.amqp.v100.generated.transport.definitions.Error error = new com.swiftmq.amqp.v100.generated.transport.definitions.Error();
error.setCondition(ErrorConditionFactory.create(po.getCondition()));
if (po.getDescription() != null)
error.setDescription(po.getDescription());
closeFrame.setError(error);
}
Semaphore sem = new Semaphore();
closeFrame.setSemaphore(sem);
outboundHandler.send(closeFrame);
sem.waitHere();
} catch (Exception e) {
if (po.getSemaphore() != null) {
po.setException(e.toString());
po.setSuccess(false);
po.getSemaphore().notifySingleWaiter();
}
}
if (pTracer.isEnabled())
pTracer.trace(toString(), ", visit, po=" + po + " done");
}
Aggregations