Search in sources :

Example 31 with ConnectionException

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);
}
Also used : SocketException(java.net.SocketException) IOException(java.io.IOException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 32 with ConnectionException

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);
    }
}
Also used : ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 33 with ConnectionException

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();
}
Also used : TransactionException(org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 34 with ConnectionException

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();
}
Also used : ServiceData(org.jboss.narayana.blacktie.jatmibroker.core.server.ServiceData) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 35 with ConnectionException

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);
}
Also used : Buffer(org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer) ResponseException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException) Session(org.jboss.narayana.blacktie.jatmibroker.xatmi.Session)

Aggregations

ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)41 Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)12 ConfigurationException (org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException)11 IOException (java.io.IOException)9 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)9 ResponseException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException)6 Message (org.jboss.narayana.blacktie.jatmibroker.core.transport.Message)5 Receiver (org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver)5 Buffer (org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer)5 CodecFactory (org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory)3 Codec (org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec)3 Transport (org.jboss.narayana.blacktie.jatmibroker.core.transport.Transport)3 TransactionException (org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionException)3 SocketException (java.net.SocketException)2 HashMap (java.util.HashMap)2 StringTokenizer (java.util.StringTokenizer)2 ServiceData (org.jboss.narayana.blacktie.jatmibroker.core.server.ServiceData)2 Sender (org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1