@Override public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame)command; if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { os.write(Stomp.BREAK); return; } StringBuilder builder = new StringBuilder(); os.write(marshalHeaders(stomp, builder).toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
@Override public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame)command; if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { os.write(Stomp.BREAK); return; } StringBuilder builder = new StringBuilder(); os.write(marshalHeaders(stomp, builder).toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
private StringBuilder marshalHeaders(StompFrame stomp, StringBuilder buffer) throws IOException { buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to separate the headers from the content. buffer.append(Stomp.NEWLINE); return buffer; }
@Override public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame)command; if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { os.write(Stomp.BREAK); return; } StringBuilder builder = new StringBuilder(); os.write(marshalHeaders(stomp, builder).toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
private StringBuilder marshalHeaders(StompFrame stomp, StringBuilder buffer) throws IOException { buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to separate the headers from the content. buffer.append(Stomp.NEWLINE); return buffer; }
private StringBuilder marshalHeaders(StompFrame stomp, StringBuilder buffer) throws IOException { buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to separate the headers from the content. buffer.append(Stomp.NEWLINE); return buffer; }
public String marshalToString(StompFrame stomp) throws IOException { if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { return String.valueOf((char)Stomp.BREAK); } StringBuilder buffer = new StringBuilder(); marshalHeaders(stomp, buffer); if (stomp.getContent() != null) { String contentString = new String(stomp.getContent(), "UTF-8"); buffer.append(contentString); } buffer.append('\u0000'); return buffer.toString(); }
public String marshalToString(StompFrame stomp) throws IOException { if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { return String.valueOf((char)Stomp.BREAK); } StringBuilder buffer = new StringBuilder(); marshalHeaders(stomp, buffer); if (stomp.getContent() != null) { String contentString = new String(stomp.getContent(), "UTF-8"); buffer.append(contentString); } buffer.append('\u0000'); return buffer.toString(); }
public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame)command; StringBuffer buffer = new StringBuffer(); buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Iterator iter = stomp.getHeaders().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry)iter.next(); buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(entry.getValue()); buffer.append(Stomp.NEWLINE); } // Add a newline to seperate the headers from the content. buffer.append(Stomp.NEWLINE); os.write(buffer.toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame) command; if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { os.write(Stomp.BREAK); return; } StringBuilder buffer = new StringBuilder(); buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to seperate the headers from the content. buffer.append(Stomp.NEWLINE); os.write(buffer.toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
public String marshalToString(StompFrame stomp) throws IOException { if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { return String.valueOf((char)Stomp.BREAK); } StringBuilder buffer = new StringBuilder(); marshalHeaders(stomp, buffer); if (stomp.getContent() != null) { String contentString = new String(stomp.getContent(), "UTF-8"); buffer.append(contentString); } buffer.append('\u0000'); return buffer.toString(); }
@Override public void handle(StompFrame event) { if (event.getAction().equals(Stomp.Commands.CONNECT) || event.getAction().equals(Stomp.Commands.STOMP)) { Map<String, String> headers = event.getHeaders(); ConnectionParameters parameters = new ConnectionParameters(); if (headers != null) { parameters.protocolVirtualHost = headers.get("host"); parameters.protocolUser = headers.get("JMSXUserID"); parameters.protocolClientId = headers.get("client-id"); } handler.handle(parameters); } else { LOG.info("Expected a CONNECT or STOMP frame"); socket.close(); } } });
public void marshal(Object command, DataOutput os) throws IOException { StompFrame stomp = (org.apache.activemq.transport.stomp.StompFrame) command; if (stomp.getAction().equals(Stomp.Commands.KEEPALIVE)) { os.write(Stomp.BREAK); return; } StringBuilder buffer = new StringBuilder(); buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to seperate the headers from the content. buffer.append(Stomp.NEWLINE); os.write(buffer.toString().getBytes("UTF-8")); os.write(stomp.getContent()); os.write(END_OF_FRAME); }
@Override public void handle(StompFrame event) { if (event.getAction().equals(Stomp.Commands.CONNECT) || event.getAction().equals(Stomp.Commands.STOMP)) { Map<String, String> headers = event.getHeaders(); ConnectionParameters parameters = new ConnectionParameters(); if (headers != null) { parameters.protocolVirtualHost = headers.get("host"); parameters.protocolUser = headers.get("JMSXUserID"); parameters.protocolClientId = headers.get("client-id"); } handler.handle(parameters); } else { LOG.info("Expected a CONNECT or STOMP frame"); socket.close(); } } });
public void connect(String username, String password, String client) throws Exception { HashMap<String, String> headers = new HashMap(); headers.put("login", username); headers.put("passcode", password); if (client != null) { headers.put("client-id", client); } StompFrame frame = new StompFrame("CONNECT", headers); sendFrame(frame.format()); StompFrame connect = receive(); if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) { throw new Exception ("Not connected: " + connect.getBody()); } }
public void connect(HashMap<String, String> headers) throws Exception { StompFrame frame = new StompFrame("CONNECT", headers); sendFrame(frame.format()); StompFrame connect = receive(); if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) { throw new Exception ("Not connected: " + connect.getBody()); } }
public void connect(HashMap<String, String> headers) throws Exception { StompFrame frame = new StompFrame("CONNECT", headers); sendFrame(frame.format()); StompFrame connect = receive(); if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) { throw new Exception ("Not connected: " + connect.getBody()); } }
public void connect(HashMap<String, String> headers) throws Exception { StompFrame frame = new StompFrame("CONNECT", headers); sendFrame(frame.format()); StompFrame connect = receive(); if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) { throw new Exception ("Not connected: " + connect.getBody()); } }
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", "tx1", null); connection.send("/queue/test", "message2", "tx1", null); 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();