use of org.apache.qpid.protonj2.test.driver.matchers.messaging.ApplicationPropertiesMatcher in project qpid-protonj2 by apache.
the class StreamSenderTest method testStreamSenderWritesFooterAfterStreamClosed.
@Test
public void testStreamSenderWritesFooterAfterStreamClosed() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
peer.expectSASLAnonymousConnect();
peer.expectOpen().respond();
peer.expectBegin().respond();
peer.expectAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(10).queue();
peer.start();
URI remoteURI = peer.getServerURI();
LOG.info("Sender test started, peer listening on: {}", remoteURI);
Client container = Client.create();
Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort()).openFuture().get();
StreamSender sender = connection.openStreamSender("test-queue");
StreamSenderMessage message = sender.beginMessage();
final byte[] payload = new byte[] { 0, 1, 2, 3, 4, 5 };
// First frame should include only the bits up to the body
HeaderMatcher headerMatcher = new HeaderMatcher(true);
headerMatcher.withDurable(true);
headerMatcher.withPriority((byte) 1);
headerMatcher.withTtl(65535);
headerMatcher.withFirstAcquirer(true);
headerMatcher.withDeliveryCount(2);
ApplicationPropertiesMatcher apMatcher = new ApplicationPropertiesMatcher(true);
apMatcher.withEntry("ap1", Matchers.equalTo(1));
apMatcher.withEntry("ap2", Matchers.equalTo(2));
apMatcher.withEntry("ap3", Matchers.equalTo(3));
FooterMatcher footerMatcher = new FooterMatcher(false);
footerMatcher.withEntry("f1", Matchers.equalTo(1));
footerMatcher.withEntry("f2", Matchers.equalTo(2));
footerMatcher.withEntry("f3", Matchers.equalTo(3));
EncodedDataMatcher bodyMatcher = new EncodedDataMatcher(payload, true);
TransferPayloadCompositeMatcher payloadMatcher = new TransferPayloadCompositeMatcher();
payloadMatcher.setHeadersMatcher(headerMatcher);
payloadMatcher.setApplicationPropertiesMatcher(apMatcher);
payloadMatcher.setMessageContentMatcher(bodyMatcher);
payloadMatcher.setFootersMatcher(footerMatcher);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectTransfer().withPayload(payloadMatcher).withMore(false).accept();
// Populate all Header values
message.durable(true);
message.priority((byte) 1);
message.timeToLive(65535);
message.firstAcquirer(true);
message.deliveryCount(2);
// Populate message application properties
message.property("ap1", 1);
message.property("ap2", 2);
message.property("ap3", 3);
// Populate message footers
assertFalse(message.hasFooters());
assertFalse(message.hasFooter("f1"));
message.footer("f1", 1);
message.footer("f2", 2);
message.footer("f3", 3);
assertTrue(message.hasFooter("f1"));
assertTrue(message.hasFooters());
OutputStreamOptions bodyOptions = new OutputStreamOptions().completeSendOnClose(true);
OutputStream stream = message.body(bodyOptions);
assertThrows(ClientUnsupportedOperationException.class, () -> message.encode(Collections.emptyMap()));
stream.write(payload);
stream.close();
assertThrows(ClientIllegalStateException.class, () -> message.footer(new Footer(Collections.emptyMap())));
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectDetach().respond();
peer.expectEnd().respond();
peer.expectClose().respond();
assertNotNull(message.tracker());
Wait.assertTrue(() -> message.tracker().settlementFuture().isDone());
assertTrue(message.tracker().settlementFuture().get().settled());
sender.closeAsync().get(10, TimeUnit.SECONDS);
connection.closeAsync().get(10, TimeUnit.SECONDS);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
}
}
use of org.apache.qpid.protonj2.test.driver.matchers.messaging.ApplicationPropertiesMatcher in project qpid-protonj2 by apache.
the class StreamSenderTest method testStreamSenderMessageWithDeliveryAnnotations.
@Test
public void testStreamSenderMessageWithDeliveryAnnotations() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
peer.expectSASLAnonymousConnect();
peer.expectOpen().respond();
peer.expectBegin().respond();
peer.expectAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(10).queue();
peer.start();
URI remoteURI = peer.getServerURI();
LOG.info("Sender test started, peer listening on: {}", remoteURI);
Client container = Client.create();
Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort()).openFuture().get();
// Populate delivery annotations
final Map<String, Object> deliveryAnnotations = new HashMap<>();
deliveryAnnotations.put("da1", 1);
deliveryAnnotations.put("da2", 2);
deliveryAnnotations.put("da3", 3);
StreamSender sender = connection.openStreamSender("test-queue");
StreamSenderMessage message = sender.beginMessage(deliveryAnnotations);
final byte[] payload = new byte[] { 0, 1, 2, 3, 4, 5 };
HeaderMatcher headerMatcher = new HeaderMatcher(true);
headerMatcher.withDurable(true);
headerMatcher.withPriority((byte) 1);
headerMatcher.withTtl(65535);
headerMatcher.withFirstAcquirer(true);
headerMatcher.withDeliveryCount(2);
PropertiesMatcher propertiesMatcher = new PropertiesMatcher(true);
propertiesMatcher.withMessageId("ID:12345");
propertiesMatcher.withUserId("user".getBytes(StandardCharsets.UTF_8));
propertiesMatcher.withTo("the-management");
propertiesMatcher.withSubject("amqp");
propertiesMatcher.withReplyTo("the-minions");
propertiesMatcher.withCorrelationId("abc");
propertiesMatcher.withContentEncoding("application/json");
propertiesMatcher.withContentType("gzip");
propertiesMatcher.withAbsoluteExpiryTime(123);
propertiesMatcher.withCreationTime(1);
propertiesMatcher.withGroupId("disgruntled");
propertiesMatcher.withGroupSequence(8192);
propertiesMatcher.withReplyToGroupId("/dev/null");
DeliveryAnnotationsMatcher daMatcher = new DeliveryAnnotationsMatcher(true);
daMatcher.withEntry("da1", Matchers.equalTo(1));
daMatcher.withEntry("da2", Matchers.equalTo(2));
daMatcher.withEntry("da3", Matchers.equalTo(3));
MessageAnnotationsMatcher maMatcher = new MessageAnnotationsMatcher(true);
maMatcher.withEntry("ma1", Matchers.equalTo(1));
maMatcher.withEntry("ma2", Matchers.equalTo(2));
maMatcher.withEntry("ma3", Matchers.equalTo(3));
ApplicationPropertiesMatcher apMatcher = new ApplicationPropertiesMatcher(true);
apMatcher.withEntry("ap1", Matchers.equalTo(1));
apMatcher.withEntry("ap2", Matchers.equalTo(2));
apMatcher.withEntry("ap3", Matchers.equalTo(3));
EncodedDataMatcher bodyMatcher = new EncodedDataMatcher(payload);
TransferPayloadCompositeMatcher payloadMatcher = new TransferPayloadCompositeMatcher();
payloadMatcher.setHeadersMatcher(headerMatcher);
payloadMatcher.setDeliveryAnnotationsMatcher(daMatcher);
payloadMatcher.setMessageAnnotationsMatcher(maMatcher);
payloadMatcher.setPropertiesMatcher(propertiesMatcher);
payloadMatcher.setApplicationPropertiesMatcher(apMatcher);
payloadMatcher.setMessageContentMatcher(bodyMatcher);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectTransfer().withPayload(payloadMatcher).withMore(false).accept();
// Populate all Header values
message.durable(true);
assertEquals(true, message.durable());
message.priority((byte) 1);
assertEquals(1, message.priority());
message.timeToLive(65535);
assertEquals(65535, message.timeToLive());
message.firstAcquirer(true);
assertTrue(message.firstAcquirer());
message.deliveryCount(2);
assertEquals(2, message.deliveryCount());
// Populate message annotations
assertFalse(message.hasAnnotations());
assertFalse(message.hasAnnotation("ma1"));
message.annotation("ma1", 1);
assertTrue(message.hasAnnotation("ma1"));
assertEquals(1, message.annotation("ma1"));
message.annotation("ma2", 2);
assertEquals(2, message.annotation("ma2"));
message.annotation("ma3", 3);
assertEquals(3, message.annotation("ma3"));
assertTrue(message.hasAnnotations());
// Populate all Properties values
message.messageId("ID:12345");
assertEquals("ID:12345", message.messageId());
message.userId("user".getBytes(StandardCharsets.UTF_8));
assertArrayEquals("user".getBytes(StandardCharsets.UTF_8), message.userId());
message.to("the-management");
assertEquals("the-management", message.to());
message.subject("amqp");
assertEquals("amqp", message.subject());
message.replyTo("the-minions");
assertEquals("the-minions", message.replyTo());
message.correlationId("abc");
assertEquals("abc", message.correlationId());
message.contentEncoding("application/json");
assertEquals("application/json", message.contentEncoding());
message.contentType("gzip");
assertEquals("gzip", message.contentType());
message.absoluteExpiryTime(123);
assertEquals(123, message.absoluteExpiryTime());
message.creationTime(1);
assertEquals(1, message.creationTime());
message.groupId("disgruntled");
assertEquals("disgruntled", message.groupId());
message.groupSequence(8192);
assertEquals(8192, message.groupSequence());
message.replyToGroupId("/dev/null");
assertEquals("/dev/null", message.replyToGroupId());
// Populate message application properties
assertFalse(message.hasProperties());
assertFalse(message.hasProperty("ma1"));
message.property("ap1", 1);
assertEquals(1, message.property("ap1"));
assertTrue(message.hasProperty("ap1"));
message.property("ap2", 2);
assertEquals(2, message.property("ap2"));
message.property("ap3", 3);
assertEquals(3, message.property("ap3"));
assertTrue(message.hasProperties());
OutputStream stream = message.body();
stream.write(payload);
stream.close();
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectDetach().respond();
peer.expectEnd().respond();
peer.expectClose().respond();
assertNotNull(message.tracker());
Wait.assertTrue(() -> message.tracker().settlementFuture().isDone());
assertTrue(message.tracker().settlementFuture().get().settled());
sender.closeAsync().get(10, TimeUnit.SECONDS);
connection.closeAsync().get(10, TimeUnit.SECONDS);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
}
}
use of org.apache.qpid.protonj2.test.driver.matchers.messaging.ApplicationPropertiesMatcher in project qpid-protonj2 by apache.
the class MessageSendTest method testSendMessageWithApplicationPropertiesPopulated.
@Test
public void testSendMessageWithApplicationPropertiesPopulated() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
peer.expectSASLAnonymousConnect();
peer.expectOpen().respond();
peer.expectBegin().respond();
peer.expectAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(10).queue();
// Open a receiver to ensure sender link has processed
peer.expectAttach().respond();
// the inbound flow frame we sent previously before send.
peer.expectFlow();
peer.start();
URI remoteURI = peer.getServerURI();
LOG.info("Sender test started, peer listening on: {}", remoteURI);
Client container = Client.create();
Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort()).openFuture().get();
Session session = connection.openSession().openFuture().get();
SenderOptions options = new SenderOptions().deliveryMode(DeliveryMode.AT_MOST_ONCE);
Sender sender = session.openSender("test-qos", options);
// Gates send on remote flow having been sent and received
session.openReceiver("dummy").openFuture().get();
ApplicationPropertiesMatcher apMatcher = new ApplicationPropertiesMatcher(true);
apMatcher.withEntry("one", Matchers.equalTo(1));
apMatcher.withEntry("two", Matchers.equalTo(2));
apMatcher.withEntry("three", Matchers.equalTo(3));
EncodedAmqpValueMatcher bodyMatcher = new EncodedAmqpValueMatcher("Hello World");
TransferPayloadCompositeMatcher payloadMatcher = new TransferPayloadCompositeMatcher();
payloadMatcher.setApplicationPropertiesMatcher(apMatcher);
payloadMatcher.setMessageContentMatcher(bodyMatcher);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectTransfer().withPayload(payloadMatcher).accept();
peer.expectDetach().respond();
peer.expectClose().respond();
final Message<String> message = Message.create("Hello World");
// Populate message application properties
message.property("one", 1);
message.property("two", 2);
message.property("three", 3);
final Tracker tracker = sender.send(message);
assertNotNull(tracker);
assertNotNull(tracker.settlementFuture().isDone());
assertNotNull(tracker.settlementFuture().get().settled());
sender.closeAsync().get(10, TimeUnit.SECONDS);
connection.closeAsync().get(10, TimeUnit.SECONDS);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
}
}
use of org.apache.qpid.protonj2.test.driver.matchers.messaging.ApplicationPropertiesMatcher in project qpid-protonj2 by apache.
the class MessageSendTest method doTestSendOfExternalMessage.
private void doTestSendOfExternalMessage(boolean allowAdvancedConversion, boolean trySend) throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
peer.expectSASLAnonymousConnect();
peer.expectOpen().respond();
peer.expectBegin().respond();
peer.expectAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(10).queue();
// Open a receiver to ensure sender link has processed
peer.expectAttach().respond();
// the inbound flow frame we sent previously before send.
peer.expectFlow();
peer.start();
URI remoteURI = peer.getServerURI();
LOG.info("Sender test started, peer listening on: {}", remoteURI);
Client container = Client.create();
Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort()).openFuture().get();
Session session = connection.openSession().openFuture().get();
SenderOptions options = new SenderOptions().deliveryMode(DeliveryMode.AT_MOST_ONCE);
Sender sender = session.openSender("test-qos", options);
// Gates send on remote flow having been sent and received
session.openReceiver("dummy").openFuture().get();
HeaderMatcher headerMatcher = new HeaderMatcher(true);
headerMatcher.withDurable(true);
headerMatcher.withPriority((byte) 1);
headerMatcher.withTtl(65535);
headerMatcher.withFirstAcquirer(true);
headerMatcher.withDeliveryCount(2);
PropertiesMatcher propertiesMatcher = new PropertiesMatcher(true);
propertiesMatcher.withMessageId("ID:12345");
propertiesMatcher.withUserId("user".getBytes(StandardCharsets.UTF_8));
propertiesMatcher.withTo("the-management");
propertiesMatcher.withSubject("amqp");
propertiesMatcher.withReplyTo("the-minions");
propertiesMatcher.withCorrelationId("abc");
propertiesMatcher.withContentEncoding("application/json");
propertiesMatcher.withContentEncoding("gzip");
propertiesMatcher.withAbsoluteExpiryTime(123);
propertiesMatcher.withCreationTime(1);
propertiesMatcher.withGroupId("disgruntled");
propertiesMatcher.withGroupSequence(8192);
propertiesMatcher.withReplyToGroupId("/dev/null");
DeliveryAnnotationsMatcher daMatcher = new DeliveryAnnotationsMatcher(true);
daMatcher.withEntry("da1", Matchers.equalTo(1));
daMatcher.withEntry("da2", Matchers.equalTo(2));
daMatcher.withEntry("da3", Matchers.equalTo(3));
MessageAnnotationsMatcher maMatcher = new MessageAnnotationsMatcher(true);
maMatcher.withEntry("ma1", Matchers.equalTo(1));
maMatcher.withEntry("ma2", Matchers.equalTo(2));
maMatcher.withEntry("ma3", Matchers.equalTo(3));
ApplicationPropertiesMatcher apMatcher = new ApplicationPropertiesMatcher(true);
apMatcher.withEntry("ap1", Matchers.equalTo(1));
apMatcher.withEntry("ap2", Matchers.equalTo(2));
apMatcher.withEntry("ap3", Matchers.equalTo(3));
FooterMatcher footerMatcher = new FooterMatcher(false);
footerMatcher.withEntry("f1", Matchers.equalTo(1));
footerMatcher.withEntry("f2", Matchers.equalTo(2));
footerMatcher.withEntry("f3", Matchers.equalTo(3));
EncodedAmqpValueMatcher bodyMatcher = new EncodedAmqpValueMatcher("Hello World", true);
TransferPayloadCompositeMatcher payloadMatcher = new TransferPayloadCompositeMatcher();
payloadMatcher.setHeadersMatcher(headerMatcher);
payloadMatcher.setDeliveryAnnotationsMatcher(daMatcher);
payloadMatcher.setMessageAnnotationsMatcher(maMatcher);
payloadMatcher.setPropertiesMatcher(propertiesMatcher);
payloadMatcher.setApplicationPropertiesMatcher(apMatcher);
payloadMatcher.setMessageContentMatcher(bodyMatcher);
payloadMatcher.setFootersMatcher(footerMatcher);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectTransfer().withPayload(payloadMatcher).accept();
peer.expectDetach().respond();
peer.expectClose().respond();
// Populate delivery annotations
Map<String, Object> deliveryAnnotations = new HashMap<>();
deliveryAnnotations.put("da1", 1);
deliveryAnnotations.put("da2", 2);
deliveryAnnotations.put("da3", 3);
final Message<String> message = new ExternalMessage<>(allowAdvancedConversion);
message.body("Hello World");
// Populate all Header values
message.durable(true);
message.priority((byte) 1);
message.timeToLive(65535);
message.firstAcquirer(true);
message.deliveryCount(2);
// Populate message annotations
message.annotation("ma1", 1);
message.annotation("ma2", 2);
message.annotation("ma3", 3);
// Populate all Properties values
message.messageId("ID:12345");
message.userId("user".getBytes(StandardCharsets.UTF_8));
message.to("the-management");
message.subject("amqp");
message.replyTo("the-minions");
message.correlationId("abc");
message.contentEncoding("application/json");
message.contentEncoding("gzip");
message.absoluteExpiryTime(123);
message.creationTime(1);
message.groupId("disgruntled");
message.groupSequence(8192);
message.replyToGroupId("/dev/null");
// Populate message application properties
message.property("ap1", 1);
message.property("ap2", 2);
message.property("ap3", 3);
// Populate message footers
message.footer("f1", 1);
message.footer("f2", 2);
message.footer("f3", 3);
// Check preconditions that should affect the send operation
if (allowAdvancedConversion) {
assertNotNull(message.toAdvancedMessage());
} else {
assertThrows(UnsupportedOperationException.class, () -> message.toAdvancedMessage());
}
final Tracker tracker;
if (trySend) {
tracker = sender.trySend(message, deliveryAnnotations);
} else {
tracker = sender.send(message, deliveryAnnotations);
}
assertNotNull(tracker);
assertNotNull(tracker.settlementFuture().isDone());
assertNotNull(tracker.settlementFuture().get().settled());
sender.closeAsync().get(10, TimeUnit.SECONDS);
connection.closeAsync().get(10, TimeUnit.SECONDS);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
}
}
use of org.apache.qpid.protonj2.test.driver.matchers.messaging.ApplicationPropertiesMatcher in project qpid-protonj2 by apache.
the class MessageSendTest method testSendMessageWithMultipleSectionsPopulated.
@Test
public void testSendMessageWithMultipleSectionsPopulated() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
peer.expectSASLAnonymousConnect();
peer.expectOpen().respond();
peer.expectBegin().respond();
peer.expectAttach().ofSender().respond();
peer.remoteFlow().withLinkCredit(10).queue();
// Open a receiver to ensure sender link has processed
peer.expectAttach().respond();
// the inbound flow frame we sent previously before send.
peer.expectFlow();
peer.start();
URI remoteURI = peer.getServerURI();
LOG.info("Sender test started, peer listening on: {}", remoteURI);
Client container = Client.create();
Connection connection = container.connect(remoteURI.getHost(), remoteURI.getPort()).openFuture().get();
Session session = connection.openSession().openFuture().get();
SenderOptions options = new SenderOptions().deliveryMode(DeliveryMode.AT_MOST_ONCE);
Sender sender = session.openSender("test-qos", options);
// Gates send on remote flow having been sent and received
session.openReceiver("dummy").openFuture().get();
HeaderMatcher headerMatcher = new HeaderMatcher(true);
headerMatcher.withDurable(true);
headerMatcher.withPriority((byte) 1);
headerMatcher.withTtl(65535);
headerMatcher.withFirstAcquirer(true);
headerMatcher.withDeliveryCount(2);
PropertiesMatcher propertiesMatcher = new PropertiesMatcher(true);
propertiesMatcher.withMessageId("ID:12345");
propertiesMatcher.withUserId("user".getBytes(StandardCharsets.UTF_8));
propertiesMatcher.withTo("the-management");
propertiesMatcher.withSubject("amqp");
propertiesMatcher.withReplyTo("the-minions");
propertiesMatcher.withCorrelationId("abc");
propertiesMatcher.withContentEncoding("application/json");
propertiesMatcher.withContentEncoding("gzip");
propertiesMatcher.withAbsoluteExpiryTime(123);
propertiesMatcher.withCreationTime(1);
propertiesMatcher.withGroupId("disgruntled");
propertiesMatcher.withGroupSequence(8192);
propertiesMatcher.withReplyToGroupId("/dev/null");
DeliveryAnnotationsMatcher daMatcher = new DeliveryAnnotationsMatcher(true);
daMatcher.withEntry("da1", Matchers.equalTo(1));
daMatcher.withEntry("da2", Matchers.equalTo(2));
daMatcher.withEntry("da3", Matchers.equalTo(3));
MessageAnnotationsMatcher maMatcher = new MessageAnnotationsMatcher(true);
maMatcher.withEntry("ma1", Matchers.equalTo(1));
maMatcher.withEntry("ma2", Matchers.equalTo(2));
maMatcher.withEntry("ma3", Matchers.equalTo(3));
ApplicationPropertiesMatcher apMatcher = new ApplicationPropertiesMatcher(true);
apMatcher.withEntry("ap1", Matchers.equalTo(1));
apMatcher.withEntry("ap2", Matchers.equalTo(2));
apMatcher.withEntry("ap3", Matchers.equalTo(3));
EncodedAmqpValueMatcher bodyMatcher = new EncodedAmqpValueMatcher("Hello World", true);
FooterMatcher footerMatcher = new FooterMatcher(false);
footerMatcher.withEntry("f1", Matchers.equalTo(1));
footerMatcher.withEntry("f2", Matchers.equalTo(2));
footerMatcher.withEntry("f3", Matchers.equalTo(3));
TransferPayloadCompositeMatcher payloadMatcher = new TransferPayloadCompositeMatcher();
payloadMatcher.setHeadersMatcher(headerMatcher);
payloadMatcher.setDeliveryAnnotationsMatcher(daMatcher);
payloadMatcher.setMessageAnnotationsMatcher(maMatcher);
payloadMatcher.setPropertiesMatcher(propertiesMatcher);
payloadMatcher.setApplicationPropertiesMatcher(apMatcher);
payloadMatcher.setMessageContentMatcher(bodyMatcher);
payloadMatcher.setFootersMatcher(footerMatcher);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
peer.expectTransfer().withPayload(payloadMatcher).accept();
peer.expectDetach().respond();
peer.expectClose().respond();
// Populate delivery annotations
Map<String, Object> deliveryAnnotations = new HashMap<>();
deliveryAnnotations.put("da1", 1);
deliveryAnnotations.put("da2", 2);
deliveryAnnotations.put("da3", 3);
final Message<String> message = Message.create("Hello World");
// Populate all Header values
message.durable(true);
message.priority((byte) 1);
message.timeToLive(65535);
message.firstAcquirer(true);
message.deliveryCount(2);
// Populate message annotations
message.annotation("ma1", 1);
message.annotation("ma2", 2);
message.annotation("ma3", 3);
// Populate all Properties values
message.messageId("ID:12345");
message.userId("user".getBytes(StandardCharsets.UTF_8));
message.to("the-management");
message.subject("amqp");
message.replyTo("the-minions");
message.correlationId("abc");
message.contentEncoding("application/json");
message.contentEncoding("gzip");
message.absoluteExpiryTime(123);
message.creationTime(1);
message.groupId("disgruntled");
message.groupSequence(8192);
message.replyToGroupId("/dev/null");
// Populate message application properties
message.property("ap1", 1);
message.property("ap2", 2);
message.property("ap3", 3);
// Populate message footers
message.footer("f1", 1);
message.footer("f2", 2);
message.footer("f3", 3);
final Tracker tracker = sender.send(message, deliveryAnnotations);
assertNotNull(tracker);
assertNotNull(tracker.settlementFuture().isDone());
assertNotNull(tracker.settlementFuture().get().settled());
sender.closeAsync().get(10, TimeUnit.SECONDS);
connection.closeAsync().get(10, TimeUnit.SECONDS);
peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
}
}
Aggregations