use of com.swiftmq.tools.util.DataStreamOutputStream in project swiftmq-ce by iitsoftware.
the class VersionedConnection method sendAndClose.
private void sendAndClose(final Connection connection, ProtocolHeader rcvHeader, ProtocolHeader header) throws IOException {
if (ctx.protSpace.enabled)
ctx.protSpace.trace("amqp", toString() + "/SND: " + header);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/wrong header received: " + rcvHeader + ", required: " + header + ", closing connection");
ctx.logSwiftlet.logError(ctx.amqpSwiftlet.getName(), toString() + "/wrong header received: " + rcvHeader + ", required: " + header + ", closing connection");
DataStreamOutputStream out = new DataStreamOutputStream(connection.getOutputStream());
header.writeContent(out);
out.flush();
ctx.timerSwiftlet.addInstantTimerListener(500, new TimerListener() {
public void performTimeAction() {
ctx.networkSwiftlet.getConnectionManager().removeConnection(connection);
}
});
}
use of com.swiftmq.tools.util.DataStreamOutputStream 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.util.DataStreamOutputStream 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.util.DataStreamOutputStream 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.util.DataStreamOutputStream in project swiftmq-ce by iitsoftware.
the class Exporter method store.
private void store(String queueName, XStream xStream, File outputDir, int nMsgs, MessageImpl message) throws Exception {
String fn = "swiftmq_" + queueName + "_" + FMT.format(nMsgs);
if (xStream != null) {
File outFile = new File(outputDir, fn + ".xml");
BufferedWriter bos = new BufferedWriter(new FileWriter(outFile));
message.unfoldBuffers();
xStream.toXML(message, bos);
bos.flush();
bos.close();
} else {
File outFile = new File(outputDir, fn + ".message");
DataStreamOutputStream dos = new DataStreamOutputStream(new FileOutputStream(outFile));
message.writeContent(dos);
dos.flush();
dos.close();
}
}
Aggregations