Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override layers in the profiles. Add a new profile to use the postgre… #16

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,33 @@ CREATE DATABASE
podman run -it -e POSTGRES_PASSWORD=123 -e POSTGRES_USER=batch_user -e POSTGRES_DB=batch_db -p 5432:5432 postgres
```

Then you need to enable the prostrgres profile. This can be done with `-Ppostgres` or `-Dpostgres`.
Then you need to enable the `postgres` profile. This can be done with `-Ppostgres` or `-Dpostgres`.

```bash
$ mvn wildfly:dev -Ppostgres
```

or:

```bash
$ mvn wildfly:dev -Ppostgres-ds
```

Here's the console output of from the server:

If you'd like to use the `postgresql-datasource` layer instead of the `postgresql-driver` layer, this can be enabled with
the `-Ppostgres-ds` or `-Dpostgres.ds` arguments. The layer being used simply depends on if you want to use CLI to
create the data source or have the layer create it for you.

```bash
$ mvn wildfly:dev -Ppostgres-ds
```

or:

```bash
$ mvn wildfly:dev -Dpostgres.ds
```

```txt
01:28:43,076 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/jsr352/batch_db]
Expand Down
2 changes: 1 addition & 1 deletion deployment/add-h2-ds.cli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
xa-data-source add --name=batch_db --enabled=true --use-java-context=true --use-ccm=true --jndi-name=java:jboss/jsr352/batch_db --xa-datasource-properties={"URL"=>"jdbc:h2:/tmp/batch_db"} --driver-name=h2 --password=sa --user-name=sa --same-rm-override=false --no-recovery=true
xa-data-source add --name=batch_db --enabled=true --use-java-context=true --use-ccm=true --jndi-name=java:jboss/jsr352/batch_db --xa-datasource-properties={"URL"=>"jdbc:h2:/tmp/batch_db;DB_CLOSE_ON_EXIT=FALSE"} --driver-name=h2 --password=sa --user-name=sa --same-rm-override=false --no-recovery=true
/subsystem=batch-jberet/jdbc-job-repository=batch_db:add(data-source=batch_db)
/subsystem=batch-jberet/:write-attribute(name=default-job-repository, value=batch_db)
2 changes: 2 additions & 0 deletions deployment/enable-jdbc-job-repo.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/subsystem=batch-jberet/jdbc-job-repository=batch_db:add(data-source=PostgreSQLDS)
/subsystem=batch-jberet/:write-attribute(name=default-job-repository,value=batch_db)
62 changes: 52 additions & 10 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.maven.wildfly.plugin}</version>
<configuration>
<!-- These environment variables are required if you are using the `postgresql-datasource` instead of the `postgresql-driver` in below.-->
<!-- <env>-->
<!-- <POSTGRESQL_DATABASE>batch_db</POSTGRESQL_DATABASE>-->
<!-- <POSTGRESQL_PASSWORD>123</POSTGRESQL_PASSWORD>-->
<!-- <POSTGRESQL_URL>jdbc:postgresql://localhost:5432/batch_db</POSTGRESQL_URL>-->
<!-- <POSTGRESQL_USER>batch_user</POSTGRESQL_USER>-->
<!-- </env>-->
<provisioning-dir>${jboss.home}</provisioning-dir>
<galleon-options>
<jboss-fork-embedded>${galleon.fork.embedded}</jboss-fork-embedded>
Expand All @@ -108,13 +101,10 @@
</feature-pack>
</feature-packs>
<layers>
<!-- The `postgresql-datasource` layer provides a `PostgreSQLDS` datasource by default.-->
<!-- <layer>postgresql-datasource</layer>-->
<layer>core-tools</layer>
<layer>batch-jberet</layer>
<layer>h2-driver</layer>
<layer>jaxrs-server</layer>
<layer>postgresql-driver</layer>
</layers>
<channels>
<channel>
Expand Down Expand Up @@ -193,6 +183,58 @@
<properties>
<configure.ds.script>${project.basedir}/add-postgresql-ds.cli</configure.ds.script>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<layers>
<layer>core-tools</layer>
<layer>batch-jberet</layer>
<layer>jaxrs-server</layer>
<layer>postgresql-driver</layer>
</layers>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>postgres-ds</id>
<activation>
<property>
<name>postgres.ds</name>
</property>
</activation>
<properties>
<configure.ds.script>${project.basedir}/enable-jdbc-job-repo.cli</configure.ds.script>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<!-- These environment variables are required if you are using the `postgresql-datasource` instead of the `postgresql-driver` in below.-->
<env>
<POSTGRESQL_JNDI>java:jboss/jsr352/batch_db</POSTGRESQL_JNDI>
<POSTGRESQL_DATABASE>batch_db</POSTGRESQL_DATABASE>
<POSTGRESQL_PASSWORD>123</POSTGRESQL_PASSWORD>
<POSTGRESQL_URL>jdbc:postgresql://localhost:5432/batch_db</POSTGRESQL_URL>
<POSTGRESQL_USER>batch_user</POSTGRESQL_USER>
</env>
<layers>
<!-- The `postgresql-datasource` layer provides a `PostgreSQLDS` datasource by default.-->
<layer>postgresql-datasource</layer>
<layer>core-tools</layer>
<layer>batch-jberet</layer>
<layer>jaxrs-server</layer>
</layers>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>