You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Reji Mathews <co...@gmail.com> on 2020/11/11 23:51:06 UTC

Unable to map @UriPath values in Endpoint class

Hello developers!

Am trying to create a camel component to connect with the Huawei cloud
services.

I started developing with camel v3.4.0 archetype ->
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes
-DarchetypeArtifactId=camel-archetype-component
-DarchetypeVersion=3.4.0-SNAPSHOT

I have my  SimpleNotificationEndpoint extending DefaultEndpoint as follows

@UriEndpoint(firstVersion = "3.4.0-SNAPSHOT", scheme = "hwcloud-smn", title
= "SimpleNotification", syntax="hwcloud-smn:smnService",
             category = {Category.CLOUD, Category.MESSAGING}, producerOnly
= true)
public class SimpleNotificationEndpoint extends DefaultEndpoint {

    @UriPath(description = "service name")
    @Metadata(required = true)
    private String smnService;

    @UriParam(label = "producer", defaultValue = "publish", description =
"operation to invoke")
    private String operation;




while testing, my producer endpoint is configured as following

.to("hwcloud-smn:publishmessage?operation=publishTextMessage&authKey=*******")

I assume, with @UriPath, the String value "publishmessage" should be copied
to the endpoint class member smnService. But, when I test, its null. Any
suggestions?


Cheers
Reji Mathews

Re: Unable to map @UriPath values in Endpoint class

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You need to map it from the component class. Take a look at all the
existing components and how they are implemented.

On Thu, Nov 12, 2020 at 7:14 AM Reji Mathews <co...@gmail.com> wrote:
>
> Hello developers!
>
> Am trying to create a camel component to connect with the Huawei cloud
> services.
>
> I started developing with camel v3.4.0 archetype ->
> mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes
> -DarchetypeArtifactId=camel-archetype-component
> -DarchetypeVersion=3.4.0-SNAPSHOT
>
> I have my  SimpleNotificationEndpoint extending DefaultEndpoint as follows
>
> @UriEndpoint(firstVersion = "3.4.0-SNAPSHOT", scheme = "hwcloud-smn", title
> = "SimpleNotification", syntax="hwcloud-smn:smnService",
>              category = {Category.CLOUD, Category.MESSAGING}, producerOnly
> = true)
> public class SimpleNotificationEndpoint extends DefaultEndpoint {
>
>     @UriPath(description = "service name")
>     @Metadata(required = true)
>     private String smnService;
>
>     @UriParam(label = "producer", defaultValue = "publish", description =
> "operation to invoke")
>     private String operation;
>
>
>
>
> while testing, my producer endpoint is configured as following
>
> .to("hwcloud-smn:publishmessage?operation=publishTextMessage&authKey=*******")
>
> I assume, with @UriPath, the String value "publishmessage" should be copied
> to the endpoint class member smnService. But, when I test, its null. Any
> suggestions?
>
>
> Cheers
> Reji Mathews



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2