Skip to content

Can't send iterable message using Stream Bridge #748

@xcejp03

Description

@xcejp03

I have a problem with stream bridge in last version of spring cloud 2020.0.4. If I try to send something iterable (json array) than I get this error:
java.lang.ClassCastException: class reactor.core.publisher.FluxPeekFuseable cannot be cast to class org.springframework.messaging.Message (reactor.core.publisher.FluxPeekFuseable and org.springframework.messaging.Message are in unnamed module of loader 'app')

It is because when message is iterable than it is wrapped in Flux in SimpleFunctionRegistry.java and stream bridge is expecting Message<byte[]> so it fails.
Spring cloud 2020.3 is ok

libraries versions:
spring boot - 2.5.5
spring cloud - 2020.4
spring cloud stream - 3.1.4
spring cloud function - 3.1.4

@RequiredArgsConstructor
@Controller
@SpringBootApplication
public class DemoApplication {

    private final StreamBridge streamBridge;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class);
    }

    @RequestMapping
    @ResponseStatus(HttpStatus.ACCEPTED)
    public void sendMsg() {
        String data = """
                [{"color":"red"},{"color":"blue"}]""";
                streamBridge.send("myDestination", data);
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions