feign.jackson.JacksonEncoder Java Examples
The following examples show how to use
feign.jackson.JacksonEncoder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TwitchHelixBuilder.java From twitch4j with MIT License | 8 votes |
/** * Twitch API Client (Helix) * * @return TwitchHelix */ public TwitchHelix build() { log.debug("Helix: Initializing Module ..."); // Hystrix ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", timeout); ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.requestCache.enabled", false); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.maxQueueSize", getRequestQueueSize()); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.queueSizeRejectionThreshold", getRequestQueueSize()); // Jackson ObjectMapper ObjectMapper mapper = new ObjectMapper(); // - Modules mapper.findAndRegisterModules(); // Feign TwitchHelix client = HystrixFeign.builder() .client(new OkHttpClient()) .encoder(new JacksonEncoder(mapper)) .decoder(new JacksonDecoder(mapper)) .logger(new Logger.ErrorLogger()) .errorDecoder(new TwitchHelixErrorDecoder(new JacksonDecoder())) .requestInterceptor(new TwitchHelixClientIdInterceptor(this)) .options(new Request.Options(timeout / 3, TimeUnit.MILLISECONDS, timeout, TimeUnit.MILLISECONDS, true)) .retryer(new Retryer.Default(500, timeout, 2)) .target(TwitchHelix.class, baseUrl); return client; }
Example #2
Source File: AlertsPublisher.java From hawkular-apm with Apache License 2.0 | 7 votes |
@Asynchronous public void publish(final Event event) { if (BASE_URL == null || BASE_URL.isEmpty()) { logger.hawkularServerNotConfigured(); return; } if (USERNAME == null || USERNAME.isEmpty()) { logger.hawkularServerUsernameNotConfigured(); return; } if (PASSWORD == null || PASSWORD.isEmpty()) { logger.hawkularServerPasswordNotConfigured(); return; } HystrixFeign.builder() .requestInterceptor(new BasicAuthRequestInterceptor(USERNAME, PASSWORD)) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .retryer(new Retryer.Default()) .target(AlertsService.class, TARGET) .addEvent(event); }
Example #3
Source File: TwitchKrakenBuilder.java From twitch4j with MIT License | 7 votes |
/** * Twitch API Client (Kraken) * * @return TwitchKraken */ public TwitchKraken build() { log.debug("Kraken: Initializing Module ..."); // Hystrix ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", timeout); ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.requestCache.enabled", false); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.maxQueueSize", getRequestQueueSize()); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.queueSizeRejectionThreshold", getRequestQueueSize()); // Build TwitchKraken client = HystrixFeign.builder() .client(new OkHttpClient()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logger(new Logger.ErrorLogger()) .errorDecoder(new TwitchKrakenErrorDecoder(new JacksonDecoder())) .requestInterceptor(new TwitchClientIdInterceptor(this.clientId, this.userAgent)) .options(new Request.Options(timeout / 3, TimeUnit.MILLISECONDS, timeout, TimeUnit.MILLISECONDS, true)) .retryer(new Retryer.Default(500, timeout, 2)) .target(TwitchKraken.class, baseUrl); return client; }
Example #4
Source File: TwitchMessagingInterfaceBuilder.java From twitch4j with MIT License | 7 votes |
/** * Twitch API Client (Helix) * * @return TwitchHelix */ public TwitchMessagingInterface build() { log.debug("TMI: Initializing Module ..."); // Hystrix ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", timeout); ConfigurationManager.getConfigInstance().setProperty("hystrix.command.default.requestCache.enabled", false); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.maxQueueSize", getRequestQueueSize()); ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.default.queueSizeRejectionThreshold", getRequestQueueSize()); // Build TwitchMessagingInterface client = HystrixFeign.builder() .client(new OkHttpClient()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logger(new Logger.ErrorLogger()) .errorDecoder(new TwitchMessagingInterfaceErrorDecoder(new JacksonDecoder())) .logLevel(Logger.Level.BASIC) .requestInterceptor(new TwitchClientIdInterceptor(this.clientId, this.userAgent)) .retryer(new Retryer.Default(1, 10000, 3)) .options(new Request.Options(5000, TimeUnit.MILLISECONDS, 15000, TimeUnit.MILLISECONDS, true)) .target(TwitchMessagingInterface.class, baseUrl); return client; }
Example #5
Source File: VertxHttp2ClientReconnectTest.java From feign-vertx with Apache License 2.0 | 6 votes |
/** * Create a Feign Vertx client that is built once and used several times * during positive and negative test cases. * @param context */ @Before public void before(TestContext context) { // for HTTP2 test, set up the protocol and the pool size to 1. HttpClientOptions options = new HttpClientOptions(); options .setProtocolVersion(HttpVersion.HTTP_2) .setHttp2MaxPoolSize(1); client = VertxFeign .builder() .vertx(this.vertx) .options(options) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .target(HelloServiceAPI.class, "http://localhost:8091"); }
Example #6
Source File: ShopifyApiFactory.java From shopify-api-java-wrapper with Apache License 2.0 | 6 votes |
public static ShopifyApiClient create(String accessToken, String myShopifyUrl, String nodeAddress) { ShopifyRedissonManager shopifyRedissonManager = new ShopifyRedissonManager(nodeAddress, myShopifyUrl); // Prepare the request interceptors ArrayList<RequestInterceptor> requestInterceptors = new ArrayList<>(); requestInterceptors.add(new OAuthRequestInterceptor(accessToken)); requestInterceptors.add(new ContentTypeRequestInterceptor()); requestInterceptors.add(new RequestLimitInterceptor(shopifyRedissonManager)); return Feign.builder() .decoder(new ShopifyJacksonDecoder(shopifyRedissonManager)) .encoder(new JacksonEncoder()) .requestInterceptors(requestInterceptors) // .logger(new Logger.JavaLogger().appendToFile("http.log")) // .logLevel(Logger.Level.FULL) .target(ShopifyApiClient.class, myShopifyUrl); }
Example #7
Source File: BackendServiceFactory.java From jrestless-examples with Apache License 2.0 | 6 votes |
@Inject public BackendServiceFactory(InjectionManager serviceLocator) { awsLambdaClient = new AWSLambdaClient(); awsLambdaClient.configureRegion(BACKEND_SERVICE_REGION); backendService = Feign.builder() .client(FeignLambdaServiceInvokerClient.builder() .setRegion(BACKEND_SERVICE_REGION) .setFunctionName(BACKEND_SERVICE_FUNCTION_NAME) .build()) .decoder(new JacksonDecoder()) .encoder(new JacksonEncoder()) .logger(new Slf4jLogger()) .target(new LambdaServiceFunctionTarget<BackendService>(BackendService.class) { @Override public Request apply(RequestTemplate input) { // TODO inject the context directly => requires the context to be bound as proxy Context lambdaContext = serviceLocator.getInstance(Context.class); // propagate the AWS request ID => the called service can log the original AWS request ID input.header("X-Base-Aws-Request-Id", lambdaContext.getAwsRequestId()); return super.apply(input); } }); }
Example #8
Source File: SimulatedDeviceFactory.java From hawkbit-examples with Eclipse Public License 1.0 | 6 votes |
private AbstractSimulatedDevice createDdiDevice(final String id, final String tenant, final int pollDelaySec, final URL baseEndpoint, final String gatewayToken) { final ObjectMapper mapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .registerModule(new Jackson2HalModule()); final RootControllerResourceClient controllerResource = Feign.builder() .requestInterceptor(new GatewayTokenInterceptor(gatewayToken)) .contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).logLevel(Level.HEADERS) .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))).encoder(new JacksonEncoder()) .logger(new Slf4jLogger()).decode404() .target(RootControllerResourceClient.class, baseEndpoint.toString()); return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater, gatewayToken); }
Example #9
Source File: ReactiveFeignIntegrationTest.java From feign with Apache License 2.0 | 6 votes |
@Test public void testRxJavaTarget() throws Exception { this.webServer.enqueue(new MockResponse().setBody("1.0")); this.webServer.enqueue(new MockResponse().setBody("{ \"username\": \"test\" }")); TestReactiveXService service = RxJavaFeign.builder() .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logger(new ConsoleLogger()) .logLevel(Level.FULL) .target(TestReactiveXService.class, this.getServerUrl()); assertThat(service).isNotNull(); StepVerifier.create(service.version()) .expectNext("1.0") .expectComplete() .verify(); assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/version"); /* test encoding and decoding */ StepVerifier.create(service.user("test")) .assertNext(user -> assertThat(user).hasFieldOrPropertyWithValue("username", "test")) .expectComplete() .verify(); assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/users/test"); }
Example #10
Source File: FrostmourneSpiAutoConfiguration.java From frostmourne with MIT License | 6 votes |
@Bean @ConditionalOnMissingBean public IFrostmourneSpiApi frostmourneSpiApi() { if(frostmourneSpiProperties.getMock()) { return new MockFrostmourneSpi(); } return Feign.builder().options(defaultOptions()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .retryer(feignRetryer()) .client(okHttpClient) .logLevel(feignLoggerLevel()) .target(IFrostmourneSpiApi.class, frostmourneSpiProperties.getServiceAddr()); }
Example #11
Source File: LinshareExtension.java From james-project with Apache License 2.0 | 5 votes |
@VisibleForTesting static LinshareAPIForTechnicalAccountTesting from(LinshareFixture.Credential credential) { return Feign.builder() .requestInterceptor(new BasicAuthRequestInterceptor(credential.getUsername(), credential.getPassword())) .logger(new Slf4jLogger(LinshareAPIForTechnicalAccountTesting.class)) .logLevel(Logger.Level.FULL) .encoder(new FormEncoder(new JacksonEncoder())) .decoder(CombinedDecoder.builder() .defaultDecoder(new JacksonDecoder()) .registerSingleTypeDecoder(new ByteArrayDecoder()) .build()) .target(LinshareAPIForTechnicalAccountTesting.class, linshare.getUrl()); }
Example #12
Source File: LinshareExtension.java From james-project with Apache License 2.0 | 5 votes |
@VisibleForTesting static LinshareAPIForAdminTesting from(LinshareFixture.Credential credential) { return Feign.builder() .requestInterceptor(new BasicAuthRequestInterceptor(credential.getUsername(), credential.getPassword())) .logger(new Slf4jLogger(LinshareAPIForAdminTesting.class)) .logLevel(Logger.Level.FULL) .encoder(new FormEncoder(new JacksonEncoder())) .decoder(CombinedDecoder.builder() .defaultDecoder(new JacksonDecoder()) .registerSingleTypeDecoder(new ByteArrayDecoder()) .build()) .target(LinshareAPIForAdminTesting.class, linshare.getUrl()); }
Example #13
Source File: LinshareAPI.java From james-project with Apache License 2.0 | 5 votes |
@VisibleForTesting static LinshareAPI from(LinshareConfiguration configuration) { return Feign.builder() .requestInterceptor( new BasicAuthRequestInterceptor( configuration.getUuid().toString(), configuration.getPassword())) .logger(new Slf4jLogger(LinshareAPI.class)) .logLevel(Logger.Level.FULL) .encoder(new FormEncoder(new JacksonEncoder())) .decoder(new JacksonDecoder()) .target(LinshareAPI.class, configuration.getUrl().toString()); }
Example #14
Source File: LinshareExtension.java From james-project with Apache License 2.0 | 5 votes |
@VisibleForTesting static LinshareAPIForUserTesting from(LinshareFixture.Credential credential) { return Feign.builder() .requestInterceptor(new BasicAuthRequestInterceptor(credential.getUsername(), credential.getPassword())) .logger(new Slf4jLogger(LinshareAPIForUserTesting.class)) .logLevel(Logger.Level.FULL) .encoder(new FormEncoder(new JacksonEncoder())) .decoder(CombinedDecoder.builder() .defaultDecoder(new JacksonDecoder()) .registerSingleTypeDecoder(new ByteArrayDecoder()) .build()) .target(LinshareAPIForUserTesting.class, linshare.getUrl()); }
Example #15
Source File: GameClientResolver.java From codenjoy with GNU General Public License v3.0 | 5 votes |
private GameServerClient buildGameServerClient(String server) { return Feign.builder() .client(new OkHttpClient()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .errorDecoder(new ClientErrorDecoder()) .logger(new Slf4jLogger(GameServerClient.class)) .logLevel(Level.BASIC) .requestInterceptor(new BasicAuthRequestInterceptor(gameProperties.getBasicAuthUser(), Hash.md5(gameProperties.getBasicAuthPassword()))) .target(GameServerClient.class, gameProperties.getSchema() + "://" + server); }
Example #16
Source File: FeignClientFactory.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * Get the default values of this factory * * @return the feign builder to create the clients */ private Feign.Builder getDefaults() { return Feign.builder() .logLevel(FULL) .decode404() .encoder(new JacksonEncoder(this.configureMapper())) .decoder(new JacksonDecoder(this.configureMapper())); }
Example #17
Source File: ConfigurationClient.java From james-project with Apache License 2.0 | 5 votes |
static ConfigurationClient from(Host mockServerHttpHost) { return Feign.builder() .logger(new Slf4jLogger(ConfigurationClient.class)) .logLevel(Logger.Level.FULL) .encoder(new JacksonEncoder(OBJECT_MAPPER)) .decoder(new JacksonDecoder(OBJECT_MAPPER)) .target(ConfigurationClient.class, "http://" + mockServerHttpHost.asString()); }
Example #18
Source File: RabbitMQManagementAPI.java From james-project with Apache License 2.0 | 5 votes |
static RabbitMQManagementAPI from(RabbitMQConfiguration configuration) { RabbitMQConfiguration.ManagementCredentials credentials = configuration.getManagementCredentials(); return Feign.builder() .requestInterceptor(new BasicAuthRequestInterceptor(credentials.getUser(), new String(credentials.getPassword()))) .logger(new Slf4jLogger(RabbitMQManagementAPI.class)) .logLevel(Logger.Level.FULL) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .retryer(new Retryer.Default()) .errorDecoder(RETRY_500) .target(RabbitMQManagementAPI.class, configuration.getManagementUri().toString()); }
Example #19
Source File: FeignClientFactory.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * Get the default values of this factory * * @return the feign builder to create the clients */ private Feign.Builder getDefaults() { return Feign.builder() .logLevel(FULL) .decode404() .encoder(new JacksonEncoder(this.configureMapper())) .decoder(new JacksonDecoder(this.configureMapper())); }
Example #20
Source File: ReactiveFeignIntegrationTest.java From feign with Apache License 2.0 | 5 votes |
@Test public void testReactorTargetFull() throws Exception { this.webServer.enqueue(new MockResponse().setBody("1.0")); this.webServer.enqueue(new MockResponse().setBody("{ \"username\": \"test\" }")); TestReactorService service = ReactorFeign.builder() .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logger(new ConsoleLogger()) .decode404() .options(new Options()) .logLevel(Level.FULL) .target(TestReactorService.class, this.getServerUrl()); assertThat(service).isNotNull(); StepVerifier.create(service.version()) .expectNext("1.0") .expectComplete() .verify(); assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/version"); /* test encoding and decoding */ StepVerifier.create(service.user("test")) .assertNext(user -> assertThat(user).hasFieldOrPropertyWithValue("username", "test")) .expectComplete() .verify(); assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/users/test"); }
Example #21
Source File: ModuleConfigurationIntegrationClient.java From abixen-platform with GNU Lesser General Public License v2.1 | 5 votes |
@HystrixCommand(fallbackMethod = "getModulesConfigurationPropertiesFallback") public ModulesConfigurationProperties getModulesConfigurationProperties(String serviceName) { log.debug("getModulesConfigurationProperties: " + serviceName); if (discoveryClient.getInstances(serviceName).isEmpty()) { throw new PlatformCoreException("Can not find any instance for " + serviceName); } ServiceInstance serviceInstance = discoveryClient.getInstances(serviceName).get(0); ModuleConfigurationService moduleConfigurationService = Feign.builder().contract(new JAXRSContract()).encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()).target(ModuleConfigurationService.class, "http://" + serviceInstance.getHost() + ":" + serviceInstance.getPort()); return moduleConfigurationService.getModulesConfigurationProperties(); }
Example #22
Source File: SpringContractTest.java From feign with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException { mockClient = new MockClient() .noContent(HttpMethod.GET, "/health") .noContent(HttpMethod.GET, "/health/1") .noContent(HttpMethod.GET, "/health/1?deep=true") .noContent(HttpMethod.GET, "/health/1?deep=true&dryRun=true") .ok(HttpMethod.GET, "/health/generic", "{}"); resource = Feign.builder() .contract(new SpringContract()) .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .client(mockClient) .target(new MockTarget<>(HealthResource.class)); }
Example #23
Source File: FeignApiConfig.java From frostmourne with MIT License | 5 votes |
@Bean public IXxlJob xxlJobApi(Retryer retryer, Request.Options defaultOptions) { if (mock) { return new MockXxlJob(); } return Feign.builder().options(defaultOptions) .encoder(new FormEncoder(new JacksonEncoder())) .decoder(new JacksonDecoder()) .retryer(retryer) .client(okHttpClient()) .target(IXxlJob.class, xxlJobAdminHost); }
Example #24
Source File: AbstractControllerTestCase.java From research-graphql with MIT License | 5 votes |
<T> T apiSetup(Class<T> target) { return Feign.builder() .encoder(new JacksonEncoder(mapper)) .decoder(new JacksonDecoder()) .logLevel(Logger.Level.BASIC) .target(target, "http://localhost:" + port); }
Example #25
Source File: ApiClient.java From openapi-generator with Apache License 2.0 | 5 votes |
public ApiClient() { objectMapper = createObjectMapper(); apiAuthorizations = new LinkedHashMap<String, RequestInterceptor>(); feignBuilder = Feign.builder() .encoder(new FormEncoder(new JacksonEncoder(objectMapper))) .decoder(new JacksonDecoder(objectMapper)) .logger(new Slf4jLogger()); }
Example #26
Source File: OrderControllerTest.java From research-graphql with MIT License | 5 votes |
@Before public void apiSetup() { this.api = Feign.builder() .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logLevel(Logger.Level.BASIC) .target(OrderApi.class, "http://localhost:" + port); }
Example #27
Source File: UserControllerTest.java From research-graphql with MIT License | 5 votes |
@Before public void apiSetup() { this.api = Feign.builder() .encoder(new JacksonEncoder(jacksonMapper)) .decoder(new JacksonDecoder(jacksonMapper)) .logLevel(Logger.Level.BASIC) .target(UserApi.class, "http://localhost:"+port); }
Example #28
Source File: ProductControllerTest.java From research-graphql with MIT License | 5 votes |
@Before public void apiSetup() { this.api = Feign.builder() .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logLevel(Logger.Level.BASIC) .target(ProductApi.class, "http://localhost:" + port); }
Example #29
Source File: OrderAdaptor.java From research-graphql with MIT License | 5 votes |
@PostConstruct public void apiSetup() { log.info("Connecting {} to {}", OrderApi.class.getSimpleName(), properties.getUrlOrderService()); this.api = Feign.builder() .encoder(new JacksonEncoder()) .decoder(new JacksonDecoder()) .logLevel(Logger.Level.BASIC) .target(OrderApi.class, properties.getUrlOrderService()); }
Example #30
Source File: UserAdaptor.java From research-graphql with MIT License | 5 votes |
@PostConstruct public void apiSetup() { log.info("Connecting {} to {}", UserApi.class.getSimpleName(), properties.getUrlUserService()); this.api = Feign.builder() .encoder(new JacksonEncoder(jacksonMapper)) .decoder(new JacksonDecoder(jacksonMapper)) .logLevel(Logger.Level.BASIC) .target(UserApi.class, properties.getUrlUserService()); }