Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!