@Override public MessageAck onStompMessageNack(String messageId, TransactionId transactionId) throws ProtocolException { throw new ProtocolException("Cannot Nack a message on a Queue Browser Subscription."); }
@Override public MessageAck onStompMessageNack(String messageId, TransactionId transactionId) throws ProtocolException { throw new ProtocolException("Cannot Nack a message on a Queue Browser Subscription."); }
@Override public MessageAck onStompMessageNack(String messageId, TransactionId transactionId) throws ProtocolException { throw new ProtocolException("Cannot Nack a message on a Queue Browser Subscription."); }
protected void checkConnected() throws ProtocolException { if (!connected.get()) { throw new ProtocolException("Not connected."); } }
protected void checkConnected() throws ProtocolException { if (!connected.get()) { throw new ProtocolException("Not connected."); } }
protected void checkConnected() throws ProtocolException { if (!connected.get()) { throw new ProtocolException("Not connected."); } }
protected int parseContentLength(String contentLength) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > MAX_DATA_LENGTH) { throw new ProtocolException("The maximum data length was exceeded", true); } return length; }
protected int parseContentLength(String contentLength) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > MAX_DATA_LENGTH) { throw new ProtocolException("The maximum data length was exceeded", true); } return length; }
protected void checkConnected() throws ProtocolException { if (!connected.get()) { throw new ProtocolException("Not connected."); } }
protected int parseContentLength(String contentLength) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > MAX_DATA_LENGTH) { throw new ProtocolException("The maximum data length was exceeded", true); } return length; }
protected int parseContentLength(String contentLength, AtomicLong frameSize) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } if (frameSize.addAndGet(length) > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true); } return length; }
protected int parseContentLength(String contentLength, AtomicLong frameSize) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } if (frameSize.addAndGet(length) > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true); } return length; }
protected int parseContentLength(String contentLength, AtomicLong frameSize) throws ProtocolException { int length; try { length = Integer.parseInt(contentLength.trim()); } catch (NumberFormatException e) { throw new ProtocolException("Specified content-length is not a valid integer", true); } if (length > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } if (frameSize.addAndGet(length) > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true); } return length; }
public static String detectVersion(Map<String, String> headers) throws ProtocolException { String accepts = headers.get(Stomp.Headers.Connect.ACCEPT_VERSION); if (accepts == null) { accepts = Stomp.DEFAULT_VERSION; } HashSet<String> acceptsVersions = new HashSet<String>(Arrays.asList(accepts.trim().split(Stomp.COMMA))); acceptsVersions.retainAll(Arrays.asList(Stomp.SUPPORTED_PROTOCOL_VERSIONS)); if (acceptsVersions.isEmpty()) { throw new ProtocolException("Invalid Protocol version[" + accepts +"], supported versions are: " + Arrays.toString(Stomp.SUPPORTED_PROTOCOL_VERSIONS), true); } else { return Collections.max(acceptsVersions); } } }
public static String detectVersion(Map<String, String> headers) throws ProtocolException { String accepts = headers.get(Stomp.Headers.Connect.ACCEPT_VERSION); if (accepts == null) { accepts = Stomp.DEFAULT_VERSION; } HashSet<String> acceptsVersions = new HashSet<String>(Arrays.asList(accepts.trim().split(Stomp.COMMA))); acceptsVersions.retainAll(Arrays.asList(Stomp.SUPPORTED_PROTOCOL_VERSIONS)); if (acceptsVersions.isEmpty()) { throw new ProtocolException("Invalid Protocol version[" + accepts +"], supported versions are: " + Arrays.toString(Stomp.SUPPORTED_PROTOCOL_VERSIONS), true); } else { return Collections.max(acceptsVersions); } } }
public static String detectVersion(Map<String, String> headers) throws ProtocolException { String accepts = headers.get(Stomp.Headers.Connect.ACCEPT_VERSION); if (accepts == null) { accepts = Stomp.DEFAULT_VERSION; } HashSet<String> acceptsVersions = new HashSet<String>(Arrays.asList(accepts.trim().split(Stomp.COMMA))); acceptsVersions.retainAll(Arrays.asList(Stomp.SUPPORTED_PROTOCOL_VERSIONS)); if (acceptsVersions.isEmpty()) { throw new ProtocolException("Invalid Protocol version[" + accepts +"], supported versions are: " + Arrays.toString(Stomp.SUPPORTED_PROTOCOL_VERSIONS), true); } else { return Collections.max(acceptsVersions); } } }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was already started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
protected void onStompBegin(StompFrame command) throws ProtocolException { checkConnected(); Map<String, String> headers = command.getHeaders(); String stompTx = headers.get(Stomp.Headers.TRANSACTION); if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { throw new ProtocolException("Must specify the transaction you are beginning"); } if (transactions.get(stompTx) != null) { throw new ProtocolException("The transaction was already started: " + stompTx); } LocalTransactionId activemqTx = new LocalTransactionId(connectionId, transactionIdGenerator.getNextSequenceId()); transactions.put(stompTx, activemqTx); TransactionInfo tx = new TransactionInfo(); tx.setConnectionId(connectionId); tx.setTransactionId(activemqTx); tx.setType(TransactionInfo.BEGIN); sendToActiveMQ(tx, createResponseHandler(command)); }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength-1] == '\r') { line.setLength(lineLength-1); } } return line; }
private String readLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence sequence = baos.toByteSequence(); return new String(sequence.getData(), sequence.getOffset(), sequence.getLength(), "UTF-8"); }