Search in sources :

Example 6 with SocketFactory

use of com.swiftmq.net.SocketFactory in project swiftmq-client by iitsoftware.

the class BlockingReconnector method createConnection.

protected Connection createConnection(ServerEntry entry, Map parameters) {
    Connection connection = null;
    try {
        boolean tcpNoDelay = ((Boolean) parameters.get(SwiftMQConnectionFactory.TCP_NO_DELAY)).booleanValue();
        int inputBufferSize = ((Integer) parameters.get(SwiftMQConnectionFactory.INPUT_BUFFER_SIZE)).intValue();
        int inputExtendSize = ((Integer) parameters.get(SwiftMQConnectionFactory.INPUT_EXTEND_SIZE)).intValue();
        int outputBufferSize = ((Integer) parameters.get(SwiftMQConnectionFactory.OUTPUT_BUFFER_SIZE)).intValue();
        int outputExtendSize = ((Integer) parameters.get(SwiftMQConnectionFactory.OUTPUT_EXTEND_SIZE)).intValue();
        SocketFactory socketFactory = (SocketFactory) parameters.get(SwiftMQConnectionFactory.SOCKETFACTORY);
        Socket socket = socketFactory.createSocket(entry.getHostname(), entry.getPort(), tcpNoDelay);
        connection = new BlockingConnection(socket, inputBufferSize, inputExtendSize, outputBufferSize, outputExtendSize);
    } catch (Exception e) {
        if (debug)
            System.out.println(toString() + " exception creating connection: " + e);
    }
    return connection;
}
Also used : SocketFactory(com.swiftmq.net.SocketFactory) Socket(java.net.Socket)

Example 7 with SocketFactory

use of com.swiftmq.net.SocketFactory in project swiftmq-ce by iitsoftware.

the class IOScheduler method getSocketFactory.

private SocketFactory getSocketFactory(String className) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$net", toString() + "/getSocketFactory: className=" + className);
    SocketFactory sf = (SocketFactory) socketFactories.get(className);
    if (sf == null) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$net", toString() + "/getSocketFactory: className=" + className + ", creating...");
        sf = (SocketFactory) Class.forName(className).newInstance();
        socketFactories.put(className, sf);
    }
    return sf;
}
Also used : SocketFactory(com.swiftmq.net.SocketFactory)

Example 8 with SocketFactory

use of com.swiftmq.net.SocketFactory in project swiftmq-client by iitsoftware.

the class ConnectionFactoryImpl method createServerConnection.

private com.swiftmq.net.client.Connection createServerConnection() throws JMSException {
    PoolManager.setIntraVM(intraVM);
    com.swiftmq.net.client.Connection conn = null;
    if (intraVM) {
        try {
            conn = new IntraVMConnection();
            NetworkSwiftlet networkSwiftlet = (NetworkSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$net");
            networkSwiftlet.connectIntraVMListener("sys$jms", (IntraVMConnection) conn);
        } catch (Exception e) {
            throw new JMSException("error creating intraVM connection, message: " + e.getMessage());
        }
    } else {
        try {
            if (socketFactory == null)
                socketFactory = (SocketFactory) Class.forName(socketFactoryClass).newInstance();
            Socket socket = socketFactory.createSocket(hostname, port, Boolean.valueOf(System.getProperty("swiftmq.tcp.no.delay", "true")).booleanValue());
            conn = new BlockingConnection(socket, inputBufferSize, inputExtendSize, outputBufferSize, outputExtendSize);
        } catch (Exception e) {
            throw new JMSException("error creating socket connection to " + hostname + ":" + port + ", message: " + e.getMessage());
        }
    }
    return conn;
}
Also used : IntraVMConnection(com.swiftmq.net.client.IntraVMConnection) SocketFactory(com.swiftmq.net.SocketFactory) NetworkSwiftlet(com.swiftmq.swiftlet.net.NetworkSwiftlet) BlockingConnection(com.swiftmq.net.client.BlockingConnection) IOException(java.io.IOException) NamingException(javax.naming.NamingException) Socket(java.net.Socket)

Aggregations

SocketFactory (com.swiftmq.net.SocketFactory)8 IOException (java.io.IOException)5 NamingException (javax.naming.NamingException)5 Socket (java.net.Socket)4 BlockingConnection (com.swiftmq.net.client.BlockingConnection)3 IntraVMConnection (com.swiftmq.net.client.IntraVMConnection)3 NetworkSwiftlet (com.swiftmq.swiftlet.net.NetworkSwiftlet)3 SocketFactory2 (com.swiftmq.net.SocketFactory2)2 BlockingReconnector (com.swiftmq.net.client.BlockingReconnector)2 IntraVMReconnector (com.swiftmq.net.client.IntraVMReconnector)2 Reconnector (com.swiftmq.net.client.Reconnector)2 ServerEntry (com.swiftmq.net.client.ServerEntry)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 AMQPContext (com.swiftmq.amqp.AMQPContext)1 Connection (com.swiftmq.amqp.v100.client.Connection)1