From the course: Spring: Spring Integration

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Refactor a Spring Integration SubscribableChannel

Solution: Refactor a Spring Integration SubscribableChannel - Spring Tutorial

From the course: Spring: Spring Integration

Start my 1-month free trial

Solution: Refactor a Spring Integration SubscribableChannel

(upbeat music) - [Instructor] Let's have a look now at one way to solve this refactoring code challenge. Starting in tech support.xml, where our channel is first configured, the first thing we need to do is instead of using the channel element from the Integration namespace, we need to use the PublishSubscribeChannel element. It's that simple. Now in our code references, we need to update the type that we're casting this reference to. So here in line 33, in the ViewService, instead of casting our resulting bean to a direct channel, we need to cast it to a PublishSubscribeChannel. The reason that works so handily for us is there in line 20, we have initialized our TechSupportChannel property to be an abstract subscribable channel, which is the parent of both PublishSubscribeChannels and direct channels. So it's just a simple matter of changing our cast there in line 33, and that does the trick. We have a similar…

Contents