当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationProperties类代码示例

本文整理汇总了Java中org.apache.qpid.proton.amqp.messaging.ApplicationProperties的典型用法代码示例。如果您正苦于以下问题:Java ApplicationProperties类的具体用法?Java ApplicationProperties怎么用?Java ApplicationProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationProperties类属于org.apache.qpid.proton.amqp.messaging包,在下文中一共展示了ApplicationProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setApplicationProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
/**
 * Set the application properties for a Proton Message but do a check for all properties first if they only contain
 * values that the AMQP 1.0 spec allows.
 *
 * @param msg The Proton message. Must not be null.
 * @param properties The map containing application properties.
 * @throws NullPointerException if the message passed in is null.
 * @throws IllegalArgumentException if the properties contain any value that AMQP 1.0 disallows.
 */
protected static final void setApplicationProperties(final Message msg, final Map<String, ?> properties) {
    if (properties != null) {

        // check the three types not allowed by AMQP 1.0 spec for application properties (list, map and array)
        for (final Map.Entry<String, ?> entry: properties.entrySet()) {
            if (entry.getValue() instanceof List) {
                throw new IllegalArgumentException(String.format("Application property %s can't be a List", entry.getKey()));
            } else if (entry.getValue() instanceof Map) {
                throw new IllegalArgumentException(String.format("Application property %s can't be a Map", entry.getKey()));
            } else if (entry.getValue().getClass().isArray()) {
                throw new IllegalArgumentException(String.format("Application property %s can't be an Array", entry.getKey()));
            }
        }

        final ApplicationProperties applicationProperties = new ApplicationProperties(properties);
        msg.setApplicationProperties(applicationProperties);
    }
}
 
开发者ID:eclipse,项目名称:hono,代码行数:28,代码来源:AbstractHonoClient.java

示例2: getRegistrationAssertion

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
private static String getRegistrationAssertion(final Message msg, final boolean removeAssertion) {
    Objects.requireNonNull(msg);
    String assertion = null;
    ApplicationProperties properties = msg.getApplicationProperties();
    if (properties != null) {
        Object obj = null;
        if (removeAssertion) {
            obj = properties.getValue().remove(APP_PROPERTY_REGISTRATION_ASSERTION);
        } else {
            obj = properties.getValue().get(APP_PROPERTY_REGISTRATION_ASSERTION);
        }
        if (obj instanceof String) {
            assertion = (String) obj;
        }
    }
    return assertion;
}
 
开发者ID:eclipse,项目名称:hono,代码行数:18,代码来源:MessageHelper.java

示例3: checkRouter

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
private List<String> checkRouter(SyncRequestClient client, String entityType, String attributeName) {
    Map<String, String> properties = new LinkedHashMap<>();
    properties.put("operation", "QUERY");
    properties.put("entityType", entityType);
    Map body = new LinkedHashMap<>();

    body.put("attributeNames", Arrays.asList(attributeName));

    Message message = Proton.message();
    message.setAddress("$management");
    message.setApplicationProperties(new ApplicationProperties(properties));
    message.setBody(new AmqpValue(body));

    try {
        Message response = client.request(message, 10, TimeUnit.SECONDS);
        AmqpValue value = (AmqpValue) response.getBody();
        Map values = (Map) value.getValue();
        List<List<String>> results = (List<List<String>>) values.get("results");
        return results.stream().map(l -> l.get(0)).collect(Collectors.toList());
    } catch (Exception e) {
        log.info("Error requesting router status. Ignoring", e);
        eventLogger.log(RouterCheckFailed, e.getMessage(), Warning, AddressSpace, addressSpaceName);
        return Collections.emptyList();
    }
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:26,代码来源:AddressController.java

示例4: getSubscriberCount

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Override
public int getSubscriberCount(AmqpClient queueClient, Destination replyQueue, String queue) throws Exception {
    Message requestMessage = Message.Factory.create();
    Map<String, String> appProperties = new HashMap<>();
    appProperties.put(resourceProperty, "queue." + queue);
    appProperties.put(operationProperty, "getConsumerCount");
    requestMessage.setAddress(managementAddress);
    requestMessage.setApplicationProperties(new ApplicationProperties(appProperties));
    requestMessage.setReplyTo(replyQueue.getAddress());
    requestMessage.setBody(new AmqpValue("[]"));

    Future<Integer> sent = queueClient.sendMessages(managementAddress, requestMessage);
    assertThat(sent.get(30, TimeUnit.SECONDS), is(1));
    Logging.log.info("request sent");

    Future<List<Message>> received = queueClient.recvMessages(replyQueue.getAddress(), 1);
    assertThat(received.get(30, TimeUnit.SECONDS).size(), is(1));


    AmqpValue val = (AmqpValue) received.get().get(0).getBody();
    Logging.log.info("answer received: " + val.toString());
    String count = val.getValue().toString().replaceAll("\\[|]|\"", "");

    return Integer.valueOf(count);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:26,代码来源:ArtemisManagement.java

示例5: benchmarkApplicationProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void benchmarkApplicationProperties() throws IOException {
    ApplicationProperties properties = new ApplicationProperties(new HashMap<String, Object>());
    properties.getValue().put("test1", UnsignedByte.valueOf((byte) 128));
    properties.getValue().put("test2", UnsignedShort.valueOf((short) 128));
    properties.getValue().put("test3", UnsignedInteger.valueOf((byte) 128));

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

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

    time("ApplicationProperties", resultSet);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:24,代码来源:Benchmark.java

示例6: testAMQP_to_JSON_VerifyApplicationPropertySymbol

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
/**
 * Verifies that a Symbol application property is converted to a String [by the JsonObject]
 */
@Test
public void testAMQP_to_JSON_VerifyApplicationPropertySymbol() {
  Map<String, Object> props = new HashMap<>();
  ApplicationProperties appProps = new ApplicationProperties(props);

  String symbolPropKey = "symbolPropKey";
  Symbol symbolPropValue = Symbol.valueOf("symbolPropValue");

  props.put(symbolPropKey, symbolPropValue);

  Message protonMsg = Proton.message();
  protonMsg.setApplicationProperties(appProps);

  JsonObject jsonObject = translator.convertToJsonObject(protonMsg);
  assertNotNull("expected converted msg", jsonObject);
  assertTrue("expected application properties element key to be present",
      jsonObject.containsKey(AmqpConstants.APPLICATION_PROPERTIES));

  JsonObject jsonAppProps = jsonObject.getJsonObject(AmqpConstants.APPLICATION_PROPERTIES);
  assertNotNull("expected application properties element value to be non-null", jsonAppProps);

  assertTrue("expected key to be present", jsonAppProps.containsKey(symbolPropKey));
  assertEquals("expected value to be equal, as a string", symbolPropValue.toString(),
      jsonAppProps.getValue(symbolPropKey));
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:29,代码来源:MessageTranslatorImplTest.java

示例7: getApplicationPropertiesMap

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<String, Object> getApplicationPropertiesMap() {
   ApplicationProperties appMap = getApplicationProperties();
   Map<String, Object> map = null;

   if (appMap != null) {
      map = appMap.getValue();
   }

   if (map == null) {
      map = new HashMap<>();
      this.applicationProperties = new ApplicationProperties(map);
   }

   return map;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:AMQPMessage.java

示例8: getApplicationProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
private ApplicationProperties getApplicationProperties() {
   parseHeaders();

   if (applicationProperties == null && appLocation >= 0) {
      ByteBuffer buffer = getBuffer().nioBuffer();
      buffer.position(appLocation);
      TLSEncode.getDecoder().setByteBuffer(buffer);
      Object section = TLSEncode.getDecoder().readObject();
      if (section instanceof ApplicationProperties) {
         this.applicationProperties = (ApplicationProperties) section;
      }
      this.appLocation = -1;
      TLSEncode.getDecoder().setByteBuffer(null);
   }

   return applicationProperties;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:AMQPMessage.java

示例9: createTypicalQpidJMSMessage

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
private Message createTypicalQpidJMSMessage() {
   Map<String, Object> applicationProperties = new HashMap<>();
   Map<Symbol, Object> messageAnnotations = new HashMap<>();

   applicationProperties.put("property-1", "string");
   applicationProperties.put("property-2", 512);
   applicationProperties.put("property-3", true);

   messageAnnotations.put(Symbol.valueOf("x-opt-jms-msg-type"), 0);
   messageAnnotations.put(Symbol.valueOf("x-opt-jms-dest"), 0);

   Message message = Proton.message();

   message.setAddress("queue://test-queue");
   message.setDeliveryCount(1);
   message.setApplicationProperties(new ApplicationProperties(applicationProperties));
   message.setMessageAnnotations(new MessageAnnotations(messageAnnotations));
   message.setCreationTime(System.currentTimeMillis());
   message.setContentType("text/plain");
   message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));

   return message;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:JMSTransformationSpeedComparisonTest.java

示例10: testSimpleConversionStream

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testSimpleConversionStream() throws Exception {
   Map<String, Object> mapprop = createPropertiesMap();
   ApplicationProperties properties = new ApplicationProperties(mapprop);
   MessageImpl message = (MessageImpl) Message.Factory.create();
   message.setApplicationProperties(properties);

   List<Object> objects = new LinkedList<>();
   objects.add(new Integer(10));
   objects.add("10");

   message.setBody(new AmqpSequence(objects));

   AMQPMessage encodedMessage = new AMQPMessage(message);

   ICoreMessage serverMessage = encodedMessage.toCore();

   ServerJMSStreamMessage streamMessage = (ServerJMSStreamMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);

   verifyProperties(streamMessage);

   streamMessage.reset();

   assertEquals(10, streamMessage.readInt());
   assertEquals("10", streamMessage.readString());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:TestConversions.java

示例11: testVerySimple

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testVerySimple() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader( new Header());
   Properties properties = new Properties();
   properties.setTo("someNiceLocal");
   protonMessage.setProperties(properties);
   protonMessage.getHeader().setDeliveryCount(new UnsignedInteger(7));
   protonMessage.getHeader().setDurable(Boolean.TRUE);
   protonMessage.setApplicationProperties(new ApplicationProperties(new HashMap()));

   AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);

   assertEquals(7, decoded.getHeader().getDeliveryCount().intValue());
   assertEquals(true, decoded.getHeader().getDurable());
   assertEquals("someNiceLocal", decoded.getAddress());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:AMQPMessageTest.java

示例12: testSendProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testSendProperties() throws Exception {
   ProtonFactoryLoader<MessengerFactory> factoryLoader = new ProtonFactoryLoader(MessengerFactory.class, ImplementationType.PROTON_J);
   ProtonFactoryLoader<MessageFactory> messageLoader = new ProtonFactoryLoader(MessageFactory.class, ImplementationType.PROTON_J);
   MessengerFactory factory = factoryLoader.loadFactory();
   MessageFactory msgFactory = messageLoader.loadFactory();
   Messenger messenger = factory.createMessenger("testSendBytes");
   messenger.start();
   Message msg = msgFactory.createMessage();
   //msg.setAddress("amqp://192.168.1.107:5672/topic://beaconEvents");
   msg.setAddress("amqp://192.168.1.107:5672/beaconEvents");
   Beacon beacon = createBeacon();
   Map<String, Object> beaconProps = beacon.toProperties();
   msg.setApplicationProperties(new ApplicationProperties(beaconProps));
   messenger.put(msg);

   messenger.send();
   messenger.stop();
}
 
开发者ID:starksm64,项目名称:RaspberryPiBeaconParser,代码行数:20,代码来源:TestSendRecv.java

示例13: testGetProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testGetProperties() throws Exception {
    Map<String, Object> applicationPropertiesMap = new HashMap<>();
    applicationPropertiesMap.put(TEST_PROP_A, TEST_VALUE_STRING_A);
    applicationPropertiesMap.put(TEST_PROP_B, TEST_VALUE_STRING_B);

    Message message2 = Proton.message();
    message2.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap));

    JmsMessageFacade amqpMessageFacade = createReceivedMessageFacade(createMockAmqpConsumer(), message2);

    Set<String> props = amqpMessageFacade.getPropertyNames();
    assertEquals(2, props.size());
    assertTrue(props.contains(TEST_PROP_A));
    assertEquals(TEST_VALUE_STRING_A, amqpMessageFacade.getProperty(TEST_PROP_A));
    assertTrue(props.contains(TEST_PROP_B));
    assertEquals(TEST_VALUE_STRING_B, amqpMessageFacade.getProperty(TEST_PROP_B));
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:19,代码来源:AmqpJmsMessageFacadeTest.java

示例14: testGetPropertyNames

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testGetPropertyNames() throws Exception {
    Map<String, Object> applicationPropertiesMap = new HashMap<>();
    applicationPropertiesMap.put(TEST_PROP_A, TEST_VALUE_STRING_A);
    applicationPropertiesMap.put(TEST_PROP_B, TEST_VALUE_STRING_B);

    Message message2 = Proton.message();
    message2.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap));

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

    Set<String> applicationPropertyNames = amqpMessageFacade.getPropertyNames();
    assertEquals(2, applicationPropertyNames.size());
    assertTrue(applicationPropertyNames.contains(TEST_PROP_A));
    assertTrue(applicationPropertyNames.contains(TEST_PROP_B));
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:AmqpJmsMessageFacadeTest.java

示例15: testClearProperties

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; //导入依赖的package包/类
@Test
public void testClearProperties() throws Exception {
    Map<String, Object> applicationPropertiesMap = new HashMap<>();
    applicationPropertiesMap.put(TEST_PROP_A, TEST_VALUE_STRING_A);

    Message message = Proton.message();
    message.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap));

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

    Set<String> props1 = amqpMessageFacade.getPropertyNames();
    assertEquals(1, props1.size());

    amqpMessageFacade.clearProperties();

    Set<String> props2 = amqpMessageFacade.getPropertyNames();
    assertTrue(props2.isEmpty());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:19,代码来源:AmqpJmsMessageFacadeTest.java


注:本文中的org.apache.qpid.proton.amqp.messaging.ApplicationProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。