make it easier to configure dispatcher for Camel ProducerChild, #23099
* and use parent dispatcher as default, better than default-dispatcher (cherry picked from commit c911c06b9e60b88874cf9b608c64aa5a125e9794)
This commit is contained in:
parent
de3a48f2c3
commit
8ca0aac2dc
3 changed files with 16 additions and 1 deletions
|
|
@ -32,6 +32,15 @@ akka {
|
|||
# The duration of time to await activation of an endpoint.
|
||||
activation-timeout = 10s
|
||||
}
|
||||
|
||||
producer {
|
||||
# The id of the dispatcher to use for producer child actors, i.e. the actor that
|
||||
# interacts with the Camel endpoint. Some endpoints may be blocking and then it
|
||||
# can be good to define a dedicated dispatcher.
|
||||
# If not defined the producer child actor is using the same dispatcher as the
|
||||
# parent producer actor.
|
||||
use-dispatcher = ""
|
||||
}
|
||||
|
||||
#Scheme to FQCN mappings for CamelMessage body conversions
|
||||
conversions {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ class CamelSettings private[camel] (config: Config, dynamicAccess: DynamicAccess
|
|||
*/
|
||||
final val StreamingCache: Boolean = config.getBoolean("akka.camel.streamingCache")
|
||||
|
||||
final val ProducerChildDispatcher: String = config.getString("akka.camel.producer.use-dispatcher")
|
||||
|
||||
final val Conversions: (String, RouteDefinition) ⇒ RouteDefinition = {
|
||||
val specifiedConversions = {
|
||||
import scala.collection.JavaConverters.asScalaSetConverter
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@ trait ProducerSupport extends Actor with CamelSupport {
|
|||
protected def produce: Receive = {
|
||||
case CamelProducerObjects(endpoint, processor) ⇒
|
||||
if (producerChild.isEmpty) {
|
||||
producerChild = Some(context.actorOf(Props(new ProducerChild(endpoint, processor))))
|
||||
val disp = camel.settings.ProducerChildDispatcher match {
|
||||
case "" ⇒ context.props.dispatcher
|
||||
case d ⇒ d
|
||||
}
|
||||
producerChild = Some(context.actorOf(Props(new ProducerChild(endpoint, processor)).withDispatcher(disp)))
|
||||
messages = {
|
||||
for (
|
||||
child ← producerChild;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue