@SuppressWarnings("unchecked") @Override @Nullable protected List<List<Object>> getSequenceDetails() { return (List<List<Object>>) this.headerAccessor.getHeader(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS); }
/** * Return the acknowledgment callback, if present. * @return the callback. * @since 5.0.1 */ @Nullable public AcknowledgmentCallback getAcknowledgmentCallback() { return getHeader(ACKNOWLEDGMENT_CALLBACK, AcknowledgmentCallback.class); }
/** * When a message-driven endpoint supports retry implicitly, this * header is incremented for each delivery attempt. * @return the delivery attempt. * @since 5.0.1 */ @Nullable public AtomicInteger getDeliveryAttempt() { return getHeader(DELIVERY_ATTEMPT, AtomicInteger.class); }
public int getSequenceSize() { Number sequenceSize = getHeader(SEQUENCE_SIZE, Number.class); return (sequenceSize != null ? sequenceSize.intValue() : 0); }
/** * If the payload was created by a {@link Closeable} that needs to remain * open until the payload is consumed, the resource will be added to this * header. After the payload is consumed the {@link Closeable} should be * closed. Usually this must occur in an endpoint close to the message * origin in the flow, and in the same JVM. * @return the {@link Closeable}. * @since 4.3 */ @Nullable public Closeable getCloseableResource() { return getHeader(CLOSEABLE_RESOURCE, Closeable.class); }
@Nullable public Object getCorrelationId() { return getHeader(CORRELATION_ID); }
@Nullable public Long getExpirationDate() { return getHeader(EXPIRATION_DATE, Long.class); }
public int getSequenceNumber() { Number sequenceNumber = getHeader(SEQUENCE_NUMBER, Number.class); return (sequenceNumber != null ? sequenceNumber.intValue() : 0); }
@Nullable public Integer getPriority() { Number priority = getHeader(PRIORITY, Number.class); return (priority != null ? priority.intValue() : null); }
@SuppressWarnings("unchecked") @Nullable public <T> T getHeader(String key, Class<T> type) { Object value = getHeader(key); if (value == null) { return null; } if (!type.isAssignableFrom(value.getClass())) { throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type + "] but actual type is [" + value.getClass() + "]"); } return (T) value; }
@Test public void testRoutingSlip() { MessagingTemplate template = new MessagingTemplate(); MessageChannel channel = context.getBean("routingSlipInput", MessageChannel.class); Message<?> result = template.sendAndReceive(channel, new GenericMessage<>("test")); assertNotNull(result); Object routingSlip = new IntegrationMessageHeaderAccessor(result) .getHeader(IntegrationMessageHeaderAccessor.ROUTING_SLIP); assertNotNull(routingSlip); assertThat(routingSlip, instanceOf(Map.class)); @SuppressWarnings("unchecked") List<Object> routingSlipPath = (List<Object>) ((Map<?, ?>) routingSlip).keySet().iterator().next(); assertEquals("fooChannel", routingSlipPath.get(0)); assertThat(routingSlipPath.get(1), instanceOf(ExpressionEvaluatingRoutingSlipRouteStrategy.class)); assertEquals("bazRoutingSlip", routingSlipPath.get(2)); }
/** * When a message-driven endpoint supports retry implicitly, this * header is incremented for each delivery attempt. * @return the delivery attempt. * @since 5.0.1 */ @Nullable public AtomicInteger getDeliveryAttempt() { return getHeader(DELIVERY_ATTEMPT, AtomicInteger.class); }
@SuppressWarnings("unchecked") @Override @Nullable protected List<List<Object>> getSequenceDetails() { return (List<List<Object>>) this.headerAccessor.getHeader(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS); }
/** * Return the acknowledgment callback, if present. * @return the callback. * @since 5.0.1 */ @Nullable public AcknowledgmentCallback getAcknowledgmentCallback() { return getHeader(ACKNOWLEDGMENT_CALLBACK, AcknowledgmentCallback.class); }
@Nullable public Object getCorrelationId() { return getHeader(CORRELATION_ID); }
@Nullable public Long getExpirationDate() { return getHeader(EXPIRATION_DATE, Long.class); }
/** * If the payload was created by a {@link Closeable} that needs to remain * open until the payload is consumed, the resource will be added to this * header. After the payload is consumed the {@link Closeable} should be * closed. Usually this must occur in an endpoint close to the message * origin in the flow, and in the same JVM. * @return the {@link Closeable}. * @since 4.3 */ @Nullable public Closeable getCloseableResource() { return getHeader(CLOSEABLE_RESOURCE, Closeable.class); }
public int getSequenceSize() { Number sequenceSize = getHeader(SEQUENCE_SIZE, Number.class); return (sequenceSize != null ? sequenceSize.intValue() : 0); }
@Nullable public Integer getPriority() { Number priority = getHeader(PRIORITY, Number.class); return (priority != null ? priority.intValue() : null); }
@SuppressWarnings("unchecked") @Nullable public <T> T getHeader(String key, Class<T> type) { Object value = getHeader(key); if (value == null) { return null; } if (!type.isAssignableFrom(value.getClass())) { throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type + "] but actual type is [" + value.getClass() + "]"); } return (T) value; }