onkami
onkami

Reputation: 9431

Send data to a Channel from a callback method (Spring Integration)

I have a method that is called as a callback from some communication library when data are received.

Using Spring Integration, I would like to send data to a specific Channel that will be later picked up by some Sender and some Database Recorder. These two may work in parallel. How could I do it?

I prefer not to use XML for anything.

Upvotes: 0

Views: 363

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121552

These two may work in parallel.

For this purpose Spring Integration provides PublishSubscribeChannel. With its executor option you really can make subscribers working in parallel.

I would like to send data to a specific Channel

So, just do that from that callback method.

You can consider to use Messaging Gateway for dependency injection instead of direct channel injection for sending.

That way you will call the gateway's method from that callback and the data will be send to predefined PublishSubscribeChannel channel for distribution between its subscribers.

how do I create that "existing channel"

That's all about Spring and its inversion of control implementation.

You may consider to consult existing Spring Integration Samples for ideas.

Upvotes: 1

Related Questions