Yuliya Tararueva
Yuliya Tararueva

Reputation: 1

Spring integration - failed to look up MessageChannel with name '55774d05-e054-4b71-bc7e-ecc53d029e75:20' in the BeanFactory

I have a Spring boot project with spring-integration. As far as I understand, it uses a Scatter-Gather pattern:

@Bean
public IntegrationFlow getClientsFlow() {
    return IntegrationFlows.from(FIND_CLIENTS_INPUT_CHANNEL_NAME)
            .transform(inputMessageConfigurer())
            .scatterGather(
                scatterer -> scatterer.applySequence(true)
                    .recipient(ONE_FLOW_CHANNEL_NAME)
                    .recipient(TWO_FLOW_CHANNEL_NAME),
                gatherer -> gatherer
                    .releaseStrategy(
                            new MessageCountReleaseStrategy(2))
                    .messageStore(new SimpleMessageStore()).outputProcessor(messageGroup -> {
                        List<TWOClient> twoClients = getMessagePayloadWithType(messageGroup,
                                TWO_MESSAGE_TYPE);
                        List<ONEClientAccount> oneClientAccounts = getMessagePayloadWithType(
                                messageGroup, ONE_MESSAGE_TYPE);
                        ClientAggregator aggregator = new ClientAggregator(twoClients,
                                oneClientAccounts);
                        return MessageBuilder.withPayload(aggregator.aggregateClients())
                                .copyHeaders(messageGroup.getOne().getHeaders()).build();
                    }))
            .get();
}

It works fine, but sometimes there is an error in logs:

[17.08.20 10:53:51:724 SAMT] 00000373 LoggingHandle I org.springframework.integration.handler.LoggingHandler handleMessageInternal GenericMessage [payload=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:searchResult
...
</ns2:searchResult>
, headers={gatherResultChannel=55774d05-e054-4b71-bc7e-ecc53d029e75:20, sequenceDetails=[[0f92a717-b48b-bb4b-ee44-c1198b7301ed, 0, 0]], ... }]

[17.08.20 10:54:17:916 SAMT] 00000373 LoggingHandle E org.springframework.integration.handler.LoggingHandler handleMessageInternal [Request id: e13472c747b64e299f627ba541e6b367] - failed to look up MessageChannel with name '55774d05-e054-4b71-bc7e-ecc53d029e75:20' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '55774d05-e054-4b71-bc7e-ecc53d029e75:20' available
[17.08.20 10:54:17:916 SAMT] 00000373 SystemErr     R org.springframework.messaging.MessagingException: Failed to handle Message; nested exception is org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name '55774d05-e054-4b71-bc7e-ecc53d029e75:20' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '55774d05-e054-4b71-bc7e-ecc53d029e75:20' available, failedMessage=GenericMessage, headers={gatherResultChannel=55774d05-e054-4b71-bc7e-ecc53d029e75:20, .... }]
[17.08.20 10:54:17:918 SAMT] 00000373 SystemErr     R   at org.springframework.integration.channel.FixedSubscriberChannel.send(FixedSubscriberChannel.java:76)
[17.08.20 10:54:17:918 SAMT] 00000373 SystemErr     R   at org.springframework.integration.channel.FixedSubscriberChannel.send(FixedSubscriberChannel.java:64)
[17.08.20 10:54:17:918 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:181)
[17.08.20 10:54:17:918 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:160)
[17.08.20 10:54:17:918 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:108)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:426)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:336)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:227)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler.completeGroup(AbstractCorrelatingMessageHandler.java:747)
[17.08.20 10:54:17:919 SAMT] 00000373 SystemErr     R   at org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler.handleMessageInternal(AbstractCorrelatingMessageHandler.java:439)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:158)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.integration.channel.FixedSubscriberChannel.send(FixedSubscriberChannel.java:70)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.integration.channel.FixedSubscriberChannel.send(FixedSubscriberChannel.java:64)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:181)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:160)
[17.08.20 10:54:17:920 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)
...
[17.08.20 10:54:17:972 SAMT] 00000373 SystemErr     R Caused by: org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name '55774d05-e054-4b71-bc7e-ecc53d029e75:20' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '55774d05-e054-4b71-bc7e-ecc53d029e75:20' available
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:117)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:46)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.resolveDestination(AbstractDestinationResolvingMessagingTemplate.java:76)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.send(AbstractDestinationResolvingMessagingTemplate.java:69)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.integration.scattergather.ScatterGatherHandler.lambda$doInit$0(ScatterGatherHandler.java:120)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.integration.scattergather.ScatterGatherHandler$$Lambda$496/000000002B45D160.handleMessage(Unknown Source)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   at org.springframework.integration.channel.FixedSubscriberChannel.send(FixedSubscriberChannel.java:70)
[17.08.20 10:54:17:973 SAMT] 00000373 SystemErr     R   ... 277 more
[17.08.20 10:54:17:974 SAMT] 00000373 SystemErr     R Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '55774d05-e054-4b71-bc7e-ecc53d029e75:20' available
[17.08.20 10:54:18:002 SAMT] 00000373 SystemErr     R   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:688)
[17.08.20 10:54:18:002 SAMT] 00000373 SystemErr     R   at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1218)
[17.08.20 10:54:18:003 SAMT] 00000373 SystemErr     R   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
[17.08.20 10:54:18:003 SAMT] 00000373 SystemErr     R   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
[17.08.20 10:54:18:003 SAMT] 00000373 SystemErr     R   at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:89)
[17.08.20 10:54:18:003 SAMT] 00000373 SystemErr     R   ... 283 more

What could be the reason for this error? Perhaps there is a timeout after which bean is destroyed. Can I change it?

Upvotes: 0

Views: 1000

Answers (2)

Artem Bilan
Artem Bilan

Reputation: 121177

55774d05-e054-4b71-bc7e-ecc53d029e75:20

This is an UUID from the HeaderChannelRegistry:

if (channel instanceof MessageChannel) {
        String name = this.uuid + id.incrementAndGet();

Looks like there is some header enricher in your configuration which does something like this:

/**
 * Add header specifications to automatically convert header channels (reply, error
 * channels) to Strings and store them in a header channel registry. Allows
 * persistence and serialization of messages without losing these important framework
 * headers.
 * @param timeToLiveExpression the minimum time that the mapping will remain in the registry.
 * @return the header enricher spec.
 * @see org.springframework.integration.support.channel.HeaderChannelRegistry
 */
public HeaderEnricherSpec headerChannelsToString(String timeToLiveExpression) {

So, you are right: there is a timeout to remove those entries from the registry for the replyChannel header and it is not enough for your logic.

Although it is not clear if you still need that headerChannelsToString() option anyway.

See docs for more info: https://docs.spring.io/spring-integration/docs/current/reference/html/message-transformation.html#header-channel-registry

Upvotes: 2

pratik
pratik

Reputation: 21

Try this increase timeToLiveExpression

@Bean
  public IntegrationFlow verifyUtilityIntegrationFlow() {
    return IntegrationFlows.from(verifyUtilityHttpGateway())
      .enrichHeaders(h -> h.headerChannelsToString("200000"))
      .get();
  }

Upvotes: 0

Related Questions