consumer

Is adapting a no-arg method into a Consumer bad form?

蓝咒 提交于 2019-12-07 18:48:48
问题 Someone raised a question on another SO Answer about whether it is bad practice or inefficient to do this: Optional<User> user = ... user.ifPresent(u -> doSomethingWithoutUser()); instead of if (user.isPresent()) doSomethingWithoutUser(); Specifically, the fact that we're adapting a zero-arg method into a Consumer<User> which ignores its parameter u . As this isn't a Stream non-terminal operation, the fact doSomethingWithoutUser() likely has side-effects isn't a concern. I'm not bothered

DotNetOpenAuth OAuth 1.0a Consumer automation

若如初见. 提交于 2019-12-06 14:08:15
I've question regarding automation with oAuth 1.0a. I need to access a REST API at a oAuth provider on behalf of a user. The provider has oAuth version 1.0a implemented. At forehand excuse my ignorance on oAuth, it's new territory for me. I'm working on a .NET MVC 5 project and installed the NuGet Package as follows: "Install-Package DotNetOpenAuth.OAuth.Consumer". This installed the following: Attempting to gather dependencies information for package 'DotNetOpenAuth.OAuth.Consumer.4.3.4.13329' with respect to project ' projectname ', targeting '.NETFramework,Version=v4.6.1'... successfully

Is adapting a no-arg method into a Consumer bad form?

好久不见. 提交于 2019-12-06 06:30:35
Someone raised a question on another SO Answer about whether it is bad practice or inefficient to do this: Optional<User> user = ... user.ifPresent(u -> doSomethingWithoutUser()); instead of if (user.isPresent()) doSomethingWithoutUser(); Specifically, the fact that we're adapting a zero-arg method into a Consumer<User> which ignores its parameter u . As this isn't a Stream non-terminal operation, the fact doSomethingWithoutUser() likely has side-effects isn't a concern. I'm not bothered about the specifics of this one-line Optional example, it could the result of a long chain of functional

PHP OAuth 1.0 Library that handles an api key/secret pair and endpoints (request,authorization,and access)

試著忘記壹切 提交于 2019-12-06 06:17:36
I'm working with an OAuth 1.0 API that requires we use an API KEY/PAIR. Also, it gives me 3 urls: Request token endpoint: /oauth/request_token Authorization endpoint: /oauth/authorize Access token endpoint: /oauth/access_token Here is what the documentation states: We use the most current specification of OAuth 1.0 protocol (RFC 5849) to authenticate our API requests. We use OAuth 1.0 because it is an open standard, and we adapt the "three-legged" client/user/server protocol flow of OAuth 1.0 to a "two-legged" client/server model . In our adaptation of OAuth for authenticated client/server

Why System.out::println is slower than anonymous class implementation in Java 8?

浪子不回头ぞ 提交于 2019-12-05 07:48:28
问题 I was working with some Java 8 Stream APIs. I am confused to see the performance difference between below two solutions, that are just printing the contents of Stream . Solution 1: int[] array = new int[] { 0, 1, 2, 3, 4, 5 }; start = System.nanoTime(); Arrays.stream(array).forEach(System.out::println); System.out.println((System.nanoTime() - start) / 1000000.0f); Solution 2: int[] array = new int[] { 0, 1, 2, 3, 4, 5 }; start = System.nanoTime(); Arrays.stream(array).forEach(new IntConsumer(

java concurrency: multi-producer one-consumer

假装没事ソ 提交于 2019-12-05 00:43:45
问题 I have a situation where different threads populate a queue (producers) and one consumer retrieve element from this queue. My problem is that when one of these elements are retrieved from the queue some is missed (missing signal?). The producers code is: class Producer implements Runnable { private Consumer consumer; Producer(Consumer consumer) { this.consumer = consumer; } @Override public void run() { consumer.send("message"); } } and they are created and run with: ExecutorService executor

Topic can't be found when producing messages: UNKNOWN_TOPIC_OR_PARTITION

给你一囗甜甜゛ 提交于 2019-12-04 19:34:57
问题 I have a two-nodes kafka cluster (EC2 instances) where each node is used as a separate broker. When I run a producer on the leader instance with the following command: kafka-console-producer.sh --broker-list localhost:9092 --topic test I get the following errors. test message [2017-01-09 13:22:39,483] WARN Error while fetching metadata with correlation id 0 : {test=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient) [2017-01-09 13:22:39,562] WARN Error while fetching metadata

Consuming Spring Hateoas Pageable

醉酒当歌 提交于 2019-12-04 07:12:11
I have a Rest-Service using HAteoas, what worked before without pageing. Now I am producing pageable Json. I did it with out-of-the box features from Spring-Hateoas. But now I am stucking consuming it and I guess it is really not well documented, if it is. My JSON looks like follows: { "_embedded": { "vertragResourceList": [ { "identifier": 728, "auszubildender": "Rumm", "beruf": "Landwirt/in", "betrieb": "Mitterbauer Johann", "betriebsNummer": "e12d0949-67ae-4134-9dc2-fb67758b6b16", "zustaendigeStelle": "Irgendwo", "beginn": 529887600000, "status": "RECENT", "fachrichtung": null, "schwerpunkt

Kafka consumer fails to consume if first broker is down

你说的曾经没有我的故事 提交于 2019-12-04 03:38:00
问题 I'm using latest version of kafka(kafka_2.12-1.0.0.tgz). I have setup simple cluster with 3 brokers(just changed broker.id=1 and listeners=PLAINTEXT://:9092 in properties file for each instance).After cluster is up I created topic with the following command ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 13 --topic demo then start kafka consumer and producers with the following commands ./kafka-console-producer.sh --topic demo --broker-list localhost

Why System.out::println is slower than anonymous class implementation in Java 8?

[亡魂溺海] 提交于 2019-12-03 21:53:07
I was working with some Java 8 Stream APIs. I am confused to see the performance difference between below two solutions, that are just printing the contents of Stream . Solution 1: int[] array = new int[] { 0, 1, 2, 3, 4, 5 }; start = System.nanoTime(); Arrays.stream(array).forEach(System.out::println); System.out.println((System.nanoTime() - start) / 1000000.0f); Solution 2: int[] array = new int[] { 0, 1, 2, 3, 4, 5 }; start = System.nanoTime(); Arrays.stream(array).forEach(new IntConsumer() { @Override public void accept(int value) { System.out.println(value); } }); System.out.println(