Multiple camel producers instantiated

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple camel producers instantiated

Shiva
This post was updated on .
Hi,

I am using Apache Camel - v2.15.5 and I have an issue that multiple instances of the Default producer is being created suddenly. Normally when I start the camel route, only one instance of the producer is created as expected. It works fine for a few hours sending messages to the endpoint. But after a while, a new Producer is instantiated. I try to establish a TCP connection to the endpoint in doStart() of Producer. The newly created producer tries to establish connection which is not successful. So I am not able to forward messages to the endpoint anymore. Please help!!

Thanks,
Shiva
Reply | Threaded
Open this post in threaded view
|

Re: Multiple camel producers instantiated

Charles Moulliard-2
Hi Shiva,

Can you share the code/test case in order to reproduce the issue please ?
Which camel component do you use ? Which camel version ?

Regards,

On Fri, Apr 15, 2016 at 11:51 AM, Shiva <[hidden email]> wrote:

> Hi,
>
> I am using Camel and I have an issue that multiple instances of the Default
> producer is being created suddenly. Normally when I start the camel route,
> only one instance of the producer is created as expected. It works fine for
> a few hours sending messages to the endpoint. But after a while, a new
> Producer is instantiated. I try to establish a TCP connection to the
> endpoint in doStart() of Producer. The newly created producer tries to
> establish connection which is not successful. So I am not able to forward
> messages to the endpoint anymore. Please help!!
>
> Thanks,
> Shiva
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Multiple-camel-producers-instantiated-tp5781152.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
Reply | Threaded
Open this post in threaded view
|

Re: Multiple camel producers instantiated

Shiva
I am using Apache camel - 2.15.5 and Activemq - 5.10.2

Below is the code for my route

// Define heartbeat routes
    for (final EndpointInfo endpointInfo : endpointInfos) {
        final String uri = BOLD_ENDPOINT_PREFIX + endpointInfo.getUri();
        from("timer:monitor" + uri + "?fixedRate=true&period=" + (heartbeatInterval * 1000))
                .routeId(endpointInfo.getHeartbeatRouteId())
                .autoStartup(false)
                .setBody(constant(HEARTBEAT_MSG))
                .doTry()
                  .to(uri)
                  .process(new HealthProcessor(endpointInfo, true))
                .doCatch(Throwable.class)
                  .process(new HealthProcessor(endpointInfo, false))
                .end();

        uris[index++] = uri;
        routeIds[index] = endpointInfo.getHeartbeatRouteId();
    }

    // Define event route
    from("activemq:Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true")
            .routeId("eventProcessing")
            .autoStartup(false)
            .log(LoggingLevel.DEBUG, "Event Received: ${id}")
            .process(factory.createProducerTransformer())
            .loadBalance(new BoldLoadBalancer(endpointInfos))
            .to(uris);

    // Set up heartbeat detector
    heartbeatDetector.initialize(this, routeIds);

Camel Producer
-----------------
@Override
protected void doStart() throws Exception {
    super.doStart();
    connect();
}

private void connect() {
    final ChannelFuture channelFuture = bootstrap.connect();
    channelFuture.addListener(new GenericFutureListener<ChannelFuture>() {
        @Override
        public void operationComplete(final ChannelFuture future) throws Exception {
            if (!future.isSuccess()) {
                LOG.info("Connection not successful. Cause: " + future.cause().toString() + " -> Reconnecting...");
                reconnect(future.channel());
            } else {
                LOG.info("Connection successful.");
            }
        }
    });
}

I am nomally creating a new producer when an endpoint is intialized and createProducer() is called.

Endpoint class
----------------
    @Override
    public Producer createProducer() throws Exception {
        LOG.info("Create Producer called");
        return new BoldProducer(this, uri);
    }

It looks like this createProducer() is also called from ProducerCache.java

Thanks,
Shiva
Reply | Threaded
Open this post in threaded view
|

Re: Multiple camel producers instantiated

Shiva
In reply to this post by Charles Moulliard-2
Hi Charles,

Can you help me with this issue. I still couldn't find a solution for this.
Thanks!

Regards,
Shiva