Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
Specifying order of ServiceActivator on a publish-subscribe channel in Spring Integration (using javaConfig)

I'm currently specifying a service-activator and related publish-subscribe channel in an integration-context.xml file. Something like this (abridged version):

<int:publish-subscribe-channel id="notificationChannel" task-executor="executor" />

<int:gateway service-interface="com.integration.gateway.RestClientGateway" default-request-channel="notificationChannel" async-executor="executor"/>

<int:service-activator ref="restClient" method="sendRequest" **order="1"** input-channel="notificationChannel"/>
<int:service-activator ref="actionPersistor" method="persistNotification" **order="2"** input-channel="notificationChannel"/>

Now I need to specify a custom executor class (for MDC logging), so I started playing around with moving this to an annotation based approach. Something along the lines of this :

@Bean
@Description("PubSub channel for notification")
public MessageChannel notificationChannel() {
    return new PublishSubscribeChannel(mdcTaskExecutor());
}

@Bean
public TaskExecutor mdcTaskExecutor() {
    return MDCThreadPoolTaskExecutor.newWithInheritedMdc(10, 20, 25);
}

@MessagingGateway(name = "restClientGateway", defaultRequestChannel = "notificationChannel", asyncExecutor = "mdcExecutor")
public interface RestClientGateway {

    Future<Message<String>> sendRequest(Message<BlEvent> message);
}

@ServiceActivator(inputChannel = "notificationChannel")
public Message<String> sendRequest(Message<BlEvent> message) {

@ServiceActivator(inputChannel="notificationChannel")
public void persistNotification(Message<BlEvent> message) {

My question is, if there's any way to specify the ordering in which the @ServiceActivators receive a message from the pub-sub channel, similar to the way I could define it in the integration-context.xml.

Thanks much for your help. And apologies in advance if this was way too simple as setting a property, coz I couldn't seem to locate it.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Yes, you can simply add @Order alongside with those Messaging annotations.

I guess we have an omission in the Reference Manual do not mention that.

Feel free to raise a JIRA ticket on the matter!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda