Hi, Claus.  You make a good point.  I am setting up a helper class that
contains the code to create the RecipientList.  I copied over everything
from the RecipientListReifier class, and converted the places that use the
Definition instances to just use my Configuration.  I also removed the line
that wraps the EvaluateExpressionProcessor in an error handler to avoid
needing a Route instance.  I am encountering an issue (that I was also
encountering when using the Reifier and the simple Route).  It is reporting
this error: Cannot invoke
"org.apache.camel.processor.PooledExchangeTaskFactory.acquire(org.apache.camel.Exchange,
org.apache.camel.AsyncCallback)" because "this.taskFactory" is null.  In
the configuration, I am specifying that this should be synchronous, anyway,
so I am having a bit of a tough time figuring out why this is happening,
and how to fix it.  Any thoughts?

On Sun, Dec 3, 2023 at 6:19 AM Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Wed, Nov 29, 2023 at 9:06 PM Steve973 <steve...@gmail.com> wrote:
>
> > Hi, Claus.  Thanks for the recommendation.  Originally, I was going to
> use
> > the RecipientList class and create an instance.  I thought that I would
> see
> > how core was creating the processor, which led me to my interest in the
> > reifier class.  When I looked at it, I saw the value in how it set up the
> > executors/thread pools, and the aggregation strategy.  If I cannot (or do
> > not) use the reifier, then I will have to duplicate or re-create that
> > code.  Since a major point in my refactoring endeavor is to simplify this
> > component, I am hesitant to do that.
> >
> > I am looking at an alternative, and I would like your opinion when you
> have
> > the time to offer your thoughts.  I have a route template like this:
> >
> > routeTemplate("recipientListRouteTemplate")
> >         .templateParameter("channel")
> >         .from("direct:${channel}")
> >         .process("${channel}RecipientList");
> >
> > Then I create a route from this in my DynamicRouterProcessor class like
> > this:
> >
> > String routeId = TemplatedRouteBuilder.builder(camelContext,
> > "recipientListRouteTemplate")
> >         .parameter("channel", configuration.getChannel())
> >         .add();
> > Route route = camelContext.getRoute(routeId);
> >
> > After that, I have code that translates the configuration params into a
> > RecipientListDefinition.  After that, I have:
> >
> > RecipientListReifier reifier = new RecipientListReifier(route,
> definition);
> > camelContext.getRegistry()
> >         .bind(configuration.getChannel() + "RecipientList",
> > reifier.createProcessor());
> >
> > When a message comes in for the DynamicRouterProcessor instance to
> handle,
> > the process method handles the exchange like this:
> >
> > prepareExchange(exchange);
> > try (Producer producer = exchange.getContext().getEndpoint("direct:" +
> > channel).createProducer()) {
> >     producer.process(exchange);
> > }
> >
> > That was as far as I got yesterday in my implementation, so I was not yet
> > able to test it.  Is this a terrible idea, or do you think it is worth
> > trying?  Otherwise, if it's the best option, I could "borrow" the
> pertinent
> > code in the reifier and create the RecipientList instance directly.
> >
> >
> Hi
>
> I think this seems to complicated and also caused a lot of routes to be
> added dynamically based on channel names.
> And that is overhead as the route would then just be a from -> to.
>
>
>
>
>
> > Thanks,
> > Steve
> >
> >
> >
> > On Wed, Nov 29, 2023 at 1:19 AM Claus Ibsen <claus.ib...@gmail.com>
> wrote:
> >
> > > Hi
> > >
> > > If you need to create the RecipientListProcessor then you dont
> > > necessary have to use reifier to do it.
> > >
> > > We have a few EIPs that are created via annotations
> > >
> > >
> >
> https://github.com/apache/camel/blob/5235319d94fbb82f479ca3085b0780c0f144111b/core/camel-api/src/main/java/org/apache/camel/spi/AnnotationBasedProcessorFactory.java#L44
> > >
> > > You can just create the processor yourself and configure it
> accordingly.
> > >
> > >
> > >
> > >
> > > On Tue, Nov 28, 2023 at 12:51 AM Steve973 <steve...@gmail.com> wrote:
> > >
> > > > Hello.  I am attempting to simplify my Dynamic Router EIP component
> by
> > > > using the existing RecipientList implementation from camel-core.
> > > >
> > > > I was looking at the RecipientListReifier, even though I will not be
> > > adding
> > > > anything to the Camel DSL.  It looks like it would be perfect for
> > setting
> > > > up the RecipientList instance.  I can take my configuration class,
> and
> > > > adapt it to a RecipientListDefinition instance.  The problem that I
> am
> > > > encountering is that the RecipientListReifier constructor wants a
> Route
> > > > instance.  When routing recipients send their subscription
> information
> > to
> > > > the dynamic router component through its control channel, this is not
> > the
> > > > route that the actual routing will occur on.  So I have no idea what
> > > Route
> > > > instance I can provide to the Reifier constructor.  Furthermore, when
> > the
> > > > dynamic router receives a message, the producer simply calls the
> > > processor,
> > > > so there is no real route to speak of, even during runtime dynamic
> > > routing.
> > > >
> > > > My questions are:
> > > >
> > > > 1. Is this a decent approach?  After a recent code review, it
> occurred
> > to
> > > > me that I needed to simplify everything, and this would do that.  The
> > > > component would only need to manage subscriptions, and evaluate
> > exchanges
> > > > for recipients.
> > > >
> > > > 2. What should I use as the Route instance for the Reifier
> constructor?
> > > > Would it be a good idea to create a RouteBuilder for each dynamic
> > routing
> > > > channel that subscribers are using?  It would go from
> > > "direct:channelName"
> > > > and then to the processor.  That still leaves me confused about how
> to
> > > > use my component/endpoint configuration to set the options on the
> > > > RecipientList through the Reifier.  It's a chicken/egg scenario:  the
> > > > RecipientListReifier needs the Route, and the Route needs the
> > processor.
> > > >
> > > > 3. What other approach am I missing that might be better than this?
> > > >
> > > > Thanks,
> > > > Steve
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Reply via email to