Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active December 14, 2019 21:52
Show Gist options
  • Save AdamBien/46045e87888329caa3f8c29b2d56f3ea to your computer and use it in GitHub Desktop.
Save AdamBien/46045e87888329caa3f8c29b2d56f3ea to your computer and use it in GitHub Desktop.
69thAirhacksQ&A.md

Ask questions and see you at December, 9th, 8pm CET: http://www.ustream.tv/channel/adambien

Also checkout recent episode:

68 airhacks.tv

Please keep the questions Jakarta EE-stic. Means: as short and as concise as only possible. Feel free to ask several, shorter questions.

@wodarski
Copy link

wodarski commented Nov 18, 2019

Is it possible using MicroProfile JWT for Authentication but fetch user groups/roles from an external webservice instead of JWT groups claim for Authorization?

@ciment7
Copy link

ciment7 commented Nov 20, 2019

Hello Adam,

Is it possible to setup timeout for JAX-RS endpoints globally? I use payara 5.191. In admin console, I found in network settings and also in http listener some properties to setup timeout, but it doesn`t work.

Finally I used @timeout annotation from microprofile library, which it works, but only when I do some business logic without calling rest client. This annotation doesnt work when I do rest call to fetch data from other microservice. (my explanation why it doesnt work: establishing an HTTP connection and then reading from it are blocking operations. Interrupting the thread has no effect. )

Could you give me some examples how to setup max timeout for JAX-RS endpoints? Thanks.

@ciment7
Copy link

ciment7 commented Nov 20, 2019

Do you have some best practice how to use jersey client effectively?

In my Java EE application, I created Client -> ClientBuilder.newClient(..) as singleton with Lock.READ

....
 @Lock(LockType.READ)
    public WebTarget target(String url) {
        return client.target(url);
    }.....

I have performance issue in my microservice-oriented application. In distributed tracing, I see suspicious behaviour. Microservice A fetched some data from microservice B and it took 10 s, but from perspective of microservice B, executing took only 200ms. It seems like network problem or problem to use transport layer effectively by jersey client.

This behaviour can only see during high load. I changed singleton to stateless EJB, but no difference. I used connection - HttpPoolingConnectionManager with ApacheConnectorProvider, but also no change.

Thanks.

@mlemnian
Copy link

mlemnian commented Nov 20, 2019

Hi Adam,

  1. Who would you prevent cascading service calls (like Service A --> Service B --> ... -->Severice Z) in a micro service landscape with multiple dev-teams.

  2. Who can I prevent (or detect) that my micro service architecture "evolves" into a SOA-Hell. Fun Fact: My customer tries to create an REST-API integration layer for all business applications, which is in fact an ESB with JSON and REST instead of XML and SOAP.

Many Thanks,
Martin

@mb-dbc-dk
Copy link

Do you have some best practice how to use jersey client effectively?

In my Java EE application, I created Client -> ClientBuilder.newClient(..) as singleton with Lock.READ

....
 @Lock(LockType.READ)
    public WebTarget target(String url) {
        return client.target(url);
    }.....

I have performance issue in my microservice-oriented application. In distributed tracing, I see suspicious behaviour. Microservice A fetched some data from microservice B and it took 10 s, but from perspective of microservice B, executing took only 200ms. It seems like network problem or problem to use transport layer effectively by jersey client.

This behaviour can only see during high load. I changed singleton to stateless EJB, but no difference. I used connection - HttpPoolingConnectionManager with ApacheConnectorProvider, but also no change.

Thanks.

@ciment7 You've probably already checked, but since it looks like a situation, that we've run into, I just want to validate. Do your service B have enough http-worker threads? For instance for payara-micro (as far as I can read) this defaults to 10, which quite often isn't enough, if your service spends more than a few ms in processing.

@ciment7
Copy link

ciment7 commented Nov 22, 2019

Do you have some best practice how to use jersey client effectively?
In my Java EE application, I created Client -> ClientBuilder.newClient(..) as singleton with Lock.READ

....
 @Lock(LockType.READ)
    public WebTarget target(String url) {
        return client.target(url);
    }.....

I have performance issue in my microservice-oriented application. In distributed tracing, I see suspicious behaviour. Microservice A fetched some data from microservice B and it took 10 s, but from perspective of microservice B, executing took only 200ms. It seems like network problem or problem to use transport layer effectively by jersey client.
This behaviour can only see during high load. I changed singleton to stateless EJB, but no difference. I used connection - HttpPoolingConnectionManager with ApacheConnectorProvider, but also no change.
Thanks.

@ciment7 You've probably already checked, but since it looks like a situation, that we've run into, I just want to validate. Do your service B have enough http-worker threads? For instance for payara-micro (as far as I can read) this defaults to 10, which quite often isn't enough, if your service spends more than a few ms in processing.

@mb-dbc-dk yes. I setup 200 http threads, and also I use bulkhead pattern with porcupine library . For asynchronous processing I use other tread-pool with 300 threads.

@cbustamantem
Copy link

Hi Adam!!
What would be the best practice for this issue, i have several microservices proyects, and each one require some parts of others, Example, the service of Credits, requiere the entities of the clients service, and so on, for that reason, my solution was to create a common project for each service, (client-commons, credits-commons) when i need a entity or a data structure from another i use the "commons parts" like a maven dependency, is any other elegant solution for this?

Thanks.

@ares3
Copy link

ares3 commented Dec 2, 2019

Hi Adam,
thanks for providing this very informatic and pragmatic content to the community. Also airhacks.fm makes my way to the office nice.

You mentioned in one of your last episodes that you are building a hardware cluster. How is the status? Could you please provide a little bit more information about this project.

In the past you had an episode where you bought your private server hardware, I found this episode also very interesting.

Thank you!

@robert-niestroj
Copy link

robert-niestroj commented Dec 3, 2019

Hi,
question about microservices architecture and reporting. Let's say you are doing software for the environmental ministry have following domian-oriented microservices and :

  • companies
  • water
  • air
  • wastes
  • forests

Now you need to do a report for a certain company which does buisness in air and water. The report needs to be exported to PDF or Excel.

How you design this?
Where you put the logic for aggregating data from 3 microservices?
Where you have the components to export data to Excel or PDF?
Does each microservices have Apache POI for Excel and iText for PDF creation?

@sjetesjete
Copy link

Hi Adam,
could you please comment on https://thoughts-on-java.org/dont-expose-entities-in-api/ ? What are your experiences towards that?

Greetings from Frankfurt am Main.

@whyvrafvr
Copy link

whyvrafvr commented Dec 9, 2019

Hi Adam.

Thanks a lot for your work, you’re awesome 😎!

Do you know if it possible to use Microprofile config with DataSource annotation?
Payara offers a specific Tag ${MPCONFIG-foo} but it’s necessary to declare the variable foo using asadmin command line.
I guess we cannot use the default property file at the present time.

Working with docker and Kubernetes, we’ve decided to use environment variables but if you have a tip about using the microprofile properties, that’s perfect 👌

@ciment7
Copy link

ciment7 commented Dec 9, 2019

Hi Adam,
Do you have some experience how to protect open api endpoint generated by microprofile library to fetch open api files?
I don`t want to expose my API on production.

Thanks

@srnjak
Copy link

srnjak commented Dec 14, 2019

Hi Adam,

I have a project, where JUnit5 is used as testing framework. I would like to add some integration tests for JAX-RS functionality. After searching on internet, it became obvious that Arquillian doesn't support this version of JUnit.

What would be the best approach to make it possible to run Arquillian?
I was thinking about having JUnit5 and 4 as testing dependencies in the same project, but - is that even possible?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment