Results 1 to 4 of 4

Thread: Best way to get the status of Consumer

  1. #1
    Join Date
    May 2012
    Posts
    14

    Default Best way to get the status of Consumer

    Thought this could be a new thread. Is there any way in Spring Integration from which I could get the status (running/stopped) of any of my consumer ??

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,022

    Default

    Use a <gateway/> to send a message to the control bus...

    Code:
    public interface ControlBus {
        boolean command(String command);
    }
    
    <int:gateway service-interface="foo.ControlBus" default-request-channel="controlBusChannel"/>
    
    ...
    
    @Autowired
    private ControlBus controlBus;
    
    ...
    
    if (controlBus.command("@rabbitAdapter.isRunning()")) {
       ...
    }
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    May 2012
    Posts
    14

    Default

    Thank you Gary. One very dumb question, are you declaring the controlBus variable and the "if" statement in the main here ?

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,022

    Default

    In this case I @Autowired it (assumes the current class was a class declared in the Spring config).

    If you are running from a main, and creating an application context, you can get a reference to it using

    Code:
    ControlBus controlBus = context.getBean(ControlBus.class)
    This assumes there is only one instance of ControlBus in the context (which there usually would be).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •