Java Code Examples for org.apache.qpid.proton.amqp.messaging.Properties#setCreationTime()
The following examples show how to use
org.apache.qpid.proton.amqp.messaging.Properties#setCreationTime() .
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 |
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: AMQPPersisterTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private MessageImpl createProtonMessage(String address, byte[] content) { MessageImpl message = (MessageImpl) Proton.message(); Header header = new Header(); header.setDurable(true); header.setPriority(UnsignedByte.valueOf((byte) 9)); Properties properties = new Properties(); properties.setCreationTime(new Date(System.currentTimeMillis())); properties.setTo(address); properties.setMessageId(UUID.randomUUID()); MessageAnnotations annotations = new MessageAnnotations(new LinkedHashMap<>()); ApplicationProperties applicationProperties = new ApplicationProperties(new LinkedHashMap<>()); AmqpValue body = new AmqpValue(Arrays.copyOf(content, content.length)); message.setHeader(header); message.setMessageAnnotations(annotations); message.setProperties(properties); message.setApplicationProperties(applicationProperties); message.setBody(body); return message; }
Example 3
Source File: PropertiesBenchmark.java From qpid-proton-j with Apache License 2.0 | 5 votes |
private void initProperties() { properties = new Properties(); properties.setTo("queue:1"); properties.setMessageId("ID:Message:1"); properties.setCreationTime(new Date(System.currentTimeMillis())); }
Example 4
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetTimestampFromMessage() { Date timestamp = new Date(System.currentTimeMillis()); MessageImpl protonMessage = (MessageImpl) Message.Factory.create(); protonMessage.setHeader(new Header()); Properties properties = new Properties(); properties.setCreationTime(timestamp); protonMessage.setProperties(properties); AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage); assertEquals(timestamp.getTime(), decoded.getTimestamp()); }
Example 5
Source File: AMQPMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private MessageImpl createProtonMessage() { MessageImpl message = (MessageImpl) Proton.message(); Header header = new Header(); header.setDurable(true); header.setPriority(UnsignedByte.valueOf((byte) 9)); Properties properties = new Properties(); properties.setCreationTime(new Date(System.currentTimeMillis())); properties.setTo(TEST_TO_ADDRESS); properties.setMessageId(UUID.randomUUID()); MessageAnnotations annotations = new MessageAnnotations(new LinkedHashMap<>()); annotations.getValue().put(Symbol.valueOf(TEST_MESSAGE_ANNOTATION_KEY), TEST_MESSAGE_ANNOTATION_VALUE); ApplicationProperties applicationProperties = new ApplicationProperties(new LinkedHashMap<>()); applicationProperties.getValue().put(TEST_APPLICATION_PROPERTY_KEY, TEST_APPLICATION_PROPERTY_VALUE); AmqpValue body = new AmqpValue(TEST_STRING_BODY); message.setHeader(header); message.setMessageAnnotations(annotations); message.setProperties(properties); message.setApplicationProperties(applicationProperties); message.setBody(body); return message; }
Example 6
Source File: FastPathPropertiesType.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@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 7
Source File: PropertiesType.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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 8
Source File: PropertiesCodecTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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); } }