Package org.apache.qpid.transport

Examples of org.apache.qpid.transport.Connection$DefaultSessionFactory


    }

    public static void main(String[] args) throws InterruptedException
    {
        // Create connection
        Connection con = new Connection();
        con.connect("localhost", 5672, "test", "guest", "guest",false);

        // Create session
        Session session = con.createSession(0);

        // Create an instance of the listener
        TopicListener listener = new TopicListener();
        session.setSessionListener(listener);

        listener.prepareQueue(session,"usa", "usa.#");
        listener.prepareQueue(session,"europe", "europe.#");
        listener.prepareQueue(session,"news", "#.news");
        listener.prepareQueue(session,"weather", "#.weather");

        // confirm completion
        session.sync();

        System.out.println("Waiting 100 seconds for messages");
        Thread.sleep(100*1000);

        System.out.println("Shutting down listeners");
        listener.cancelSubscription(session,"usa");
        listener.cancelSubscription(session,"europe");
        listener.cancelSubscription(session,"news");
        listener.cancelSubscription(session,"weather");

        //cleanup
        session.close();
        con.close();
    }
View Full Code Here


    {
        return new ConnectionBinding()
        {
            public Connection connection()
            {
                Connection conn = new Connection();
                conn.setConnectionDelegate(delegate);
                return conn;
            }
        };
    }
View Full Code Here

    public abstract Connection connection();

    public Connection endpoint(Sender<ByteBuffer> sender)
    {
        Connection conn = connection();

        // XXX: hardcoded max-frame
        Disassembler dis = new Disassembler(sender, MAX_FRAME_SIZE);
        conn.setSender(dis);
        return conn;
    }
View Full Code Here

        {
            e.printStackTrace();
        }

        NioSender sender = new NioSender(_ch);
        Connection con = new Connection();
        con.setSender(new Disassembler(sender, 64*1024 - 1));
        con.setConnectionDelegate(delegate);

        con.setConnectionId(_count.incrementAndGet());
        _handlers.put(con.getConnectionId(),sender);

        _receiver = new InputHandler(new Assembler(con), InputHandler.State.FRAME_HDR);

        Thread t = new Thread(this);
        t.start();
View Full Code Here

            String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:" +
            QpidBrokerTestCase.DEFAULT_SSL_PORT +
            "?ssl='true'&ssl_cert_alias='" + CERT_ALIAS_APP1 + "''";
           
            AMQTestConnection_0_10 con = new AMQTestConnection_0_10(url);     
            Connection transportCon = con.getConnection();
            String userID = transportCon.getSecurityLayer().getUserID();
            assertEquals("The correct certificate was not choosen","app1@acme.org",userID);
            con.close();
           
            url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:" +
            QpidBrokerTestCase.DEFAULT_SSL_PORT +
            "?ssl='true'&ssl_cert_alias='" + CERT_ALIAS_APP2 + "''";
           
            con = new AMQTestConnection_0_10(url);     
            transportCon = con.getConnection();
            userID = transportCon.getSecurityLayer().getUserID();
            assertEquals("The correct certificate was not choosen","app2@acme.org",userID);
            con.close();
        }       
    }
View Full Code Here

    //--- constructor
    public AMQConnectionDelegate_0_10(AMQConnection conn)
    {
        _conn = conn;
        _qpidConnection = new Connection();
        _qpidConnection.addConnectionListener(this);
    }
View Full Code Here

    {
        return new ConnectionBinding()
        {
            public Connection connection()
            {
                Connection conn = new Connection();
                conn.setConnectionDelegate(delegate);
                return conn;
            }
        };
    }
View Full Code Here

    public abstract Connection connection();

    public Connection endpoint(Sender<ByteBuffer> sender)
    {
        Connection conn = connection();

        if (conn.getConnectionSettings() != null &&
            conn.getConnectionSettings().isUseSASLEncryption())
        {
            sender = new SASLSender(sender);
            conn.addConnectionListener((ConnectionListener)sender);
        }
       
        // XXX: hardcoded max-frame
        Disassembler dis = new Disassembler(sender, Constant.MIN_MAX_FRAME_SIZE);
        conn.addFrameSizeObserver(dis);
        conn.setSender(dis);
        return conn;
    }
View Full Code Here

    }

    public static void main(String[] args) throws InterruptedException
    {
        // Create connection
        Connection con = new Connection();
        con.connect("localhost", 5672, "test", "guest", "guest",false);

        // Create session
        Session session = con.createSession(0);

        // Create an instance of the listener
        TopicListener listener = new TopicListener();
        session.setSessionListener(listener);

        listener.prepareQueue(session,"usa", "usa.#");
        listener.prepareQueue(session,"europe", "europe.#");
        listener.prepareQueue(session,"news", "#.news");
        listener.prepareQueue(session,"weather", "#.weather");

        // confirm completion
        session.sync();

        System.out.println("Waiting 100 seconds for messages");
        Thread.sleep(100*1000);

        System.out.println("Shutting down listeners");
        listener.cancelSubscription(session,"usa");
        listener.cancelSubscription(session,"europe");
        listener.cancelSubscription(session,"news");
        listener.cancelSubscription(session,"weather");

        //cleanup
        session.close();
        con.close();
    }
View Full Code Here

     * properties H1 and H2 and the other queue receives messages with either one of those properties.
     */
    public static void main(String[] args)
    {
        // Create connection
        Connection con = new Connection();
        con.connect("localhost", 5672, "test", "guest", "guest",false);

        // Create session
        Session session = con.createSession(0);

        // declare and bind queues
        session.queueDeclare("headers_queue_any", null, null);
        session.queueDeclare("headers_queue_all", null, null);
        // we need to declare the header: name, type, alternate exchange
        session.exchangeDeclare("test.headers", "headers", "amq.direct", null);
        // The matching algorithm is controlled by 'x-match' property
        // 'x-match' can take one of two values,
        // (i) 'all' implies that all the other pairs must match the headers
        // property of a message for that message to be routed (i.e. an AND match)
        // (ii) 'any' implies that the message should be routed if any of the
        // fields in the headers property match one of the fields in the arguments table (i.e. an OR match)
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("x-match", "any");
        arguments.put("h1", "v1");
        arguments.put("h2", "v2");
        session.exchangeBind("headers_queue_any", "test.headers", "useless", arguments);
        arguments = new HashMap<String, Object>();
        arguments.put("x-match", "all");
        arguments.put("h1", "v1");
        arguments.put("h2", "v2");
        session.exchangeBind("headers_queue_all", "test.headers", "useless", arguments);
        // confirm completion
        session.sync();
        //cleanup
        session.close();
        con.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.transport.Connection$DefaultSessionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.