Java Code Examples for org.apache.qpid.proton.amqp.messaging.Properties#setReplyTo()

The following examples show how to use org.apache.qpid.proton.amqp.messaging.Properties#setReplyTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Benchmark.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
private void benchmarkProperties() throws IOException {
    Properties properties = new Properties();
    properties.setTo("queue:1-1024");
    properties.setReplyTo("queue:1-11024-reply");
    properties.setMessageId("ID:255f1297-5a71-4df1-8147-b2cdf850a56f:1");
    properties.setCreationTime(new Date(System.currentTimeMillis()));

    resultSet.start();
    for (int i = 0; i < ITERATIONS; i++) {
        outputBuf.byteBuffer().clear();
        encoder.writeObject(properties);
    }
    resultSet.encodesComplete();

    CompositeReadableBuffer inputBuf = convertToComposite(outputBuf);
    decoder.setBuffer(inputBuf);

    resultSet.start();
    for (int i = 0; i < ITERATIONS; i++) {
        decoder.readObject();
        inputBuf.flip();
    }
    resultSet.decodesComplete();

    time("Properties", resultSet);
}
 
Example 2
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetReplyToWithReceivedMessage() throws JMSException {
    String testReplyToAddress = "myTestReplyTo";

    Message message = Proton.message();

    Properties props = new Properties();
    props.setReplyTo(testReplyToAddress);
    message.setProperties(props);

    AmqpJmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message);

    JmsDestination dest = amqpMessageFacade.getReplyTo();
    //We didn't set any destination type annotations, so the consumer destination type will be used: a topic.
    assertTrue(dest instanceof Topic);
    assertEquals(testReplyToAddress, ((Topic) dest).getTopicName());
}
 
Example 3
Source File: FastPathPropertiesType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public Properties readValue() {
    DecoderImpl decoder = getDecoder();
    ReadableBuffer buffer = decoder.getBuffer();
    byte typeCode = decoder.getBuffer().get();

    @SuppressWarnings("unused")
    int size = 0;
    int count = 0;

    switch (typeCode) {
        case EncodingCodes.LIST0:
            break;
        case EncodingCodes.LIST8:
            size = buffer.get() & 0xff;
            count = buffer.get() & 0xff;
            break;
        case EncodingCodes.LIST32:
            size = buffer.getInt();
            count = buffer.getInt();
            break;
        default:
            throw new DecodeException("Incorrect type found in Properties encoding: " + typeCode);
    }

    Properties properties = new Properties();

    for (int index = 0; index < count; ++index) {
        switch (index) {
            case 0:
                properties.setMessageId(decoder.readObject());
                break;
            case 1:
                properties.setUserId(decoder.readBinary(null));
                break;
            case 2:
                properties.setTo(decoder.readString(null));
                break;
            case 3:
                properties.setSubject(decoder.readString(null));
                break;
            case 4:
                properties.setReplyTo(decoder.readString(null));
                break;
            case 5:
                properties.setCorrelationId(decoder.readObject());
                break;
            case 6:
                properties.setContentType(decoder.readSymbol(null));
                break;
            case 7:
                properties.setContentEncoding(decoder.readSymbol(null));
                break;
            case 8:
                properties.setAbsoluteExpiryTime(decoder.readTimestamp(null));
                break;
            case 9:
                properties.setCreationTime(decoder.readTimestamp(null));
                break;
            case 10:
                properties.setGroupId(decoder.readString(null));
                break;
            case 11:
                properties.setGroupSequence(decoder.readUnsignedInteger(null));
                break;
            case 12:
                properties.setReplyToGroupId(decoder.readString(null));
                break;
            default:
                throw new IllegalStateException("To many entries in Properties encoding");
        }
    }

    return properties;
}
 
Example 4
Source File: PropertiesType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Properties newInstance(Object described)
{
    List l = (List) described;

    Properties o = new Properties();


    switch(13 - l.size())
    {

        case 0:
            o.setReplyToGroupId( (String) l.get( 12 ) );
        case 1:
            o.setGroupSequence( (UnsignedInteger) l.get( 11 ) );
        case 2:
            o.setGroupId( (String) l.get( 10 ) );
        case 3:
            o.setCreationTime( (Date) l.get( 9 ) );
        case 4:
            o.setAbsoluteExpiryTime( (Date) l.get( 8 ) );
        case 5:
            o.setContentEncoding( (Symbol) l.get( 7 ) );
        case 6:
            o.setContentType( (Symbol) l.get( 6 ) );
        case 7:
            o.setCorrelationId( (Object) l.get( 5 ) );
        case 8:
            o.setReplyTo( (String) l.get( 4 ) );
        case 9:
            o.setSubject( (String) l.get( 3 ) );
        case 10:
            o.setTo( (String) l.get( 2 ) );
        case 11:
            o.setUserId( (Binary) l.get( 1 ) );
        case 12:
            o.setMessageId( (Object) l.get( 0 ) );
    }


    return o;
}
 
Example 5
Source File: PropertiesCodecTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void doTestDecodePropertiesSeries(int size) throws IOException {
    Properties properties = new Properties();

    Date timeNow = new Date(System.currentTimeMillis());

    properties.setMessageId("ID:Message-1:1:1:0");
    properties.setUserId(new Binary(new byte[1]));
    properties.setTo("queue:work");
    properties.setSubject("help");
    properties.setReplyTo("queue:temp:me");
    properties.setContentEncoding(Symbol.valueOf("text/UTF-8"));
    properties.setContentType(Symbol.valueOf("text"));
    properties.setCorrelationId("correlation-id");
    properties.setAbsoluteExpiryTime(timeNow);
    properties.setCreationTime(timeNow);
    properties.setGroupId("group-1");
    properties.setGroupSequence(UnsignedInteger.valueOf(1));
    properties.setReplyToGroupId("group-1");

    for (int i = 0; i < size; ++i) {
        encoder.writeObject(properties);
    }

    buffer.clear();

    for (int i = 0; i < size; ++i) {
        final Object result = decoder.readObject();

        assertNotNull(result);
        assertTrue(result instanceof Properties);

        Properties decoded = (Properties) result;

        assertNotNull(decoded.getAbsoluteExpiryTime());
        assertEquals(timeNow, decoded.getAbsoluteExpiryTime());
        assertEquals(Symbol.valueOf("text/UTF-8"), decoded.getContentEncoding());
        assertEquals(Symbol.valueOf("text"), decoded.getContentType());
        assertEquals("correlation-id", decoded.getCorrelationId());
        assertEquals(timeNow, decoded.getCreationTime());
        assertEquals("group-1", decoded.getGroupId());
        assertEquals(UnsignedInteger.valueOf(1), decoded.getGroupSequence());
        assertEquals("ID:Message-1:1:1:0", decoded.getMessageId());
        assertEquals("queue:temp:me", decoded.getReplyTo());
        assertEquals("group-1", decoded.getReplyToGroupId());
        assertEquals("help", decoded.getSubject());
        assertEquals("queue:work", decoded.getTo());
        assertTrue(decoded.getUserId() instanceof Binary);
    }
}