Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created May 10, 2017 12:32
Show Gist options
  • Save AdamBien/b1a66dafdae21c0c40d647f05f44e57c to your computer and use it in GitHub Desktop.
Save AdamBien/b1a66dafdae21c0c40d647f05f44e57c to your computer and use it in GitHub Desktop.
39thAirhacksQ&A.md
@chermehdi
Copy link

chermehdi commented May 23, 2017

hello again,
could you please give an example on how to use jpa with a wildfly server, and how can we define the persistance unit . and inject an entity manager , (i tried defining a jta-datasource but with no luck i still find errors whenever i try to deploy my application to wildfly) please help .

Mehdi .

@marcozanghi
Copy link

Hi Adam,
what about testing of @asynchronous methods? Are there any useful libraries for that? Thanks
Marco

@dwamara
Copy link

dwamara commented May 29, 2017

Not a question but maybe an answer to @mehdithe as I normally use Wildfly in production.

  • make sure you have add the driver library as a module to your wildfly.
  • Then you can define something like this in your standalone.xml
    <datasource jndi-name="java:/jdbc/inzo24-is24-ds" pool-name="inzo24-datasource" enabled="true" statistics-enabled="true"> <connection-url>YOUR_JDBC_URL</connection-url> <driver>mysql</driver> <security> <user-name>YOUR_USERNAME</user-name> <password>YOUR_PASSWORD</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/> <background-validation>true</background-validation> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/> </validation> </datasource>
    for this I had for the driver definition
    <driver name="mysql" module="com.mysql"> <driver-class>com.mysql.jdbc.Driver</driver-class> </driver>
    In your persistence.xml
    <persistence-unit name="finance-prod" transaction-type="JTA"> <jta-data-source>java:/jdbc/inzo24-is24-ds</jta-data-source> <class>com.dwitech.eap.inzo24.finance.entity.City</class> <class>com.dwitech.eap.inzo24.finance.entity.Region</class> <class>com.dwitech.eap.inzo24.finance.entity.ZipcodeTransferTax</class> <properties> </properties> </persistence-unit>
    Then you can inject the entity manager with @PersistenceContext(unitName = "finance-prod") public EntityManager em;

@dwamara
Copy link

dwamara commented May 30, 2017

Now my question :)
Hi Adam, I wanted to know what is your take on using technologies like Wildfly Swarm or SpringBoot. I kind of love the way one can make a runnable Jar that contains the whole service and a container but I really dislike the way one ends up. with a bloated file: I wanted to test how they work and with a 750 KB war that I had for my service, I ended up with a 50+MB file. My actual VPS doesn't support Docker so I can't use containers as I would like so I end up working with "normal" application servers deployed on the system, and I was looking on trying to leverage the use of Swarm or Boot but after seeing the size of the runnable file I'm not really bought into it.

Thanks,
Daniel

@problemzebra
Copy link

problemzebra commented May 31, 2017

Hi Adam,

what are your experiences with the Java EE Batch API (JSR 352), especially JBeret (the JSR 352 implementation in JBoss EAP/Wildfly) concerning

  • Monitoring
  • Clustering
  • Scheduling (EJB timer or ScheduledExecutorService?)?
  • Resilience (what happens if a job connects to a e.g. mail server but for some reason the job runs forever because a timeout is not working?)

A typical job in our application is: (a) reading a file from imap/folder/ftp/database/… (b) doing some processing like validation, transformation, … (c) writing a file to smtp/folder/ftp/database….

Are there any established alternatives to JSR 352? When would you recommend to build a own job framework?

@sebargarcia
Copy link

sebargarcia commented Jun 2, 2017

Hi Adam,
Is there a way tu use eclipselink @Multitenant in CMT (container managed transactions)?
I use JPA (eclipselink implementation) in Payara and in my webapp I need tu use multitenant. What I see is that there are nothing standard in JPA but eclipseLink have @Multitenant. My problem is that for what i see you can only use @Multitenant in BMT (bean managed transaction) thats mean I can not inject the entityManager (
@PersistenceContext(unitName = "myPU") private EntityManager em;
)
and set the tenant dynamically.
what are your strategy tu develop multitenant app?

oh and for @mehdithe Antnios´s blog had a good entry about JWT and jax-rs:
[https://antoniogoncalves.org/2016/10/03/securing-jax-rs-endpoints-with-jwt/]

Thanks
Sebastian.

@dempile
Copy link

dempile commented Jun 4, 2017

Hi Adam,
I want to create a project with multiple java ee modules packaged in war files connected with each other with rest webservices, these wars are deployed in the same payara appserver and sharing a single database.
Is this kind of architecture suitable to build a project with large amount of data, and is having a unique database can cause performance problems ?
architect

In you opitnion what can be the architecture to build a JEE application with different business modules sharing data between them
thanks
Kiko

@jcrochavera
Copy link

Hi Adam, did you have any experience programming an scheduled MDB ?? Could you sho us an example?

Thanks

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