Java Code Examples for org.apache.qpid.proton.amqp.messaging.AmqpValue#getValue()
The following examples show how to use
org.apache.qpid.proton.amqp.messaging.AmqpValue#getValue() .
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: JMSMappingOutboundTransformerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testConvertStreamMessageToAmqpMessageWithAmqpValueBodyNoPropertySet() throws Exception { ServerJMSStreamMessage outbound = createStreamMessage(); outbound.writeBoolean(false); outbound.writeString("test"); outbound.encode(); AMQPMessage amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage(), null); assertNotNull(amqp.getBody()); assertTrue(amqp.getBody() instanceof AmqpValue); AmqpValue list = (AmqpValue) amqp.getBody(); @SuppressWarnings("unchecked") List<Object> amqpList = (List<Object>) list.getValue(); assertEquals(2, amqpList.size()); }
Example 2
Source File: JMSMappingOutboundTransformerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testConvertStreamMessageToAmqpMessageWithAmqpValueBody() throws Exception { ServerJMSStreamMessage outbound = createStreamMessage(); outbound.setShortProperty(JMS_AMQP_ORIGINAL_ENCODING, AMQP_VALUE_LIST); outbound.writeBoolean(false); outbound.writeString("test"); outbound.encode(); AMQPMessage amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage(), null); assertNotNull(amqp.getBody()); assertTrue(amqp.getBody() instanceof AmqpValue); AmqpValue list = (AmqpValue) amqp.getBody(); @SuppressWarnings("unchecked") List<Object> amqpList = (List<Object>) list.getValue(); assertEquals(2, amqpList.size()); }
Example 3
Source File: RouterManagement.java From enmasse with Apache License 2.0 | 5 votes |
private List<List<?>> collectRouter(SyncRequestClient client, RouterEntity routerEntity) { Map<String, Object> properties = new LinkedHashMap<>(); properties.put("operation", "QUERY"); properties.put("entityType", routerEntity.getName()); Map<String, Object> body = new LinkedHashMap<>(); if (routerEntity.getAttributes() != null) { body.put("attributeNames", Arrays.asList(routerEntity.getAttributes())); } Message message = Proton.message(); message.setApplicationProperties(new ApplicationProperties(properties)); message.setBody(new AmqpValue(body)); long timeoutSeconds = this.queryTimeout.getSeconds(); Message response = client.request(message, timeoutSeconds, TimeUnit.SECONDS); if (response == null) { throw new IllegalArgumentException(String.format("No response received within timeout : %s(s)", timeoutSeconds)); } AmqpValue value = (AmqpValue) response.getBody(); if (value == null) { throw new IllegalArgumentException("Unexpected null body"); } Map<?,?> values = (Map<?,?>) value.getValue(); if (values == null) { throw new IllegalArgumentException("Unexpected null body value"); } @SuppressWarnings("unchecked") List<List<?>> results = (List<List<?>>) values.get("results"); if (results == null) { throw new IllegalArgumentException("Unexpected null results list"); } return results; }
Example 4
Source File: AmqpLargeMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testMessageWithAmqpValueAndEmptyBinaryPreservesBody() throws Exception { server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST)); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); try { AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(getTestName()); AmqpMessage message = createAmqpLargeMessageWithNoBody(); message.getWrappedMessage().setBody(new AmqpValue(new Binary(new byte[0]))); sender.send(message); sender.close(); AmqpReceiver receiver = session.createReceiver(getTestName()); receiver.flow(1); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); assertNotNull("failed to read large AMQP message", received); MessageImpl wrapped = (MessageImpl) received.getWrappedMessage(); assertTrue(wrapped.getBody() instanceof AmqpValue); AmqpValue body = (AmqpValue) wrapped.getBody(); assertTrue(body.getValue() instanceof Binary); Binary payload = (Binary) body.getValue(); assertEquals(0, payload.getLength()); received.accept(); session.close(); } finally { connection.close(); } }
Example 5
Source File: AmqpValueType.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@Override protected Object wrap(AmqpValue val) { return val.getValue(); }
Example 6
Source File: AmqpLargeMessageTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout = 60000) public void testMessageWithAmqpValueListPreservesBodyType() throws Exception { server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST)); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); try { AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(getTestName()); AmqpMessage message = createAmqpLargeMessageWithNoBody(); List<String> values = new ArrayList<>(); values.add("1"); values.add("2"); values.add("3"); message.getWrappedMessage().setBody(new AmqpValue(values)); sender.send(message); sender.close(); AmqpReceiver receiver = session.createReceiver(getTestName()); receiver.flow(1); AmqpMessage received = receiver.receive(10, TimeUnit.SECONDS); assertNotNull("failed to read large AMQP message", received); MessageImpl wrapped = (MessageImpl) received.getWrappedMessage(); assertTrue(wrapped.getBody() instanceof AmqpValue); AmqpValue body = (AmqpValue) wrapped.getBody(); assertTrue(body.getValue() instanceof List); List<String> payload = (List) body.getValue(); assertEquals(3, payload.size()); received.accept(); session.close(); } finally { connection.close(); } }