Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: ControlBus - Missing and Incorrect Reference

  1. #1
    Join Date
    Dec 2010
    Posts
    315

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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?

  3. #3
    Join Date
    Dec 2010
    Posts
    315

    Default

    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

  4. #4
    Join Date
    Oct 2008
    Location
    Warsaw, Poland
    Posts
    124

    Default

    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.

  5. #5
    Join Date
    Dec 2010
    Posts
    315

    Default

    Quote 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.

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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

  7. #7
    Join Date
    Dec 2010
    Posts
    315

    Default

    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!
    	}
    }

  8. #8
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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

  9. #9
    Join Date
    Dec 2010
    Posts
    315

    Default

    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);

  10. #10
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    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

Posting Permissions

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