You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2019/07/22 13:02:58 UTC

[tomee] branch tomee-7.1.x updated (039e454 -> 099bac0)

This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a change to branch tomee-7.1.x
in repository https://gitbox.apache.org/repos/asf/tomee.git.


    from 039e454  Use javaagent-7.1.2-SNAPSHOT
     new 3d7b1e7  Provide some detail on configuring XA datasources
     new 8187679  Adding sample XA config for popular databases
     new 099bac0  Merge branch 'tomee-7.1.x' of github.com:jgallimore/tomee into tomee-7.1.x

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/configuring-datasources-xa.adoc | 349 +++++++++++++++++++++++++++++++++++
 1 file changed, 349 insertions(+)
 create mode 100644 docs/configuring-datasources-xa.adoc


[tomee] 03/03: Merge branch 'tomee-7.1.x' of github.com:jgallimore/tomee into tomee-7.1.x

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch tomee-7.1.x
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 099bac067a45d353bc150c3d5a971609cfbdaf79
Merge: 8187679 039e454
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Mon Jul 22 14:02:39 2019 +0100

    Merge branch 'tomee-7.1.x' of github.com:jgallimore/tomee into tomee-7.1.x

 docs/java-compatibility.adoc                       |   6 +
 examples/mp-config-example/README.adoc             |  67 ++++++
 examples/mp-config-example/README_es.adoc          |  70 ++++++
 examples/mp-config-example/README_pt.adoc          |  71 ++++++
 examples/mp-config-example/pom.xml                 | 104 +++++++++
 .../java/org/superbiz/config/PropertiesRest.java   |  80 +++++++
 .../src/main/resources/META-INF/beans.xml          |   0
 .../META-INF/microprofile-config.properties        |   3 +
 .../org/superbiz/config/PropertiesRestTest.java    |  53 +++++
 .../src/test/resources/arquillian.xml              |  30 +++
 examples/mp-config-source-database/README.adoc     |  14 ++
 examples/mp-config-source-database/pom.xml         | 146 ++++++++++++
 .../config/source/database/ApplicationBean.java    |  47 ++++
 .../source/database/DatabaseConfigSource.java      |  93 ++++++++
 ...rg.eclipse.microprofile.config.spi.ConfigSource |  17 ++
 .../src/main/tomee/conf/tomee.xml                  |  21 ++
 .../tomee/lib/import-config-source-database.sql    |  19 ++
 .../source/database/DatabaseConfigSourceTest.java  |  55 +++++
 .../src/test/resources/arquillian.xml              |  37 +++
 examples/mp-faulttolerance-fallback/README.adoc    | 125 ++++++++++
 examples/mp-faulttolerance-fallback/README_es.adoc | 125 ++++++++++
 examples/mp-faulttolerance-fallback/pom.xml        | 119 ++++++++++
 .../rest/WeatherDayStatusFallbackHandler.java      |  36 +++
 .../java/org/superbiz/rest/WeatherException.java   |  20 ++
 .../java/org/superbiz/rest/WeatherService.java     |  60 +++++
 .../java/org/superbiz/rest/WeatherServiceTest.java |  74 ++++++
 .../src/test/resources/arquillian.xml              |  30 +++
 .../src/test/resources/beans.xml                   |   7 +
 examples/mp-faulttolerance-retry/README.adoc       | 255 +++++++++++++++++++++
 examples/mp-faulttolerance-retry/pom.xml           | 105 +++++++++
 .../java/org/superbiz/rest/WeatherGateway.java     | 115 ++++++++++
 .../rest/WeatherGatewayBusyServiceException.java   |  20 ++
 .../rest/WeatherGatewayTimeoutException.java       |  21 ++
 .../java/org/superbiz/rest/WeatherService.java     |  73 ++++++
 .../java/org/superbiz/rest/WeatherServiceTest.java |  94 ++++++++
 .../src/test/resources/arquillian.xml              |  30 +++
 .../src/test/resources/beans.xml                   |   7 +
 examples/mp-faulttolerance-timeout/README.adoc     | 108 +++++++++
 examples/mp-faulttolerance-timeout/pom.xml         | 107 +++++++++
 .../java/org/superbiz/rest/WeatherGateway.java     |  49 ++++
 .../java/org/superbiz/rest/WeatherService.java     |  39 ++++
 .../java/org/superbiz/rest/WeatherServiceTest.java |  66 ++++++
 .../src/test/resources/arquillian.xml              |  30 +++
 .../src/test/resources/beans.xml                   |   7 +
 examples/mp-opentracing-traced/README.adoc         |  63 +++++
 examples/mp-opentracing-traced/pom.xml             | 105 +++++++++
 .../src/test/resources/arquillian.xml              |  30 +++
 examples/pom.xml                                   |   5 +
 examples/simple-cmp2/pom.xml                       |   2 +-
 pom.xml                                            |   2 +-
 50 files changed, 2860 insertions(+), 2 deletions(-)


[tomee] 01/03: Provide some detail on configuring XA datasources

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch tomee-7.1.x
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 3d7b1e7a13e4f4f0d662ae6a240a55b94413176e
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Fri Jul 12 16:44:21 2019 +0100

    Provide some detail on configuring XA datasources
---
 docs/configuring-datasources-xa.adoc | 161 +++++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)

diff --git a/docs/configuring-datasources-xa.adoc b/docs/configuring-datasources-xa.adoc
new file mode 100644
index 0000000..8619806
--- /dev/null
+++ b/docs/configuring-datasources-xa.adoc
@@ -0,0 +1,161 @@
+= XA DataSource Configuration
+:index-group: Datasource
+:jbake-date: 2019-07-12
+:jbake-type: page
+:jbake-status: published
+
+== Introduction
+
+XA datasources are able to participate in global transactions involving
+more than one resource - for example, scenarios where a transaction needs 
+to encompass connections to two different databases,, or a database and
+a JMS resource. 
+
+The global transaction manager will provide a two phase commit for all
+the resources enlisted in the transaction - if any of the commit
+operations fail, then all the resources in the global transaction will
+be rolled back.
+
+JTA can still be used with non-XA datasources, however the datasource will
+use a local transaction as opposed to a global transaction.
+
+JDBC drivers providing XA capabilities provide an implementation of
+`javax.sql.XADataSource`. This makes them a little more tricky to configure
+than non-XA datasources. The general technique is to configure an instance
+of the vendor-provided `XADataSource` implementation, and to then point
+the usual non-XA resource at this instance. Sounds complex? Let's walk
+through an example. We'll also provide tested example configs for a number
+of well known databases at the end of this document.
+
+== Example
+
+In this example, we'll look at MySQL. First off, download the MySQL driver
+from: https://dev.mysql.com/downloads/connector/j/. Once you have the .jar
+file, add it to the TomEE `lib` directory. This driver provides the 
+`com.mysql.cj.jdbc.MysqlXADataSource` class. The properties that need to 
+be configured vary between datasources, so we'll need to get a list of the
+properties and work out the values to set.
+
+From the TomEE bin directory, execute the following command:
+`./tomee.sh setters -c com.mysql.cj.jdbc.MysqlXADataSource` on *nix systems,
+or 
+
+`tomee.bat setters -c com.mysql.cj.jdbc.MysqlXADataSource` on Windows systems.
+
+This will give a complete list of paramaters that are available for the XA 
+datasource. We'll simply use the `URL` paramater for the datasource.
+
+```
+  <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="com.mysql.cj.jdbc.MysqlXADataSource">
+    Url jdbc:mysql://192.168.37.202:3306/movie
+  </Resource>
+```
+
+Next, we create a JtaManaged datasource as we normally would, and point it to the
+XA datasource using the `XaDataSource` attribute.
+
+```
+  <Resource id="demo/jdbc/XADataSource" type="DataSource">
+    XaDataSource demo/jdbc/XADataSourceXA
+    JdbcDriver  com.mysql.cj.jdbc.Driver
+    JdbcUrl jdbc:mysql://192.168.37.202:3306/movie
+    username root
+    password my-secret-pw
+    JtaManaged true
+    InitialSize 10
+    MaxActive 128
+    MaxIdle 25
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    ValidationQuery select null from dual
+  </Resource>
+```
+
+And finally, a non-JTA managed datasource as well:
+
+```
+  <Resource id="demo/jdbc/XADataSourceUnmanaged" type="DataSource">
+    JdbcDriver com.mysql.cj.jdbc.Driver
+    JdbcUrl jdbc:mysql://192.168.37.202:3306/movie
+    UserName root
+    password my-secret-pw
+    JtaManaged false
+    InitialSize 10
+    MaxActive 100
+    MaxIdle 50
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    ValidationQuery select null from dual
+  </Resource>
+```
+
+== Sample configs
+
+=== Oracle
+
+```
+  <Resource id="demo/jdbc/XADataSource" type="DataSource">
+    XaDataSource demo/jdbc/XADataSourceXA
+    JdbcDriver  oracle.jdbc.OracleDriver
+    JdbcUrl jdbc:oracle:thin:@//192.168.37.214:1521/XE
+    username system
+    password my-cool-password
+    JtaManaged true
+    InitialSize 10
+    MaxActive 128
+    MaxIdle 25
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    PoolPreparedStatements true
+    MaxOpenPreparedStatements 1024
+    ValidationQuery select null from dual
+  </Resource>
+
+  <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="oracle.jdbc.xa.client.OracleXADataSource">
+    Url jdbc:oracle:thin:@//192.168.37.214:1521/XE
+  </Resource>
+
+  <Resource id="demo/jdbc/XADataSourceUnmanaged" type="DataSource">
+    JdbcDriver oracle.jdbc.OracleDriver
+    JdbcUrl jdbc:oracle:thin:@//192.168.37.214:1521/XE
+    UserName system
+    password my-cool-password
+    JtaManaged false
+    InitialSize 10
+    MaxActive 100
+    MaxIdle 50
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    PoolPreparedStatements true
+    MaxOpenPreparedStatements 1024
+    ValidationQuery select null from dual
+  </Resource>
+```
+
+
+
+=== Microsoft SQL Server
+
+=== MySQL
+
+=== PostgreSQL
+
+=== Derby
+
+=== NuoDB
\ No newline at end of file


[tomee] 02/03: Adding sample XA config for popular databases

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch tomee-7.1.x
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 81876790b458ef9686e9c62f885e0ed38a9a42b8
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Mon Jul 22 13:56:49 2019 +0100

    Adding sample XA config for popular databases
---
 docs/configuring-datasources-xa.adoc | 200 +++++++++++++++++++++++++++++++++--
 1 file changed, 194 insertions(+), 6 deletions(-)

diff --git a/docs/configuring-datasources-xa.adoc b/docs/configuring-datasources-xa.adoc
index 8619806..bbc58df 100644
--- a/docs/configuring-datasources-xa.adoc
+++ b/docs/configuring-datasources-xa.adoc
@@ -71,7 +71,7 @@ XA datasource using the `XaDataSource` attribute.
     TestWhileIdle true
     TimeBetweenEvictionRuns 1 minute
     MaxWaitTime 0 seconds
-    ValidationQuery select null from dual
+    ValidationQuery select 1
   </Resource>
 ```
 
@@ -93,7 +93,7 @@ And finally, a non-JTA managed datasource as well:
     TestWhileIdle true
     TimeBetweenEvictionRuns 1 minute
     MaxWaitTime 0 seconds
-    ValidationQuery select null from dual
+    ValidationQuery select 1
   </Resource>
 ```
 
@@ -120,7 +120,7 @@ And finally, a non-JTA managed datasource as well:
     MaxWaitTime 0 seconds
     PoolPreparedStatements true
     MaxOpenPreparedStatements 1024
-    ValidationQuery select null from dual
+    ValidationQuery select 1 from dual
   </Resource>
 
   <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="oracle.jdbc.xa.client.OracleXADataSource">
@@ -144,18 +144,206 @@ And finally, a non-JTA managed datasource as well:
     MaxWaitTime 0 seconds
     PoolPreparedStatements true
     MaxOpenPreparedStatements 1024
-    ValidationQuery select null from dual
+    ValidationQuery select 1 from dual
   </Resource>
 ```
 
+=== Microsoft SQL Server
+
+```
+  <Resource id="demo/jdbc/XADataSource" type="DataSource">
+    XaDataSource demo/jdbc/XADataSourceXA
+    JdbcDriver  com.microsoft.sqlserver.jdbc.SQLServerDriver
+    JdbcUrl jdbc:sqlserver://yourserver.database.windows.net:1433;database=test
+    username sa
+    password my-secret-pw1
+    JtaManaged true
+    InitialSize 10
+    MaxActive 128
+    MaxIdle 25
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    PoolPreparedStatements true
+    MaxOpenPreparedStatements 1024
+    ValidationQuery select 1
+  </Resource>
 
+  <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="com.microsoft.sqlserver.jdbc.SQLServerXADataSource">
+    URL jdbc:sqlserver://yourserver.database.windows.net:1433;database=test
+  </Resource>
 
-=== Microsoft SQL Server
+  <Resource id="demo/jdbc/XADataSourceUnmanaged" type="DataSource">
+    JdbcDriver com.microsoft.sqlserver.jdbc.SQLServerDriver
+    JdbcUrl jdbc:sqlserver://yourserver.database.windows.net:1433;database=test
+    UserName sa
+    password my-secret-pw1
+    JtaManaged false
+    InitialSize 10
+    MaxActive 100
+    MaxIdle 50
+    MinIdle 10
+    AccessToUnderlyingConnectionAllowed true
+    TestOnBorrow false
+    TestWhileIdle true
+    TimeBetweenEvictionRuns 1 minute
+    MaxWaitTime 0 seconds
+    PoolPreparedStatements true
+    MaxOpenPreparedStatements 1024
+    ValidationQuery select 1
+  </Resource>
+```
+
+Please note that using XA with Microsoft SQL Server requires the MS DTC to be configured correctly, and sqljdbc_xa.dll to be installed. For instructions, please see this Microsoft article: https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-xa-transactions?view=sql-server-2017
 
 === MySQL
 
+```
+  <resources>
+    <Resource id="demo/jdbc/XADataSource" type="DataSource">
+      XaDataSource demo/jdbc/XADataSourceXA
+      JdbcDriver  com.mysql.cj.jdbc.Driver
+      JdbcUrl jdbc:mysql://192.168.37.202:3306/movie
+      username root
+      password my-secret-pw
+      JtaManaged true
+      InitialSize 10
+      MaxActive 128
+      MaxIdle 25
+      MinIdle 10
+      AccessToUnderlyingConnectionAllowed true
+      TestOnBorrow false
+      TestWhileIdle true
+      TimeBetweenEvictionRuns 1 minute
+      MaxWaitTime 0 seconds
+      ValidationQuery select 1
+
+    <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="com.mysql.cj.jdbc.MysqlXADataSource">
+      Url jdbc:mysql://192.168.37.202:3306/movie
+    </Resource>
+
+    <Resource id="demo/jdbc/XADataSourceUnmanaged" type="DataSource">
+      JdbcDriver com.mysql.cj.jdbc.Driver
+      JdbcUrl jdbc:mysql://192.168.37.202:3306/movie
+      UserName root
+      password my-secret-pw
+      JtaManaged false
+      InitialSize 10
+      MaxActive 100
+      MaxIdle 50
+      MinIdle 10
+      AccessToUnderlyingConnectionAllowed true
+      TestOnBorrow false
+      TestWhileIdle true
+      TimeBetweenEvictionRuns 1 minute
+      MaxWaitTime 0 seconds
+      ValidationQuery select 1
+    </Resource>
+  </resources>
+```
+
 === PostgreSQL
 
+```
+  <resources>
+    <Resource id="demo/jdbc/XADataSource" type="DataSource">
+      XaDataSource demo/jdbc/XADataSourceXA
+      JdbcDriver org.postgresql.Driver 
+      JdbcUrl jdbc:postgresql://192.168.37.200:5432/movie
+      username postgres
+      password mysecretpassword
+      JtaManaged true
+      InitialSize 10
+      MaxActive 128
+      MaxIdle 25
+      MinIdle 10
+      AccessToUnderlyingConnectionAllowed true
+      TestOnBorrow false
+      TestWhileIdle true
+      TimeBetweenEvictionRuns 1 minute
+      MaxWaitTime 0 seconds
+      PoolPreparedStatements true
+      MaxOpenPreparedStatements 1024
+      ValidationQuery select 1
+    </Resource>
+
+    <Resource id="demo/jdbc/XADataSourceXA" type="XADataSource" class-name="org.postgresql.xa.PGXADataSource">
+      URL jdbc:postgresql://192.168.37.200:5432/movie
+    </Resource>
+
+    <Resource id="demo/jdbc/XADataSourceUnmanaged" type="DataSource">
+      JdbcDriver org.postgresql.Driver
+      JdbcUrl jdbc:postgresql://192.168.37.200:5432/movie
+      UserName postgres
+      password mysecretpassword
+      JtaManaged false
+      InitialSize 10
+      MaxActive 100
+      MaxIdle 50
+      MinIdle 10
+      AccessToUnderlyingConnectionAllowed true
+      TestOnBorrow false
+      TestWhileIdle true
+      TimeBetweenEvictionRuns 1 minute
+      MaxWaitTime 0 seconds
+      PoolPreparedStatements true
+      MaxOpenPreparedStatements 1024
+      ValidationQuery select 1
+    </Resource>
+  </resources>
+```
+
 === Derby
 
-=== NuoDB
\ No newline at end of file
+```
+  <resources>
+    <Resource id="movieDatabaseXA" type="javax.sql.XADataSource" class-name="org.apache.derby.jdbc.ClientXADataSource">
+      DatabaseName=testdb
+      CreateDatabase=create
+      ServerName=localhost
+      PortName=1527
+      UserName=admin
+      Password=admin
+    </Resource>
+    <Resource id="movieDatabase" type="DataSource">
+      JdbcDriver org.apache.derby.jdbc.ClientDriver
+      JdbcUrl  jdbc:derby://localhost:1527/testdb;create=true
+      XaDataSource=movieDatabaseXA
+      UserName=admin
+      Password=admin
+      ValidationQuery=values 1
+      InitialSize=2
+      MaxActive=128
+      MaxIdle=25
+      MinIdle=10
+      TestWhileIdle=true
+      TestOnBorrow=false
+      TestOnReturn=false
+      AccessToUnderlyingConnectionAllowed=true
+      TimeBetweenEvictionRuns=1 minute
+      MaxWaitTime=0 seconds
+      JtaManaged=true
+    </Resource>
+    <Resource id="movieDatabaseUnmanaged" type="DataSource">
+      JdbcDriver org.apache.derby.jdbc.ClientDriver
+      JdbcUrl  jdbc:derby://localhost:1527/testdb;create=true
+      UserName admin
+      Password admin
+      ValidationQuery=values 1
+      InitialSize=2
+      MaxActive=128
+      MaxIdle=25
+      MinIdle=10
+      TestWhileIdle=true
+      TestOnBorrow=false
+      TestOnReturn=false
+      AccessToUnderlyingConnectionAllowed=true
+      TimeBetweenEvictionRuns=1 minute
+      MaxWaitTime=0 seconds
+      JtaManaged=false
+    </Resource>
+  </resources>
+```