Package org.apache.activemq.transport.stomp

Examples of org.apache.activemq.transport.stomp.StompConnection


        startAllBrokers();
        waitForBridgeFormation();

        Thread.sleep(1000);

        stompConnection = new StompConnection();
        stompConnection.open("localhost", 61614);
        // Creating a temp queue
        stompConnection.sendFrame("CONNECT\n" + "login:system\n" + "passcode:manager\n\n" + Stomp.NULL);

        StompFrame frame = stompConnection.receive();
View Full Code Here


        SocketFactory factory = SSLSocketFactory.getDefault();
        return factory.createSocket(host, port);
    }
   
    public void stompConnectTo(String host, int port) throws Exception {
      StompConnection stompConnection = new StompConnection();
      stompConnection.open(createSocket(host, port));
        stompConnection.sendFrame("CONNECT\n" + "\n" + Stomp.NULL);
        StompFrame f = stompConnection.receive();
        TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());
        stompConnection.close();
    }
View Full Code Here

*
*/
public class StompExample {

  public static void main(String args[]) throws Exception {
    StompConnection connection = new StompConnection();
    connection.open("localhost", 61616);
   
    connection.connect("system", "manager");
   
    connection.begin("tx1");
    connection.send("/queue/test", "message1");
    connection.send("/queue/test", "message2");
    connection.commit("tx1");
   
    connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
   
    connection.begin("tx2");
   
    StompFrame message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    connection.commit("tx2");
   
    connection.disconnect();
  }
View Full Code Here

*
*/
public class StompExample {

  public static void main(String args[]) throws Exception {
    StompConnection connection = new StompConnection();
    connection.open("localhost", 61613);
   
    connection.connect("system", "manager");
    StompFrame connect = connection.receive();
    if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) {
      throw new Exception ("Not connected");
    }
   
    connection.begin("tx1");
    connection.send("/queue/test", "message1");
    connection.send("/queue/test", "message2");
    connection.commit("tx1");
   
    connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
   
    connection.begin("tx2");
   
    StompFrame message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    connection.commit("tx2");
   
    connection.disconnect();
  }
View Full Code Here

            for (TransportConnector transport : broker.getTransportConnectors()) {
                final URI UriToConnectTo = transport.getConnectUri();
                
                if (UriToConnectTo.getScheme().startsWith("stomp")) {
                    LOG.info("validating alive with connection to: " + UriToConnectTo);
                    StompConnection connection = new StompConnection();
                    connection.open(UriToConnectTo.getHost(), UriToConnectTo.getPort());
                    connection.close();
                    break;
                } else if (UriToConnectTo.getScheme().startsWith("tcp")) {
                    LOG.info("validating alive with connection to: " + UriToConnectTo);
                    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(UriToConnectTo);
                    Connection connection = connectionFactory.createConnection(secProps.getProperty("activemq.username"),
                            secProps.getProperty("activemq.password"));
                    connection.start();
                    connection.close();
                    break;
                } else {
                    LOG.info("not validating connection to: " + UriToConnectTo);
                }
            }
View Full Code Here

*
*/
public class StompExample {

  public static void main(String args[]) throws Exception {
    StompConnection connection = new StompConnection();
    connection.open("localhost", 61613);
   
    connection.connect("system", "manager");
   
    connection.begin("tx1");
    connection.send("/queue/test", "message1");
    connection.send("/queue/test", "message2");
    connection.commit("tx1");
   
    connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
   
    connection.begin("tx2");
   
    StompFrame message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    message = connection.receive();
    System.out.println(message.getBody());
    connection.ack(message, "tx2");
   
    connection.commit("tx2");
   
    connection.disconnect();
  }
View Full Code Here

            for (TransportConnector transport : broker.getTransportConnectors()) {
                final URI UriToConnectTo = URISupport.removeQuery(transport.getConnectUri());
                
                if (UriToConnectTo.getScheme().startsWith("stomp")) {
                    LOG.info("validating alive with connection to: " + UriToConnectTo);
                    StompConnection connection = new StompConnection();
                    connection.open(UriToConnectTo.getHost(), UriToConnectTo.getPort());
                    connection.close();
                    break;
                } else if (UriToConnectTo.getScheme().startsWith("tcp")) {
                    LOG.info("validating alive with connection to: " + UriToConnectTo);
                    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(UriToConnectTo);
                    Connection connection = connectionFactory.createConnection(secProps.getProperty("activemq.username"),
                            secProps.getProperty("activemq.password"));
                    connection.start();
                    connection.close();
                    break;
                } else {
                    LOG.info("not validating connection to: " + UriToConnectTo);
                }
            }
View Full Code Here

    disconnect();
  }

  private void connect() throws Exception {
    _log.info("opening stomp connection");
    _connection = new StompConnection();
    _connection.open(_host, _port);
    _connection.connect(_username, _password);

    _connection.subscribe(TOPIC_TRAIN_MVT, Subscribe.AckModeValues.CLIENT);
    _connection.subscribe(TOPIC_TD, Subscribe.AckModeValues.CLIENT);
View Full Code Here

        connection.close();
    }

    @Test
    public void testConnectStomp_shouldConnect() throws Exception {
        StompConnection connection = new StompConnection();
        connection.open("localhost", STOMP_PORT);
        connection.close();
    }
View Full Code Here

        poll.setURL("http://localhost:8080/amq?timeout=5000");
        poll.setRequestHeader( "Cookie", jsessionid );
        httpClient.send( poll );

        // stomp client queues some messages
        StompConnection connection = new StompConnection();
        connection.open(stompUri.getHost(), stompUri.getPort());
        connection.connect("user", "password");
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put( "amq-msg-type", "text" );
        connection.send( "/queue/test", "message1", (String)null, headers );
        connection.send( "/queue/test", "message2", (String)null, headers );
        connection.send( "/queue/test", "message3", (String)null, headers );
        connection.send( "/queue/test", "message4", (String)null, headers );
        connection.send( "/queue/test", "message5", (String)null, headers );
        String frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
        connection.sendFrame(frame);

        // Need to let the transport have enough time to dispatch the incoming messages from
        // the socket before we break the connection.
        TimeUnit.SECONDS.sleep(5);

        connection.disconnect();

        // wait for poll to finish
        poll.waitForDone();
        String response = poll.getResponseContent();
View Full Code Here

TOP

Related Classes of org.apache.activemq.transport.stomp.StompConnection

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.