Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11225

Deadlock in component creation

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      There are circumstances in which the component creation could enter in a deadlock, let's have a look at the following spring example:

      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
               http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
               http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
       
        <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
          <route id="twitter-route">
            <from id="twitter" uri="twitter://timeline/home?type=polling"/>
            <log id="route-log" message="Got ${body}"/>
          </route>
        </camelContext>
       
      </beans>
      

      The critical part is:

        <from id="twitter" uri="twitter://timeline/home?type=polling"/>
      

      What happens is that:

      • because there is an id, camel registers a CamelEndpointFactoryBean to the spring application contex
      • the endpoint is then resolved which involve the instantiation of the component (twitter in this case) which invoke CamelContext.getComponent
      • when the component is being created it then uses the component resolver which goes down to the registry to find out if the requested component is already there
      • as in the registry there is a bean factory with the same name as the component we want to create, spring invokes the factory which then goes down to CamelContext.getComponent
      • then deadlock

      Attachments

        Activity

          People

            lb Luca Burgazzoli
            lb Luca Burgazzoli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: