use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class SocketSenderImpl method close.
public void close() throws ConnectionException {
log.debug("Close called");
if (closed) {
throw new ConnectionException(Connection.TPEPROTO, "Sender already closed");
}
closed = true;
try {
outs.close();
socket.shutdownOutput();
} catch (SocketException e) {
} catch (IOException e) {
throw new ConnectionException(Connection.TPEPROTO, "close socket failed with " + e);
}
log.debug("Sender closed: " + addr);
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class StompReceiverImpl method close.
public void close() throws ConnectionException {
log.debug("close");
if (closed) {
throw new ConnectionException(Connection.TPEPROTO, "Sender already closed");
}
try {
log.debug("closing socket: " + socket);
StompManagement.close(socket, outputStream, inputStream);
inputStream.close();
log.debug("closed input stream: " + inputStream);
socket.close();
log.debug("closed socket: " + socket);
closed = true;
} catch (Throwable t) {
log.debug("consumer could not be closed");
throw new ConnectionException(Connection.TPESYSTEM, "Could not delete the queue", t);
}
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class SessionImpl method tpdiscon.
/**
* Close the conversation with the remote service. This will close the
* session.
*/
public void tpdiscon() throws ConnectionException {
log.debug("tpdiscon: " + cd);
if (closed) {
throw new ConnectionException(ConnectionImpl.TPEPROTO, "Session already closed");
}
if (sender == null) {
throw new ConnectionException(ConnectionImpl.TPEPROTO, "Session had no endpoint to respond to for tpdiscon");
}
if (TransactionImpl.current() != null) {
try {
TransactionImpl.current().rollback_only();
} catch (TransactionException e) {
throw new ConnectionException(ConnectionImpl.TPESYSTEM, "Could not mark transaction for rollback only");
}
}
try {
sender.send("", EventListener.DISCON_CODE, 0, null, 0, cd, 0, 0, null, null);
} catch (org.omg.CORBA.OBJECT_NOT_EXIST one) {
log.warn("The disconnect called failed to notify the remote end");
log.debug("The disconnect called failed to notify the remote end", one);
}
close();
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class BlackTieServer method tpunadvertise.
/**
* Unadvertise the service by name.
*
* @param serviceName The name of the service to unadverise.
* @throws ConnectionException If the service cannot be unadvertised.
*/
public void tpunadvertise(String serviceName) throws ConnectionException {
serviceName = serviceName.substring(0, Math.min(Connection.XATMI_SERVICE_NAME_LENGTH, serviceName.length()));
ServiceData data = serviceData.remove(serviceName);
if (data == null) {
throw new ConnectionException(Connection.TPENOENT, "Service did not exist: " + serviceName);
}
data.close();
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class TestRollbackOnly method test_tprecv_TPEV_SVCFAIL.
public void test_tprecv_TPEV_SVCFAIL() throws ConnectionException, ConfigurationException {
log.info("test_tprecv_TPEV_SVCFAIL");
server.tpadvertiseTestRollbackOnlyTprecvTPEVSVCFAILService();
assertTrue(TX.tx_open() == TX.TX_OK);
assertTrue(TX.tx_begin() == TX.TX_OK);
Session cd = connection.tpconnect(RunServer.getServiceNameTestRollbackOnly2(), sendbuf, Connection.TPRECVONLY);
try {
cd.tprecv(0);
fail("Expected e.getEvent() == Connection.TPEV_SVCFAIL");
} catch (ResponseException e) {
assertTrue(e.getEvent() == Connection.TPEV_SVCFAIL);
assertTrue(e.getTperrno() == Connection.TPEEVENT);
Buffer rcvbuf = e.getReceived();
assertTrue(TestTPConversation.strcmp(rcvbuf, "test_tprecv_TPEV_SVCFAIL_service") == 0);
} catch (ConnectionException e) {
fail("Expected e.getEvent() == Connection.TPEV_SVCFAIL");
}
TXINFO txinfo = new TXINFO();
int inTx = TX.tx_info(txinfo);
log.info("inTx=" + inTx);
assertTrue(txinfo.transaction_state == TX.TX_ROLLBACK_ONLY);
assertTrue(TX.tx_commit() == TX.TX_ROLLBACK);
}
Aggregations