You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chris Wolf <cw...@gmail.com> on 2013/06/12 21:28:28 UTC

Problem with DefaultCamelContext EndpointRegistry

I am trying to develop a new component, but it needs to be able to
have it's endpoint be registered in
the CamelContext endpoint registry.   Whenever the runtime tries to
call DefaultCamelContext.getEndpoint(String uri)
it returns null, even though, in the debugger, I can expand
DefaultCamelContext.endpoints.map

...and see that, for sure, the endpoint is in the registry, except the
key now has "%3A2" appended, so of course,
the EndpointKey, which looks like:

dsftp://localhost:21000?binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5

...won't match, so that explains why
DefaultCamelContext.getEndpoint(String uri) returns null.


DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
{dsftp://localhost:21000binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}

*** So why does the key in the endpoints.map have "%3A2"  appended to it? ***

Thanks,

Chris

Re: Problem with DefaultCamelContext EndpointRegistry

Posted by Chris Wolf <cw...@gmail.com>.
Claus,

Thanks, but the fact that attempting to add another instance of the
same Endpoint type results in the
name getting and instance number appended means that some
consideration must have been
given to accommodating multiple instances of the same Endpoint in the
registry, right?

In any case, I gave up on the idea of writing a custom component to
solve the dynamic
consumer problem and instead, create consumer routes, at runtime, with
static consumer URIs,
which solves my problem.

Thanks,

Chris

On Fri, Jun 14, 2013 at 7:16 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Only singleton endpoints should be in the registry.
>
> Non singleton is prototype based and therefore a new instance is
> created when you call getEndpoint.
>
>
>
> On Wed, Jun 12, 2013 at 7:41 PM, Chris Wolf <cw...@gmail.com> wrote:
>> Ok, have a partial answer - since my Endpoint is not a singleton, I see that
>> DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint)
>> appends that "%3A2" -
>> i.e. ":2" - which appears to be an instance qualifier.  The trouble is,
>> DefaultEndpoint.getEndpointUri() will always return the URI *without*
>> that instance qualifier,
>> so it won;t be found in the endpoint registry.
>>
>> Is there an example of a Component whose Endpoint is not a singleton,
>> that I can look at?
>> Or are non-singleton Endpoints some new, untested feature?
>>
>> Thanks,
>>
>> Chris
>>
>> On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf <cw...@gmail.com> wrote:
>>> I am trying to develop a new component, but it needs to be able to
>>> have it's endpoint be registered in
>>> the CamelContext endpoint registry.   Whenever the runtime tries to
>>> call DefaultCamelContext.getEndpoint(String uri)
>>> it returns null, even though, in the debugger, I can expand
>>> DefaultCamelContext.endpoints.map
>>>
>>> ...and see that, for sure, the endpoint is in the registry, except the
>>> key now has "%3A2" appended, so of course,
>>> the EndpointKey, which looks like:
>>>
>>> dsftp://localhost:21000?binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5
>>>
>>> ...won't match, so that explains why
>>> DefaultCamelContext.getEndpoint(String uri) returns null.
>>>
>>>
>>> DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
>>> {dsftp://localhost:21000binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}
>>>
>>> *** So why does the key in the endpoints.map have "%3A2"  appended to it? ***
>>>
>>> Thanks,
>>>
>>> Chris
>
>
>
> --
> Claus Ibsen
> -----------------
> www.camelone.org: The open source integration conference.
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Re: Problem with DefaultCamelContext EndpointRegistry

Posted by Claus Ibsen <cl...@gmail.com>.
Only singleton endpoints should be in the registry.

Non singleton is prototype based and therefore a new instance is
created when you call getEndpoint.



On Wed, Jun 12, 2013 at 7:41 PM, Chris Wolf <cw...@gmail.com> wrote:
> Ok, have a partial answer - since my Endpoint is not a singleton, I see that
> DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint)
> appends that "%3A2" -
> i.e. ":2" - which appears to be an instance qualifier.  The trouble is,
> DefaultEndpoint.getEndpointUri() will always return the URI *without*
> that instance qualifier,
> so it won;t be found in the endpoint registry.
>
> Is there an example of a Component whose Endpoint is not a singleton,
> that I can look at?
> Or are non-singleton Endpoints some new, untested feature?
>
> Thanks,
>
> Chris
>
> On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf <cw...@gmail.com> wrote:
>> I am trying to develop a new component, but it needs to be able to
>> have it's endpoint be registered in
>> the CamelContext endpoint registry.   Whenever the runtime tries to
>> call DefaultCamelContext.getEndpoint(String uri)
>> it returns null, even though, in the debugger, I can expand
>> DefaultCamelContext.endpoints.map
>>
>> ...and see that, for sure, the endpoint is in the registry, except the
>> key now has "%3A2" appended, so of course,
>> the EndpointKey, which looks like:
>>
>> dsftp://localhost:21000?binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5
>>
>> ...won't match, so that explains why
>> DefaultCamelContext.getEndpoint(String uri) returns null.
>>
>>
>> DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
>> {dsftp://localhost:21000binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}
>>
>> *** So why does the key in the endpoints.map have "%3A2"  appended to it? ***
>>
>> Thanks,
>>
>> Chris



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Problem with DefaultCamelContext EndpointRegistry

Posted by Chris Wolf <cw...@gmail.com>.
Ok, have a partial answer - since my Endpoint is not a singleton, I see that
DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint)
appends that "%3A2" -
i.e. ":2" - which appears to be an instance qualifier.  The trouble is,
DefaultEndpoint.getEndpointUri() will always return the URI *without*
that instance qualifier,
so it won;t be found in the endpoint registry.

Is there an example of a Component whose Endpoint is not a singleton,
that I can look at?
Or are non-singleton Endpoints some new, untested feature?

Thanks,

Chris

On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf <cw...@gmail.com> wrote:
> I am trying to develop a new component, but it needs to be able to
> have it's endpoint be registered in
> the CamelContext endpoint registry.   Whenever the runtime tries to
> call DefaultCamelContext.getEndpoint(String uri)
> it returns null, even though, in the debugger, I can expand
> DefaultCamelContext.endpoints.map
>
> ...and see that, for sure, the endpoint is in the registry, except the
> key now has "%3A2" appended, so of course,
> the EndpointKey, which looks like:
>
> dsftp://localhost:21000?binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5
>
> ...won't match, so that explains why
> DefaultCamelContext.getEndpoint(String uri) returns null.
>
>
> DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
> {dsftp://localhost:21000binary=true&directory=target%2Fres%2Fhome&filter=%23cpmdFileFilter&idempotent=true&localWorkDirectory=target%2Fres%2Ftmp%2Flocal&move=archive%2F%24%7Bfile%3Aname%7D&password=adpt5&separator=UNIX&username=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}
>
> *** So why does the key in the endpoints.map have "%3A2"  appended to it? ***
>
> Thanks,
>
> Chris