if(prefixCounter) { long id = sent + 1; ByteArrayOutputStream os = new ByteArrayOutputStream(message.length + 15); os.write(new AsciiBuffer(Long.toString(id))); os.write(':');
private void initializeWriting() throws OpenwireException { checkReadOnlyBody(); if (this.dataOut == null) { this.bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } this.dataOut = new DataOutputStream(os); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { // Need to marshal the properties. if (marshalledProperties == null && properties != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(baos); MarshallingSupport.marshalPrimitiveMap(properties, os); os.close(); marshalledProperties = baos.toBuffer(); } }
private void initializeWriting() throws OpenwireException { checkReadOnlyBody(); if (this.dataOut == null) { this.bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } this.dataOut = new DataOutputStream(os); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { // Need to marshal the properties. if (marshalledProperties == null && properties != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(baos); MarshallingSupport.marshalPrimitiveMap(properties, os); os.close(); marshalledProperties = baos.toBuffer(); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { // Need to marshal the properties. if (marshalledProperties == null && properties != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(baos); MarshallingSupport.marshalPrimitiveMap(properties, os); os.close(); marshalledProperties = baos.toBuffer(); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { // Need to marshal the properties. if (marshalledProperties == null && properties != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(baos); MarshallingSupport.marshalPrimitiveMap(properties, os); os.close(); marshalledProperties = baos.toBuffer(); } }
public static byte[] readBytes(InputStream in) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copyInputStream(in, baos); return baos.toByteArray(); }
public void storeContent() { Buffer bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toBuffer()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
public void storeContent() { Buffer bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toBuffer()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
private void storeContent() { try { if (getContent() == null && !map.isEmpty()) { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); MarshallingSupport.marshalPrimitiveMap(map, dataOut); dataOut.close(); setContent(bytesOut.toBuffer()); } } catch (IOException e) { throw new RuntimeException(e); } }
private void storeContent() { try { if (getContent() == null && !map.isEmpty()) { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); MarshallingSupport.marshalPrimitiveMap(map, dataOut); dataOut.close(); setContent(bytesOut.toBuffer()); } } catch (IOException e) { throw new RuntimeException(e); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { super.beforeMarshall(wireFormat); Buffer content = getContent(); if (content == null && text != null) { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); MarshallingSupport.writeUTF8(dataOut, this.text); dataOut.close(); setContent(bytesOut.toBuffer()); } }
public void beforeMarshall(OpenWireFormat wireFormat) throws IOException { super.beforeMarshall(wireFormat); Buffer content = getContent(); if (content == null && text != null) { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; if (Settings.enable_compression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); MarshallingSupport.writeUTF8(dataOut, this.text); dataOut.close(); setContent(bytesOut.toBuffer()); } }
public static AsciiBuffer encodeHeader(String value) { if (value == null) return null; try { byte[] data = value.getBytes("UTF-8"); ByteArrayOutputStream rc = new ByteArrayOutputStream(data.length); for (byte d : data) { switch (d) { case ESCAPE_BYTE: rc.write(ESCAPE_ESCAPE_SEQ); break; case COLON_BYTE: rc.write(COLON_ESCAPE_SEQ); break; case NEWLINE_BYTE: rc.write(COLON_ESCAPE_SEQ); break; default: rc.write(d); } } return rc.toBuffer().ascii(); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); // not expected. } }
@Override protected void processDelivery(Delivery delivery) { if( !delivery.isReadable() ) { System.out.println("it was not readable!"); return; } if( current==null ) { current = new ByteArrayOutputStream(); } int count; byte data[] = new byte[1024*4]; while( (count = receiver.recv(data, 0, data.length)) > 0 ) { current.write(data, 0, count); } // Expecting more deliveries.. if( count == 0 ) { return; } receiver.advance(); Buffer buffer = current.toBuffer(); current = null; onMessage(delivery, buffer); }
private AsciiBuffer getNextMessageId() throws JMSException { AsciiBuffer session = null; if(channel!=null) { session = channel.sessionId(); } else { session = connection.getChannel().sessionId(); } AsciiBuffer id = ascii(Long.toString(nextMessageSwquence++)); ByteArrayOutputStream out = new ByteArrayOutputStream(3+session.length() + 1 + id.length()); out.write('I'); out.write('D'); out.write(':'); out.write(session); out.write('-'); out.write(id); return out.toBuffer().ascii(); }
private AsciiBuffer getNextMessageId() throws JMSException { AsciiBuffer session = null; if(channel!=null) { session = channel.sessionId(); } else { session = connection.getChannel().sessionId(); } AsciiBuffer id = ascii(Long.toString(nextMessageSwquence++)); ByteArrayOutputStream out = new ByteArrayOutputStream(3+session.length() + 1 + id.length()); out.write('I'); out.write('D'); out.write(':'); out.write(session); out.write('-'); out.write(id); return out.toBuffer().ascii(); }
@Override public void delivery(Delivery delivery) throws Exception { if (!delivery.isReadable()) { LOG.debug("Delivery was not readable!"); return; } if (current == null) { current = new ByteArrayOutputStream(); } int count; while ((count = getEndpoint().recv(recvBuffer, 0, recvBuffer.length)) > 0) { current.write(recvBuffer, 0, count); if (current.size() > session.getMaxFrameSize()) { throw new AmqpProtocolException("Frame size of " + current.size() + " larger than max allowed " + session.getMaxFrameSize()); } } // Expecting more deliveries.. if (count == 0) { return; } try { processDelivery(delivery, current.toBuffer()); } finally { getEndpoint().advance(); current = null; } }
@Override public void delivery(Delivery delivery) throws Exception { if (!delivery.isReadable()) { LOG.debug("Delivery was not readable!"); return; } if (current == null) { current = new ByteArrayOutputStream(); } int count; while ((count = getEndpoint().recv(recvBuffer, 0, recvBuffer.length)) > 0) { current.write(recvBuffer, 0, count); if (current.size() > session.getMaxFrameSize()) { throw new AmqpProtocolException("Frame size of " + current.size() + " larger than max allowed " + session.getMaxFrameSize()); } } // Expecting more deliveries.. if (count == 0) { return; } try { processDelivery(delivery, current.toBuffer()); } finally { getEndpoint().advance(); current = null; } }