@Override @SuppressWarnings("unchecked") public AccurestMessage<T, Message> receiveMessage(String destination, long timeout, TimeUnit timeUnit) { try { ConsumerTemplate consumerTemplate = context.createConsumerTemplate(); Exchange exchange = consumerTemplate.receive(destination, timeUnit.toMillis(timeout)); return builder.create(exchange.getIn()); } catch (Exception e) { log.error("Exception occurred while trying to read a message from " + " a channel with name [" + destination + "]", e); throw new RuntimeException(e); } }
@Override public Message receive(TestContext context, long timeout) { if (log.isDebugEnabled()) { log.debug("Receiving message from camel endpoint: '" + endpointConfiguration.getEndpointUri() + "'"); } Exchange exchange = getConsumerTemplate().receive(endpointConfiguration.getEndpointUri(), timeout); if (exchange == null) { throw new ActionTimeoutException("Action timed out while receiving message from camel endpoint '" + endpointConfiguration.getEndpointUri() + "'"); } log.info("Received message from camel endpoint: '" + endpointConfiguration.getEndpointUri() + "'"); Message message = endpointConfiguration.getMessageConverter().convertInbound(exchange, endpointConfiguration, context); context.onInboundMessage(message); return message; }
@Override public Message receive(TestContext context, long timeout) { if (log.isDebugEnabled()) { log.debug("Receiving message from camel endpoint: '" + endpointConfiguration.getEndpointUri() + "'"); } Exchange exchange = getConsumerTemplate().receive(endpointConfiguration.getEndpointUri(), timeout); if (exchange == null) { throw new ActionTimeoutException("Action timed out while receiving message from camel endpoint '" + endpointConfiguration.getEndpointUri() + "'"); } log.info("Received message from camel endpoint: '" + endpointConfiguration.getEndpointUri() + "'"); Message message = endpointConfiguration.getMessageConverter().convertInbound(exchange, endpointConfiguration, context); context.onInboundMessage(message); String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()); String correlationKey = endpointConfiguration.getCorrelator().getCorrelationKey(message); correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, exchange); return message; }