Package org.apache.qpid.proton.message.impl

Examples of org.apache.qpid.proton.message.impl.MessageImpl


            {
                if (delivery.isReadable())
                {
                    _logger.log(Level.FINE, "Readable delivery found: " + delivery);
                    int size = read((Receiver) delivery.getLink());
                    Message message = new MessageImpl();
                    message.decode(_buffer, 0, size);
                    _incoming.add(delivery);
                    _distributed--;
                    delivery.getLink().advance();
                    return message;
                }
View Full Code Here


                break;
        }
    }

    public Message createTextMessage(String value) {
        Message msg = new MessageImpl();
        Section body = new AmqpValue(value);
        msg.setBody(body);
        return msg;
    }
View Full Code Here

    public Message createBinaryMessage(byte value[]) {
        return createBinaryMessage(value, 0, value.length);
    }

    public Message createBinaryMessage(byte value[], int offset, int len) {
        Message msg = new MessageImpl();
        Data body = new Data(new Binary(value, offset,len));
        msg.setBody(body);
        return msg;
    }
View Full Code Here

      }
      receiver.advance();
      byte[] bytes = new byte[buffer.readableBytes()];
      buffer.readBytes(bytes);
      buffer.clear();
      MessageImpl msg = new MessageImpl();
      msg.decode(bytes, 0, bytes.length);
      Object action = ((AmqpValue) msg.getBody()).getValue();
      if (action instanceof Declare)
      {
         Transaction tx = protonSession.getServerSession().getCurrentTransaction();
         Declared declared = new Declared();
         declared.setTxnId(new Binary(longToBytes(tx.getID())));
View Full Code Here

      }
      receiver.advance();
      byte[] bytes = new byte[buffer.readableBytes()];
      buffer.readBytes(bytes);
      buffer.clear();
      MessageImpl msg = new MessageImpl();
      msg.decode(bytes, 0, bytes.length);
      Object action = ((AmqpValue) msg.getBody()).getValue();
      if (action instanceof Declare)
      {
         Transaction tx = protonSession.getServerSession().getCurrentTransaction();
         Declared declared = new Declared();
         declared.setTxnId(new Binary(longToBytes(tx.getID())));
View Full Code Here

               SimpleString value = (SimpleString) typedProperties.getProperty(propertyName);
               Symbol symbol = Symbol.getSymbol(realName.replace(MESSAGE_ANNOTATIONS, ""));
               messageAnnotations.getValue().put(symbol, value.toString());
            }
         }
         MessageImpl protonMessage = new MessageImpl(header, deliveryAnnotations, messageAnnotations, props, applicationProperties, section, footer);
         protonMessage.setMessageFormat(getMessageFormat(message.getLongProperty(new SimpleString(PROTON_MESSAGE_FORMAT))));
         ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
         final DroppingWritableBuffer overflow = new DroppingWritableBuffer();
         int c = protonMessage.encode(new CompositeWritableBuffer(new WritableBuffer.ByteBufferWrapper(buffer), overflow));
         if (overflow.position() > 0)
         {
            buffer = ByteBuffer.wrap(new byte[1024 * 4 + overflow.position()]);
            c = protonMessage.encode(new WritableBuffer.ByteBufferWrapper(buffer));
         }

         return new EncodedMessage(messageFormat, buffer.array(), 0, c);
      }
View Full Code Here

    // This uses deprecated classes, yes. I took them from the examples provided...

    public void testRoundTrip() throws Exception {
        Messenger mng = new MessengerImpl();
        mng.start();
        Message msg = new MessageImpl();
        msg.setAddress(ADDRESS);
        msg.setSubject("hello");
        msg.setContentType("application/octet-stream");
        msg.setBody(new Data(new Binary("hello world".getBytes())));
        mng.put(msg);
        mng.send();

        mng.subscribe(ADDRESS);
        mng.recv();
        Message msg2 = mng.get();
        assertEquals(msg.getSubject(), msg2.getSubject());
        assertEquals(msg.getContentType(), msg2.getContentType());
        assertEquals(msg.getBody().toString(), msg2.getBody().toString());
        mng.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.message.impl.MessageImpl

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.