I want to use a executor-channel instead of an direct-channel, but I face an issue I don`t understand.
Working Config:
<int:channel id="newByteArrayChannel" datatype="java.lang.Byte[]" />
<int:service-activator
id="myEncryptionServiceActivator"
ref="encryptionServiceConnector"
method="encrypt"
input-channel="newByteArrayChannel"
output-channel="encryptedByteArrayChannel"
requires-reply="true"
send-timeout="1000"
/>
Changed to (Not Working):
<int:channel id="newByteArrayChannel" datatype="java.lang.Byte[]">
<int:dispatcher task-executor="myExecutor" />
</int:channel>
<task:executor id="myExecutor" pool-size="4" queue-capacity="10" keep-alive="10000"/>
<int:service-activator
id="myEncryptionServiceActivator"
ref="myServiceConnector"
method="encrypt"
input-channel="newByteArrayChannel"
output-channel="encryptedByteArrayChannel"
requires-reply="true"
send-timeout="1000"
/>
Error:
Exception in thread "main" org.springframework.messaging.MessageDeliveryException: Channel 'newByteArrayChannel' expected one of the following datataypes [class [Ljava.lang.Byte;], but received [class [B]
Thanks in advance :-)
It's a bug - I opened a JIRA Issue.
As a work-around, you could bridge a direct channel to the executor channel, or change newByteArrayChannel
to a publish subscribe channel - (with only one subscriber, or course).
<int:publish-subscribe-channel id="newByteArrayChannel"
datatype="java.lang.Byte[]" task-executor="myExecutor" />
Or you can explicitly inject a DefaultDatatypeChannelMessageConverter
bean into the channel.