/** * Adds a property indicating a device's <em>time until disconnect</em> property to an AMQP 1.0 message. * <p> * The value is put to the message's <em>application-properties</em> under key {@link #APP_PROPERTY_DEVICE_TTD}. * * @param msg The message to add the property to. * @param timeUntilDisconnect The value of the property (number of seconds). */ public static void addTimeUntilDisconnect(final Message msg, final int timeUntilDisconnect) { addProperty(msg, APP_PROPERTY_DEVICE_TTD, timeUntilDisconnect); }
/** * Adds a tenant ID to a message's <em>application properties</em>. * <p> * The name of the application property is {@link #APP_PROPERTY_TENANT_ID}. * * @param msg The message. * @param tenantId The tenant identifier to add. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addTenantId(final Message msg, final String tenantId) { addProperty(msg, APP_PROPERTY_TENANT_ID, tenantId); }
/** * Adds a tenant ID to a message's <em>application properties</em>. * <p> * The name of the application property is {@link #APP_PROPERTY_TENANT_ID}. * * @param msg The message. * @param tenantId The tenant identifier to add. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addTenantId(final Message msg, final String tenantId) { addProperty(msg, APP_PROPERTY_TENANT_ID, tenantId); }
/** * Adds a property indicating a device's <em>time until disconnect</em> property to an AMQP 1.0 message. * <p> * The value is put to the message's <em>application-properties</em> under key {@link #APP_PROPERTY_DEVICE_TTD}. * * @param msg The message to add the property to. * @param timeUntilDisconnect The value of the property (number of seconds). */ public static void addTimeUntilDisconnect(final Message msg, final int timeUntilDisconnect) { addProperty(msg, APP_PROPERTY_DEVICE_TTD, timeUntilDisconnect); }
/** * Adds a registration assertion to an AMQP 1.0 message. * <p> * The assertion is put to the message's <em>application-properties</em> under key * {@link #APP_PROPERTY_REGISTRATION_ASSERTION}. * * @param msg The message. * @param token The assertion to add. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addRegistrationAssertion(final Message msg, final String token) { addProperty(msg, APP_PROPERTY_REGISTRATION_ASSERTION, token); }
/** * Adds a device ID to a message's <em>application properties</em>. * <p> * The name of the application property is {@link #APP_PROPERTY_DEVICE_ID}. * * @param msg The message. * @param deviceId The device identifier to add. * @throws NullPointerException if any of the parameters are {@code null}. * */ public static void addDeviceId(final Message msg, final String deviceId) { addProperty(msg, APP_PROPERTY_DEVICE_ID, deviceId); }
/** * Adds a device ID to a message's <em>application properties</em>. * <p> * The name of the application property is {@link #APP_PROPERTY_DEVICE_ID}. * * @param msg The message. * @param deviceId The device identifier to add. * @throws NullPointerException if any of the parameters are {@code null}. * */ public static void addDeviceId(final Message msg, final String deviceId) { addProperty(msg, APP_PROPERTY_DEVICE_ID, deviceId); }
/** * Adds a registration assertion to an AMQP 1.0 message. * <p> * The assertion is put to the message's <em>application-properties</em> under key * {@link #APP_PROPERTY_REGISTRATION_ASSERTION}. * * @param msg The message. * @param token The assertion to add. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addRegistrationAssertion(final Message msg, final String token) { addProperty(msg, APP_PROPERTY_REGISTRATION_ASSERTION, token); }
/** * Adds a caching directive to an AMQP 1.0 message. * <p> * The directive is put to the message's <em>application-properties</em> under key * {@link #APP_PROPERTY_CACHE_CONTROL}. * * @param msg The message to add the directive to. * @param cacheDirective The cache directive. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addCacheDirective(final Message msg, final CacheDirective cacheDirective) { addProperty(msg, APP_PROPERTY_CACHE_CONTROL, cacheDirective.toString()); }
/** * Adds a caching directive to an AMQP 1.0 message. * <p> * The directive is put to the message's <em>application-properties</em> under key * {@link #APP_PROPERTY_CACHE_CONTROL}. * * @param msg The message to add the directive to. * @param cacheDirective The cache directive. * @throws NullPointerException if any of the parameters are {@code null}. */ public static void addCacheDirective(final Message msg, final CacheDirective cacheDirective) { addProperty(msg, APP_PROPERTY_CACHE_CONTROL, cacheDirective.toString()); }
default: MessageHelper.addProperty(message, prop.getKey(), prop.getValue());
default: MessageHelper.addProperty(message, prop.getKey(), prop.getValue());
/** * Adds JMS vendor properties defined by * <a href="https://www.oasis-open.org/committees/download.php/60574/amqp-bindmap-jms-v1.0-wd09.pdf"> AMQP JMS * Mapping 1.0</a> as AMQP 1.0 application properties to a given message. * <p> * The following vendor properties are added (if the message has a corresponding non-null value set): * <ul> * <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_TYPE}</li> * <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_ENCODING}</li> * </ul> * * @param msg the message to add the vendor properties to. */ public static void addJmsVendorProperties(final Message msg) { if (!Strings.isNullOrEmpty(msg.getContentType())) { MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_TYPE, msg.getContentType()); } if (!Strings.isNullOrEmpty(msg.getContentEncoding())) { MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_ENCODING, msg.getContentEncoding()); } }
/** * Adds JMS vendor properties defined by * <a href="https://www.oasis-open.org/committees/download.php/60574/amqp-bindmap-jms-v1.0-wd09.pdf"> AMQP JMS * Mapping 1.0</a> as AMQP 1.0 application properties to a given message. * <p> * The following vendor properties are added (if the message has a corresponding non-null value set): * <ul> * <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_TYPE}</li> * <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_ENCODING}</li> * </ul> * * @param msg the message to add the vendor properties to. */ public static void addJmsVendorProperties(final Message msg) { if (!Strings.isNullOrEmpty(msg.getContentType())) { MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_TYPE, msg.getContentType()); } if (!Strings.isNullOrEmpty(msg.getContentEncoding())) { MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_ENCODING, msg.getContentEncoding()); } }
private static Message createResponseMessage( final String targetAddress, final String correlationId, final String contentType, final Buffer payload, final Map<String, Object> properties, final int status) { Objects.requireNonNull(targetAddress); Objects.requireNonNull(correlationId); final Message msg = ProtonHelper.message(); msg.setCorrelationId(correlationId); msg.setAddress(targetAddress); MessageHelper.setPayload(msg, contentType, payload); if (properties != null) { msg.setApplicationProperties(new ApplicationProperties(properties)); } MessageHelper.setCreationTime(msg); MessageHelper.addProperty(msg, MessageHelper.APP_PROPERTY_STATUS, status); return msg; }
@Override public final void onLinkAttach(final ProtonConnection con, final ProtonSender sender, final ResourceIdentifier targetResource) { if (ProtonQoS.AT_LEAST_ONCE.equals(sender.getRemoteQoS())) { final HonoUser user = Constants.getClientPrincipal(con); sender.setQoS(ProtonQoS.AT_LEAST_ONCE).open(); logger.debug("transferring token to client..."); final Message tokenMsg = ProtonHelper.message(user.getToken()); MessageHelper.addProperty(tokenMsg, AuthenticationConstants.APPLICATION_PROPERTY_TYPE, AuthenticationConstants.TYPE_AMQP_JWT); sender.send(tokenMsg, disposition -> { if (disposition.remotelySettled()) { logger.debug("successfully transferred auth token to client"); } else { logger.debug("failed to transfer auth token to client"); } sender.close(); }); } else { onLinkDetach(sender, ProtonHelper.condition(AmqpError.INVALID_FIELD, "supports AT_LEAST_ONCE delivery mode only")); } }
MessageHelper.addProperty(msg, MessageHelper.APP_PROPERTY_ORIG_ADDRESS, publishAddress);
/** * Verifies that {@link TenantMessageFilter#verify(ResourceIdentifier, Message)} succeeds for a valid message. */ @Test public void testVerifySucceedsForValidGetAction() { // GIVEN a tenant GET message for tenant DEFAULT_TENANT final Message msg = givenAMessageHavingProperties(TenantConstants.TenantAction.get); MessageHelper.addProperty(msg, APP_PROPERTY_TENANT_ID, DEFAULT_TENANT); // WHEN receiving the message via a link with matching target address final ResourceIdentifier linkTarget = getResourceIdentifier(DEFAULT_TENANT); // THEN message validation succeeds assertTrue(TenantMessageFilter.verify(linkTarget, msg)); }
MessageHelper.addRegistrationAssertion(message, registrationAssertion); MessageHelper.addProperty(message, MessageHelper.APP_PROPERTY_ORIG_ADAPTER, getTypeName()); if (getConfig().isDefaultsEnabled()) { final JsonObject defaults = registrationInfo.getJsonObject(RegistrationConstants.FIELD_DEFAULTS);
MessageHelper.addRegistrationAssertion(message, registrationAssertion); MessageHelper.addProperty(message, MessageHelper.APP_PROPERTY_ORIG_ADAPTER, getTypeName()); if (getConfig().isDefaultsEnabled()) { final JsonObject defaults = registrationInfo.getJsonObject(RegistrationConstants.FIELD_DEFAULTS);