Announcement Announcement Module
Collapse
No announcement yet.
ControlBus - Missing and Incorrect Reference Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ControlBus - Missing and Incorrect Reference

    How come I can't find this class in the new package? Eclipse can't find it. Maven can't find it. I downloaded the libraries manually. I still can't find it.

    Code:
    org.springframework.integration.control.ControlBus;
    Also, there seems to be a mistake in the Spring Integration Reference:
    Code:
    8.3 Control Bus
    
    Message operation = MessageBuilder.withPayload("@myServiceBean.shutdown()");
    operationChannel.send(operation)
    It should be:
    Code:
     Message operation = new MessageBuilder.withPayload("@myServiceBean.shutdown()").build();
    operationChannel.send(operation)
    They missed out the build() method.

    By the way where is the ControlBus now? How do I call it programmatically so I can send commands? Thanks

  • #2
    ControlBus class was removed in favor of special instance if ServiceActivatingHandler (see ExpressionControlBusFactoryBean)

    Why do you need it?

    Also, thank you for pointing out the documentation flaw. Could you please open a JIRA issue for it?

    Comment


    • #3
      Okay, I did Here's the link:

      Example Has An Incomplete Method for Sending a Message to an Operation Channel
      https://jira.springsource.org/browse/INT-1733

      Comment


      • #4
        I faced same issue and describe it here: http://forum.springsource.org/showpo...73&postcount=3

        Oleg,

        Since I would like to test the Control Bus functionality ASAP, could you please tell me how to inject reference to Control Bus or operationChannel.

        Comment


        • #5
          Originally posted by oleg.zhurakousky View Post
          ControlBus class was removed in favor of special instance if ServiceActivatingHandler (see ExpressionControlBusFactoryBean)

          Why do you need it?
          I'm just trying out everything in the reference I was looking for a way to programmatically send a command. I saw one of the examples here. It has a reference over the Control Bus. So I looked at the Spring Integration API

          I was looking at the API and found the following link:
          http://static.springsource.org/sprin...ontrolBus.html

          It turns out it's an old API reference.

          Comment


          • #6
            Look at some of the test cases here
            http://git.springsource.org/spring-i...ion/config/xml

            ControlBusTest.java etc

            We are also going to be publishing CB samples shortly

            Comment


            • #7
              I actually got it working.

              Assuming you declared the following in your XML config:
              Code:
              <control-bus input-channel="operationChannel"/>
              To inject that in your bean, you just do the following:
              Code:
              @Resource(name="operationChannel")
              private DirectChannel controlBusChannel;
              It turns out it's just a simple DirectChannel after all

              If you need to send a SpEL command, do the following:
              Code:
              Message operation = MessageBuilder.withPayload("@CommandCenter.start()").build();
              controlBusChannel.send(operation);
              where MyCustomClass has the @ManagedAttribute and/or @ManagedOperation annotations:
              Code:
              @Component("CommandCenter")
              public class MyCustomClass {
              	
              
              	@ManagedAttribute	
              	public void stop() {
              		//stop nuking
              	}
              
              	@ManagedAttribute
              	public void start() {
              		//nuke more!
              	}
              }

              Comment


              • #8
                It turns out it's just a simple DirectChannel after all
                Don't you love when things are simple?
                And by the way by definition:
                Code:
                The Control Bus uses the same messaging mechanism used by the application data, but uses separate channels to transmit data that is relevant to the management of components involved in the message flow.
                http://www.eaipatterns.com/ControlBus.html

                Cheers

                Comment


                • #9
                  In one of the examples provided by Oleg (http://git.springsource.org/spring-i...lBusTests.java)

                  Here's how one way of doing it.

                  Code:
                  @Autowired
                  private MessageChannel input;
                  Code:
                  Message<?> message = MessageBuilder.withPayload("@service.convert('aardvark')+headers.foo").setHeader("foo", "bar").build();
                  this.input.send(message);

                  Comment


                  • #10
                    One way to look at Control Bus is that it's really like a special form of 'service-activator'. Here's an example:
                    Code:
                    <control-bus input-channel="controlInput" output-channel="controlOutput"/>
                    Then, you simply need to get a handle to the 'controlInput' MessageChannel instance in order to send it messages. That can be done through dependency injection, or you may prefer to use a Gateway proxy to hide the Messaging API from your code behind a simple interface. That 'input-channel' can even be some other component's 'output-channel', or it can be the target of a @Publisher annotation. The bottom line: it's just a normal Message Channel.

                    Hope that helps.
                    -Mark

                    Comment


                    • #11
                      Skram, I got it working as well. The problem is that i can not call stop() and start() methods on the <jdbc:inbound-channel-adapter> and I'm experiencing the following exception:

                      Code:
                      Caused by: org.springframework.expression.EvaluationException: The method 'public final void org.springframework.integration.endpoint.AbstractEndpoint.start()' is not supported by this command processor. If using the Control Bus, consider adding @ManagedOperation or @ManagedAttribute.
                      	at org.springframework.integration.handler.ExpressionCommandMessageProcessor$ExpressionCommandMethodResolver.validateMethod(ExpressionCommandMessageProcessor.java:100)
                      	at org.springframework.integration.handler.ExpressionCommandMessageProcessor$ExpressionCommandMethodResolver.resolve(ExpressionCommandMessageProcessor.java:81)
                      	at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:174)
                      Is there any other way to call start() and stop() methods on inbound channel adapters?

                      Thanks.

                      Comment


                      • #12
                        Unfortunately this is a bug which I am about to fix
                        https://jira.springsource.org/browse/INT-1735

                        Should be available with tonight's nightly build and in SI 2.0.2

                        Comment


                        • #13
                          Hi Oleg,

                          Thanks for fixing this. I've got additional question regarding the AbstractEndpoint and Control Bus functionality. Is there any way to get the status of a given component by calling the isRunning() method. I would like to know if the component is running or not.

                          BTW, When the SI 2.0.2 is expected to be released?

                          Regards,
                          Krzysztof

                          Comment


                          • #14
                            Yes, isRunning() is a Lifecycle method so you should have no issues if using snapshot build which includes the fix.

                            We are *planning* to release 2.0.2 by the end of January

                            Comment


                            • #15
                              Right I can call isRunning() method but the question is how can I receive the return value (true/false) from the given AbstractEndpoint?

                              I did define two channels:

                              Code:
                              <control-bus input-channel="controlBusInputChannel"
                              		output-channel="controlBusOutputChannel" />
                              and I'm sending the message

                              Code:
                              Message<String> operation = MessageBuilder.withPayload("@" + componentId + ".isRunning()").build();
                              		controlBusInputChannel.send(operation);
                              I assume that result will be send to the output-channel (controlBusOutputChannel) then how could it be retrieved?

                              Thanks,
                              Krzysztof

                              Comment

                              Working...
                              X