Annotation Type InjectChannel


  • @Autowired
    @Qualifier
    @Documented
    @Retention(RUNTIME)
    @Target({METHOD,FIELD,PARAMETER,ANNOTATION_TYPE})
    public @interface InjectChannel
    Provides support for MessagingChannels autowiring.

    This annotation can be placed on any autowire-capable elements (fields, properties, parameters, etc) of application beans in order to inject MessagingChannel by its name.

    Below is the example of how this annotation can be used.

    1) Define a bean that will use InjectChannel annotation to inject MessagingChannel into its field.

    
    @Component
    public class MyBean {
        @InjectChannel("my-channel")
        private MessagingChannel<Object> channel;
    
        // ... other fields and methods...
    }
    
    2) Define a Spring Boot application that will provide channel configuration.
    
    @EnableHekate
    @SpringBootApplication
    public class MyApp {
        @Bean
        public MessagingChannelConfig<Object> messagingChannelConfig() {
            return MessagingChannelConfig.unchecked()
                .withName("my-channel")
                .withReceiver(msg ->
                    System.out.println("Got message " + msg)
                );
        }
    
        // ... other beans and methods...
    }
    

    See Also:
    HekateMessagingServiceConfigurer