Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
26thAirhacksQ&A.md
@mart-dominguez

This comment has been minimized.

Copy link

commented Apr 16, 2016

Hi Adam, I'moving about 14 ear and 18 war (some ears has more than a war) from a two layers architecture (1 layer is a Glassfish 3.1.1.2 AppServer which uses JEE6 and the other layer is the databases, wich is acceded through JPA - HIbernate 4 implementation) to a 3 layers architecture, where EJB, and Hibernate are in the backend, and they are accesed via REST (we 've had some problems with RMI), and JSF 2 with CDI are in the frontend.

Now we are decoupling some wars in a "microservices" aproach and moving them to WildFly (using swarm).

My question is,

  • in JSF when a request is processed, is done in a single thread, which in the front end which usually need to make a request to backend, so the thread is paused and blocked, until you get the answer and finish the request processing.
  • It works like this? In blocking mode? Is there any way to work with JSF2 in non-blocking mode? I know JavaNIO I've used is small smoketests but only in servlets, not in JSF
  • shoul I use Concurrency Utilities (JSR 236) to solve the problem, i.e every call to backend would be managed by a executor.
  • We are also analyzing to move the frontend to NodeJS (and use Angular2 or ReactJS for the view, for some funcionanlities), wich works in a event aproach. For us it's imporatn reduce the response time, because we have in peek time 2000 users concurrent. ¿Do you think it's suitable?
  • Another alternative I'm thinking about, is to serve Angular2 javascript from WildFly, and put in the front end, a RestAPI as a gateway to work with RestAPI in backend. But in that case, I will face the same problem, JAX-RS neither work on Non Blocking mode? Or is possible to configure it in that mode?

Thanks

@gbourant

This comment has been minimized.

Copy link

commented Apr 20, 2016

Hey Adam !

  • I'm using an interface for different payment methods.How to inject the right implementation based on "payment-type" at run time ?
@Stateless
@Path("payments")
public class PaymentManager {

    @Inject
    Payment pay;

    @POST
    @Path("{id}/{payment-type}")
    public void pay(){
          pay.Debit();
    }
}
  • After a successful payment the product has to be shipped but , there is a restriction , it can be shipped only after two minutes have passed.Since threads are forbidden , how to execute the shipping after the restriction ends ?
  • I'm using JAX-RS and i'm receving the request in Json format.If the client doesn't specify the charset "Content-Type : application/json; charset=utf-8" , the json it's serialized in no utf-8 format.I tried to use servlet filter to manipulate the content type header but i couldn't achieve it.Is there a way to specify to serialize as uft-8 ?

Thank you so much !

@comdotlinux

This comment has been minimized.

Copy link

commented Apr 27, 2016

Hey Adam,
I was wondering what you do when you encounter methods that you would need to use again and again?
e.g. format an IBAN / Credit card number / phone number?
I usually would put them in Utils but I know that you prohibit Technical names, so if this method is going to be needed at different places then how do we achieve this?

Thanks a million.

@danilopiazza

This comment has been minimized.

Copy link

commented Apr 27, 2016

Hi Adam,

what is your opinion about using BPM and/or a workflow engine in a project?

I have been searching the blog for posts like "How to kill a BPM project" or "The state of workflow engine tools" :)

@UlrichCech

This comment has been minimized.

Copy link

commented Apr 28, 2016

Hi Adam,

I am currently designing and implementing a new JavaEE-Application from scratch, so I could follow strictly the BCE-structure and DDD.

I have two questions:
1.) How to deal correctly with serialization in ViewScoped/SessionScoped "CDI"-beans?

@javax.faces.view.ViewScoped
public class BusinessController implements Serializable {
   @Inject
   EntityManager entityManager;
}

=> results in "Non-serializable field 'entityManager' in a Serializable class". Can I ignore this IDE-hints (I know, that only the CDI-proxy-objects are "serialized") or has ignoring this hint some other bad side effect?

2.) I am also injecting JPA-entities, which works initially fine via
@Inject Provider<EntityType> entity;
But, do you have a "best-practice" for updating/merging/refreshing the concrete injected entity (when this object needs to be replaced, eg. when calling:
entity = em.merge(entity);
so, when you have to use the result of the merge-method?

Thanks in advance,
Ulrich

@luiz-daniel

This comment has been minimized.

Copy link

commented Apr 28, 2016

Hello Adam.

How you implement multitenan[t/cy] in java ee?

Thanks

Luiz Daniel Soares

@antoniovl

This comment has been minimized.

Copy link

commented May 1, 2016

Hi Adam,
This question is related to the previous one from Luiz Daniel. I have a JavaEE 6 App using JSF in the presentation side and EJB for business logic, both modules packed in an EAR. I'd want to improve it implementing multi tenancy.
I've seen Spring based REST APIs who use ThreadLocal storage to pass along tenant information through the workflow. It´s possible to use a similar approach in JavaEE? The same thread that processes the request in JSF also executes the EJB methods?
Thank you
Antonio

@carunkumar

This comment has been minimized.

Copy link

commented May 2, 2016

Hi Adam,

I currently have a application in production with JSF2.2 (Richfaces) + Spring + JPA2.1. Since Richfaces is going on EOL by June '16, we are thinking of migrating to the obvious choice, Primefaces. But in the FAQ and also in the blog by Brian Leathem, it is mentioned to migrate to HTML5 and Javascript frameworks.

https://developer.jboss.org/wiki/RichFacesEnd-Of-LifeQuestionsAnswers

Moving to primefaces is less cost comparatively to Javascript framework like AngularJS.

What is your opinion on this? My application is new to production and expecting lot of changes to system in future.

Thank you,
Arun

@rabbink

This comment has been minimized.

Copy link

commented May 4, 2016

Hi Adam,

Do you happen to know any source code analysis tooling with transaction support (preferably not cloud based)? Ideally I would like to scan an existing code base and generate feedback about, for example, illogical creation of new or suspension of active transactions.

Thanks!

@VeitWeber

This comment has been minimized.

Copy link

commented May 6, 2016

Hi Adam,
How would you structure application wide used classes in ECB? In your examples you are going to structure your applications like:
com.comp.app.business.posts.entitiy.Post
How would a class 'BaseEntity' ,which is the base class of all entities, fit in ECB?
Thanks!

@kro-git-hub

This comment has been minimized.

Copy link

commented May 8, 2016

Hi Adam,

i'm using your wildfly-ping example to deploy the ping.war into wildfly in a docker container. Everythings works fine, but how can i redeploy the changed ping.war into wildfly without restarting the container. Stopping the container takes a long time, so no fast redeployment is possible in this way.

Thanks.

@anmiralles

This comment has been minimized.

Copy link

commented May 8, 2016

Hi Adam,

how to handle distributed systems concerns with microservices such as:

  • Service discovery, have you use any platform like snoopEE? Which is the best in your opinion?
  • Distributed transaction services, maybe with rest endpoints modeled as staless EJBs?
  • Logging and debugging for the whole project.

Thanks in advanced ;)

@paolizq

This comment has been minimized.

Copy link

commented May 9, 2016

Hi Adam,

I'm trying to configure security with a jdbc realm on an application bundled up as a fat jar with payara micro, but I just can't seem to get it to work. I've tried to run the jar with the --domainConfig option and a domain.xml with the configuration for the jdbc realm and when I try to log in to the application I get the error that "No LoginModules configured for fileRealm". However if I set the alternate domain.xml within the application using PayaraMicro.setAlternateDomainXML() I get "No LoginModules configured for jdbcRealm". (At least the correct realm).

I already deployed my application using the full payara server and it works. So I don't know what I could be doing wrong or what steps I might be missing to get this to work on payara micro. Do you have any ideas?

@AlbozDroid

This comment has been minimized.

Copy link

commented May 9, 2016

Hi Adam,

How would you tackle from the performance perspective the traversing of JPA relationships.
Here is an example:

Class RiskAssessment{
        ...
        List<Step> steps; // one-to-many
}

Class Step{
        ...
        List<HazardType > hazardTypes; // one-to-many
}

Class HazardType{
        ...
        List<Hazard> hazards; // one-to-many
}

Class Hazard{
        ...
        List<Control> controls; // one-to-many
}

Given a RiskAssessment id, I'd like to load all the Hazard and Control objects associated with it.

List<Hazard> loadAllHazardsAndControls(Integer riskAssessmentId){
......
}

I'd like to access the DB as few times as possible.I know that using nested to loops is not efficient as I would fall into the N+1 query issue.

How would you tackle this problem? Using JPQL queries and chaching query_results? If a second call to the method loadAllHazardsAndControls() occurs with the same Id parameter I would like my query(or my way to load the relationships) to remain completely In Memory.

Thanks in advance!

@Abdelmuniem

This comment has been minimized.

Copy link

commented May 9, 2016

Hi Adam Bien,

I want to Develop Java EE Website, with multi-language(Arabic and English) with JSF.

Arabic is read right to left, layout, fonts are different.
Do i have to maintain two different websites, one for Arabic and the second for English ?
http://www.mydomain.com/ar
http://www.mydomain.com/en

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.