I want to create a web-socket source (for spring-cloud-stream-app-starters) which is currently not available on git hub.
I went through some of the available sources but had some confusions, may be because I'm not familiar with the framework.
Can I just create a spring boot application with Source binding
and return the received packets from web-socket clients in an @InboundChannelAdapter(value = Source.OUTPUT)
annotated method. ?
Also how can I use WebSocketInboundChannelAdapter to start a websocket server and push the packets to the underlying broker.?
You can get some ideas in the Reference Manual.
The
WebSocketInboundChannelAdapter
is an event-driven channel adapter, it's not pollable source. So, what you need is just a@Bean
for this one and an appropriate reference to theSource.OUTPUT
.The
WebSocketInboundChannelAdapter
doesn't start server. That is responsibility of the:We have a documentation on the matter as well.
There is also a stomp-chat sample to demonstrate the server behavior.
I think you don't need "underlying broker" in this kind of
source
application: you just receive messages over web socket and publish them to theSource.OUTPUT
. Why do you need STOMP broker here?UPDATE
Have just tested this code against Rabbit Binder:
My test-case is like:
This is my dependencies:
@Krishas I would definitely look at the available sources, find the one that closely resembles what you're trying to accomplish and model your new source after it. In general what you are suggesting is correct. . . it should be Spring boot app annotated with
@Source
. But of course the devil is in the details. So what I would suggest is to create a PR so we can all review it and help you bring it to the state where we can include it in the pool of available starters.