Skip to content

Initialisation of MessageHandler in MessageHandlerChain [INT-756] #4769

Closed

Description

@spring-operator

Nigel Watson opened INT-756 and commented

I've tried using a bean that implements MessageHandler and setOutputChannel in a MessageHandlerChain. I've found that I cannot use MyBean.afterPropertiesSet() to check that the outputChannel is set because the method is getting called before the MessageHandlerChain is initialised (which sets the outputChannel on it's messageHandlers).


Affects: 1.0.2.SR1

Reference URL: http://forum.springsource.org/showthread.php?t=76195

Issue Links:

Activity

  1. spring-operator commented on Aug 20, 2009

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    We might need to create and register BeanDefinitions for the internal MessageChannels when parsing the 'chain' rather than setting these programmatically. If possible, we should address for 1.0.4 (and 2.0)

  2. spring-operator commented on Oct 1, 2009

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    I've experimented with a few options here, but the order of events and the relationship to lifecycle methods is a cyclical problem. In other words, the MessageHandlerChain instance is the one that has the list of handlers set. So, when configuring as beans, the individual handler beans are instantiated (and have their dependencies set) first. The afterPropertiesSet method for each would therefore be called even before those beans are set on the chain bean. The chain then only after receiving the list of handlers creates and sets the output channels.

    There might be a way to control this by creating the channels within the configuration alongside the parsing of the individual handler beans. Then, with the entire process driven at configuration time, it would be possible to set the properties (including input/output channels) on the bean definition. The main problem with that approach is that it would then preclude the possibility of simply instantiating a MessageHandlerChain at runtime and setting a list of handlers on it directly.

    Can you describe more about your need to check the output channel in afterPropertiesSet? Assuming that the MessageHandlerChain is being used and does not have a bug, then the output channel will be set. Is there some other action that you want to drive based on that?

  3. spring-operator commented on Oct 1, 2009

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    Moving to 2.0-M2 (but still targeting 1.0.4 as well) until feedback is received and/or we consider another way to support the requested functionality.

  4. spring-operator commented on Nov 23, 2009

    @spring-operator
    ContributorAuthor

    Nigel Watson commented

    Apologies for delayed feedback. I did in fact email this back in October and thought it would auto-update.


    I'd like to use my bean outside of a chain - in which case I'd like to verify my channel is set. However this isn't a show stopper for me personally - HandlerChain is a nice way of cutting down the config.

  5. spring-operator commented on Dec 11, 2009

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    Moving to 2.0-M3 since we'll want to consider this in light of #4926.

  6. spring-operator commented on Mar 9, 2010

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    I'm resolving this as won't fix simply because the connection of MessageHandlers within a chain is deferred until the chain itself is initialized. If the handlers within that chain are themselves InitializingBean implementations, then afterPropertiesSet() will always be called on those beans before the chain configuration occurs.

    The chain configuration itself has been simplified considerably in 2.0 M3 however. See #4926 and #4985 for some more information.

    Feel free to comment here if there is a strong reason for the originally requested resolution. Perhaps there is a better way to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: declinedtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions