Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:27:56+00:00 2026-06-11T21:27:56+00:00

I am working on a web project that uses Spring and RabbitMQ. This is

  • 0

I am working on a web project that uses Spring and RabbitMQ. This is a basic system with a Master node sending tasks to Slave nodes (using a direct exchange) and Slave nodes responding to the Master using a simple queue.

New slaves may come and go at any time so they use anonymous queues. There can also be multiple Master nodes, in which case each of them will have their own reply queue. When a Master sends a task to slaves, the task contains the name of the reply queue of the master who sent it. Sending messages is done using AmqpTemplate.

I’m configuring all of this using XML, here’s what I’ve got so far:

For the Slave:

<!-- Message listener -->
<bean id="taskListener" class="tgi.docgen.amqp.TypedListener" />
  <bean id="slave" class="tgi.docgen.node.Slave" />
    <bean id="handler" class="tgi.docgen.task.TaskHandler" />

<!-- Rabbit infrastructure -->
<!-- Slave reading queue, bound to the exchange -->
<rabbit:queue id="receiveQueue" auto-delete="true" durable="false" />

<!-- Master -> Slave exchange -->
<rabbit:direct-exchange name="docgenExchange" auto-delete="true" durable="false">   
    <rabbit:bindings>
        <rabbit:binding queue="receiveQueue" />
    </rabbit:bindings>
</rabbit:direct-exchange>

<!-- taskListener bean listens to the queue -->
<rabbit:listener-container connection-factory="rabbitFactory">
    <rabbit:listener queues="receiveQueue" ref="taskListener" />
</rabbit:listener-container>

For the Master:

<!-- Message listener -->
<bean id="taskListener" class="tgi.docgen.amqp.TypedListener" />
  <bean id="master" class="tgi.docgen.node.Master">
      <property name="docgenExchange" value="???" />
      <property name="receiveQueue" value="???" />
  </bean>

<!-- Rabbit infrastructure -->
<!-- Anonymous reception queue -->
<rabbit:queue id="receiveQueue" auto-delete="true" durable="false" />

<!-- Master -> Slave exchange -->
<rabbit:direct-exchange name="docgenExchange" auto-delete="true" durable="false" />

<!-- taskListener listens to reception queue -->
<rabbit:listener-container connection-factory="rabbitFactory">
    <rabbit:listener queues="receiveQueue" ref="taskListener" />
</rabbit:listener-container>

Here’s what I want to know

1) how do I avoid repeating the name of the exchange in both XML config files ? The Master project depends on the Slave project so I can easily share configuration between them, but I don’t see how I can extract the exchange name and use it in both files.

2) As I’ve said, the Master will send tasks to the exchange, and must write the name of its reply queue in the tasks. How can I inject the name of the queue and the exchange in the Master bean ? That is: how can i replace the two ??? with respectively “docgenExchange” and the generated name of the anonymous reply queue in my config file above ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:27:57+00:00Added an answer on June 11, 2026 at 9:27 pm

    That’s not Spring Integration 2?

    Anyway, I’ve made a “proof of concept” for myself a few days ago doing stuff exactly what you want to archive. See at https://github.com/knalli/task-worker

    Regarding to your first question: Well, it depends. It depends what do you exactly want. I see no problem to configure in both projects — project master and project slave — the name of the central queue. Of course, this should not be hardcoded but a configuration option. And you can provide both running programs the same external properties which will used as a Property Placeholder Bean within the Spring Configuration Context.

    The second is a little bit weird: Perhaps you had an old example or this is Spring Ingegration 1.x.. I don’t know. Anyway: You don’t need to provide a reply name. Because this will be handled automatically by Spring Integration for you if you use the AMPQ Gateway Beans.

    I cite a port of the configuration of the Inbound AMQP Gateway configuration of my daemon (this is your “slave”):

    <int-amqp:inbound-gateway 
        connection-factory="connectionFactory" 
        request-channel="requestChannel"
        reply-channel="replyChannel" 
        error-channel="errorChannel"
        queue-names="${rabbitmq.queue}"/>
    

    Each of the mentioned channels — requestChannel, replyChannel, errorChannel — are only registered in the Spring Integration Context via a simple

     <int:channel id="requestChannel"/>
    

    For AMQP — meaning Message Broker configuration — there is no need for more configuration parts except the <rabbit:queue> item.

    Furthermore, I’d use Java annotations to wire the messages to services interfaces (@Gateway) and service classes (@ServiceActivator). This reduces the configuration a lot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Spring Web Project that we are using Subversion, Eclipse
I am working on a project that has Spring based Web Services and Spring
I'm working on a Java web project that uses Maven to build its artifacts.
I am working in a iPhone project that uses restful web services. I need
I am new to Hibernate and working on a web project that uses it.
This is the scenario: I'm working on a new ASP.NET application that uses master
I am working on an ASP.NET 4.0 web forms project that uses page routing
I'm working on a project that uses the new Web API and I noticed
I'm working on a web project that takes the results from a survey type
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.