Examples of StompFrame


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

        int port = broker.getConnectorByName(connectorName).getConnectUri().getPort();
        stompConnection.open(createSocket(host, port));
        String extra = extraHeaders != null ? extraHeaders : "\n";
        stompConnection.sendFrame("CONNECT\n" + extra + "\n" + Stomp.NULL);

        StompFrame f = stompConnection.receive();
        TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());
        stompConnection.close();
    }
View Full Code Here

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

   
    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

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

    }

    @Override
    public void onClose(int closeCode, String message) {
        try {
            protocolConverter.onStompCommand(new StompFrame(Stomp.Commands.DISCONNECT));
        } catch (Exception e) {
            LOG.warn("Failed to close WebSocket", e);
        }
    }
View Full Code Here

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

        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();
        assertTrue(frame.toString().startsWith("CONNECTED"));

        stompConnection.subscribe("/temp-queue/meaningless", "auto");
        stompConnection.send("/temp-queue/meaningless", "Hello World");

        frame = stompConnection.receive(3000);
        assertEquals("Hello World", frame.getBody());

        Thread.sleep(1000);

        assertEquals("Destination", 1, brokers.get("BrokerA").broker.getAdminView().getTemporaryQueues().length);
        assertEquals("Destination", 1, brokers.get("BrokerB").broker.getAdminView().getTemporaryQueues().length);
View Full Code Here

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

   
    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

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

   
    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

Examples of org.codehaus.stomp.StompFrame

            final String receiptId = (String) command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED);
            if (receiptId != null) {
                headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
            }

            StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray());
            sendToStomp(errorMessage);

            // TODO need to do anything else? Should we close the connection?
        }
    }
View Full Code Here

Examples of org.codehaus.stomp.StompFrame

            // TODO legacy
            responseHeaders.put(Stomp.Headers.Connected.RESPONSE_ID, requestId);
            responseHeaders.put(Stomp.Headers.Response.RECEIPT_ID, requestId);
        }

        StompFrame sc = new StompFrame();
        sc.setAction(Stomp.Responses.CONNECTED);
        sc.setHeaders(responseHeaders);
        sendToStomp(sc);
    }
View Full Code Here

Examples of org.codehaus.stomp.StompFrame

    }

    log.trace("Consumed message: " + msg);
        consumer.close();

    StompFrame sf;

    if (msg == null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8"));
      stream.print("No messages available");
            stream.close();

            HashMap eheaders = new HashMap();
            eheaders.put(Stomp.Headers.Error.MESSAGE, "timeout");

            sf = new StompFrame(Stomp.Responses.ERROR, eheaders, baos.toByteArray());
    } else {
      // Don't use sendResponse since it uses Stomp.Responses.RECEIPT as the action
      // which only allows zero length message bodies, Stomp.Responses.MESSAGE is correct:
      sf = session.convertMessage(msg);
    }

    if (headers.containsKey(Stomp.Headers.RECEIPT_REQUESTED))
      sf.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, headers.get(Stomp.Headers.RECEIPT_REQUESTED));

    sendToStomp(sf);
  }
View Full Code Here

Examples of org.codehaus.stomp.StompFrame

    protected void sendResponse(StompFrame command) throws Exception {
        final String receiptId = (String) command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED);
        // A response may not be needed.
        if (receiptId != null) {
            StompFrame sc = new StompFrame();
            sc.setAction(Stomp.Responses.RECEIPT);
            sc.setHeaders(new HashMap(1));
            sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
            sendToStomp(sc);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.