/** * Adds several AMQP 1.0 message <em>annotations</em> to the given message that are used to process/route the * message. * <p> * In particular, the following annotations are added: * <ul> * <li>{@link #APP_PROPERTY_TENANT_ID} - the tenant ID segment of the resource identifier</li> * <li>{@link #APP_PROPERTY_DEVICE_ID} - the resource ID segment of the resource identifier (if not * {@code null}</li> * <li>{@link #APP_PROPERTY_RESOURCE} - the full resource path including the endpoint, the tenant and the resource * ID</li> * </ul> * * @param msg the message to add the message annotations to. * @param resourceIdentifier the resource identifier that will be added as annotation. */ public static void annotate(final Message msg, final ResourceIdentifier resourceIdentifier) { MessageHelper.addAnnotation(msg, APP_PROPERTY_TENANT_ID, resourceIdentifier.getTenantId()); if (resourceIdentifier.getResourceId() != null) { MessageHelper.addAnnotation(msg, APP_PROPERTY_DEVICE_ID, resourceIdentifier.getResourceId()); } MessageHelper.addAnnotation(msg, APP_PROPERTY_RESOURCE, resourceIdentifier.toString()); }
/** * Adds several AMQP 1.0 message <em>annotations</em> to the given message that are used to process/route the * message. * <p> * In particular, the following annotations are added: * <ul> * <li>{@link #APP_PROPERTY_TENANT_ID} - the tenant ID segment of the resource identifier</li> * <li>{@link #APP_PROPERTY_DEVICE_ID} - the resource ID segment of the resource identifier (if not * {@code null}</li> * <li>{@link #APP_PROPERTY_RESOURCE} - the full resource path including the endpoint, the tenant and the resource * ID</li> * </ul> * * @param msg the message to add the message annotations to. * @param resourceIdentifier the resource identifier that will be added as annotation. */ public static void annotate(final Message msg, final ResourceIdentifier resourceIdentifier) { MessageHelper.addAnnotation(msg, APP_PROPERTY_TENANT_ID, resourceIdentifier.getTenantId()); if (resourceIdentifier.getResourceId() != null) { MessageHelper.addAnnotation(msg, APP_PROPERTY_DEVICE_ID, resourceIdentifier.getResourceId()); } MessageHelper.addAnnotation(msg, APP_PROPERTY_RESOURCE, resourceIdentifier.toString()); }
private static void addRetainAnnotation(final MqttContext context, final Message downstreamMessage, final Span currentSpan) { if (context.message().isRetain()) { currentSpan.log("device wants to retain message"); MessageHelper.addAnnotation(downstreamMessage, MessageHelper.ANNOTATION_X_OPT_RETAIN, Boolean.TRUE); } }
private static void addRetainAnnotation(final MqttContext context, final Message downstreamMessage, final Span currentSpan) { if (context.message().isRetain()) { currentSpan.log("device wants to retain message"); MessageHelper.addAnnotation(downstreamMessage, MessageHelper.ANNOTATION_X_OPT_RETAIN, Boolean.TRUE); } }