最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to set ObjectMapper used by Camel Route in Guidewire? - Stack Overflow

programmeradmin2浏览0评论

Guidewire Integration Gateway Application, uses Apache Camel 4.4.4

How or where can I configure the Jackson ObjectMapper used by the Camel routes in my application? The default ObjectMapper used by the route doesn't contain the expected modules that are configured and available when using the ObjectMapper provided by the @Inject annotation.

@Inject
private ObjectMapper jacksonObjectMapper; 

This provides the object mapper from camel-jackson with the modules registered

Route looks like:

        from("direct:policy-search")
                .routeId("pcPolicySearch")            
                .process(this::doPCSearch)    //read parameters and set exchange body
                .marshal().json(JsonLibrary.Jackson)  //transform body into json string

In the Route configure() block, I have tried setting the global options for the exchange but it has no effect: when the route runs it still has the default mapper with no modules.

 getCamelContext().getGlobalOptions().put("useDefaultObjectMapper", "false");
 getCamelContext().getGlobalOptions().put("autoDiscoverObjectMapper", "true");

I tried adding a class annotated with @Configure but it is never invoked

I tried adding an application.properties file but the values are not appearing.

camelponent.jackson.useDefaultObjectMapper=false
camelponent.jackson.autoDiscoverObjectMapper=true

I tried setting the same values in the gw-application.yaml but the values are not appearing, useDefaultObjectMapper on the dataformat is always true

camel:
  component:
    jackson:
      use-default-object-mapper: false
      auto-discover-object-mapper: true

I grabbed the registered ObjectMapper from the exchange and it is the one I want, but when the route executes the ObjectMapper on the dataformat is devoid of modules.

Map<String, ObjectMapper> s=getCamelContext().getRegistry().findByTypeWithName(ObjectMapper.class);

Guidewire Integration Gateway Application, uses Apache Camel 4.4.4

How or where can I configure the Jackson ObjectMapper used by the Camel routes in my application? The default ObjectMapper used by the route doesn't contain the expected modules that are configured and available when using the ObjectMapper provided by the @Inject annotation.

@Inject
private ObjectMapper jacksonObjectMapper; 

This provides the object mapper from camel-jackson with the modules registered

Route looks like:

        from("direct:policy-search")
                .routeId("pcPolicySearch")            
                .process(this::doPCSearch)    //read parameters and set exchange body
                .marshal().json(JsonLibrary.Jackson)  //transform body into json string

In the Route configure() block, I have tried setting the global options for the exchange but it has no effect: when the route runs it still has the default mapper with no modules.

 getCamelContext().getGlobalOptions().put("useDefaultObjectMapper", "false");
 getCamelContext().getGlobalOptions().put("autoDiscoverObjectMapper", "true");

I tried adding a class annotated with @Configure but it is never invoked

I tried adding an application.properties file but the values are not appearing.

camel.component.jackson.useDefaultObjectMapper=false
camel.component.jackson.autoDiscoverObjectMapper=true

I tried setting the same values in the gw-application.yaml but the values are not appearing, useDefaultObjectMapper on the dataformat is always true

camel:
  component:
    jackson:
      use-default-object-mapper: false
      auto-discover-object-mapper: true

I grabbed the registered ObjectMapper from the exchange and it is the one I want, but when the route executes the ObjectMapper on the dataformat is devoid of modules.

Map<String, ObjectMapper> s=getCamelContext().getRegistry().findByTypeWithName(ObjectMapper.class);
Share Improve this question asked Feb 7 at 17:40 David VanderMolenDavid VanderMolen 11 bronze badge New contributor David VanderMolen is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

What does your doPCSearch method look like? Normally what I've seen is in the route definition, the .process() call instantiates a Processor (a class implementing the Processor interface), and there you could define your ObjectMapper as a class variable and use it in the process() method.

发布评论

评论列表(0)

  1. 暂无评论