Reputation: 5784
I have a PublishSubscribeChannel
in my application, which should deliver messages to different MessageHandlers
inside the same JVM. Handlers are subscribed to the channel using @StreamListener
annotation. Channel uses Executors
so delivery is asynchronous.
Now, I want to test that senders and handlers agree on the specific object type which send through channel (the type of Message
body). AFAIU I have two ways to test this:
I have no idea how to do (1). And I think I could do (2) by listening to errorChannel
(there should be no messages there), but I don't quite understand how long should I wait for error messages.
Any suggestions?
Upvotes: 0
Views: 69
Reputation: 174729
For 1, you can use reflection to look at the collection of handlers in the channel's dispatcher; then use reflection again to look at the hander's Method
.
However, your design is flawed, unless you don't mind losing messages; the incoming message will be ack'd as soon as you hand off to the executor; if the server then crashes, the message will be lost.
If you get rid of the executor, it would be simpler to add an interceptor to the channel, which will be notified of any exceptions in its afterSendCompletion()
method (satisfying your 2).
Upvotes: 2