Java Code Examples for org.apache.qpid.proton.message.Message#getApplicationProperties()

The following examples show how to use org.apache.qpid.proton.message.Message#getApplicationProperties() . 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: MessageHelper.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
private static String getRegistrationAssertion(final Message msg, final boolean removeAssertion) {
    Objects.requireNonNull(msg);
    String assertion = null;
    final ApplicationProperties properties = msg.getApplicationProperties();
    if (properties != null) {
        final Object obj;
        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;
}
 
Example 2
Source File: ProtonRequestClient.java    From enmasse with Apache License 2.0 6 votes vote down vote up
public Message request(Message message, long timeout, TimeUnit timeUnit) {
    Map<String, Object> properties = new HashMap<>();
    if (message.getApplicationProperties() != null) {
        properties.putAll(message.getApplicationProperties().getValue());
    }
    message.setApplicationProperties(new ApplicationProperties(properties));

    if (message.getReplyTo() == null) {
        message.setReplyTo(replyTo);
    }
    context.runOnContext(h -> sender.send(message));
    try {
        return replies.poll(timeout, timeUnit);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
Example 3
Source File: AmqpMessage.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new AmqpMessage that wraps the information necessary to handle
 * an incoming delivery.
 *
 * @param receiver the AmqpReceiver that received this message.
 * @param message  the Proton message that was received.
 * @param delivery the Delivery instance that produced this message.
 */
@SuppressWarnings("unchecked")
public AmqpMessage(AmqpReceiver receiver, Message message, Delivery delivery) {
   this.receiver = receiver;
   this.message = message;
   this.delivery = delivery;

   if (message.getMessageAnnotations() != null) {
      messageAnnotationsMap = message.getMessageAnnotations().getValue();
   }

   if (message.getApplicationProperties() != null) {
      applicationPropertiesMap = message.getApplicationProperties().getValue();
   }

   if (message.getDeliveryAnnotations() != null) {
      deliveryAnnotationsMap = message.getDeliveryAnnotations().getValue();
   }
}
 
Example 4
Source File: Receiver.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Handle received message.
 *
 * Write log messages to stdout.
 *
 * @param endpoint receiving endpoint, "telemetry" or "event".
 * @param msg received message
 */
private void handleMessage(final String endpoint, final Message msg) {
    final String deviceId = MessageHelper.getDeviceId(msg);

    final Buffer payload = MessageHelper.getPayload(msg);

    log.info("received {} message [device: {}, content-type: {}]: {}", endpoint, deviceId, msg.getContentType(),
            payload);

    if (msg.getApplicationProperties() != null) {
        log.info("... with application properties: {}", msg.getApplicationProperties().getValue());
    }
}
 
Example 5
Source File: ReceiverStatistics.java    From hono with Eclipse Public License 2.0 4 votes vote down vote up
private void handleMessage(final String endpoint, final Message msg) {
    final String deviceId = MessageHelper.getDeviceId(msg);

    final Buffer payload = MessageHelper.getPayload(msg);

    if (LOG_STATISTIC.isInfoEnabled()) {
        final long now = System.nanoTime();
        final Statistic total;
        Statistic current;
        synchronized (this) {
            if (this.total == null) {
                this.total = new Statistic(now);
            }
            total = this.total;
            if (this.current == null) {
                this.current = new PeriodStatistic(now, interval);
            }
            current = this.current;
        }
        total.increment(now);
        if (!current.increment(now)) {
            if (current.isPrinting()) {
                LOG_STATISTIC.info("statistic: total {}, last {}", total, current);
            }
            synchronized (this) {
                if (this.current == current) {
                    this.current = new PeriodStatistic(now, interval);
                }
                current = this.current;
            }
            current.increment(now);
        }
    }

    LOG_STATISTIC.trace("received {} message [device: {}, content-type: {}]: {}", endpoint, deviceId, msg.getContentType(),
            payload);

    if (msg.getApplicationProperties() != null) {
        LOG_STATISTIC.trace("... with application properties: {}", msg.getApplicationProperties().getValue());
    }
}