aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-06-02 13:05:49 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-06-02 13:05:49 +0200
commit1eeef021c65c85c24d62a0cc1ee4a746a601beb5 (patch)
tree5e2aae9e4e78709a07b39e7a79fa3ea1446e92e0
parent52084f7b4e6f50c90b3255cdf2eb9deab560c970 (diff)
downloadquartz-based-queue-1eeef021c65c85c24d62a0cc1ee4a746a601beb5.tar.gz
quartz-based-queue-1eeef021c65c85c24d62a0cc1ee4a746a601beb5.tar.bz2
quartz-based-queue-1eeef021c65c85c24d62a0cc1ee4a746a601beb5.tar.xz
quartz-based-queue-1eeef021c65c85c24d62a0cc1ee4a746a601beb5.zip
o Cleaning up dependencies.
-rw-r--r--Locking.md14
-rwxr-xr-xpom.xml83
-rw-r--r--src/main/java/io/trygvis/async/spring/SpringJdbcAsyncService.java2
-rwxr-xr-xsrc/main/java/io/trygvis/data/QueueRepository.java8
-rwxr-xr-xsrc/main/java/io/trygvis/data/TaskRepository.java11
-rwxr-xr-xsrc/test/java/io/trygvis/test/Article.java9
-rwxr-xr-xsrc/test/java/io/trygvis/test/CreateArticleCallable.java3
-rwxr-xr-xsrc/test/java/io/trygvis/test/Main.java4
-rwxr-xr-xsrc/test/java/io/trygvis/test/UpdateArticleCallable.java4
9 files changed, 55 insertions, 83 deletions
diff --git a/Locking.md b/Locking.md
new file mode 100644
index 0000000..aea1d62
--- /dev/null
+++ b/Locking.md
@@ -0,0 +1,14 @@
+Test data:
+
+ begin;
+ drop table x;
+ create table x(id integer not null primary key, value integer default random() * 1000);
+ insert into x(id) select * from generate_series(1, 100);
+ commit;
+
+Execution:
+
+ rollback;
+ begin;
+ select id from (select id from x order by value limit 10) as rows where pg_try_advisory_xact_lock(id);
+
diff --git a/pom.xml b/pom.xml
index d18496b..2527f35 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,96 +5,94 @@
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-jpamodelgen</artifactId>
- <version>1.2.0.Final</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <version>4.1.9.Final</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
</dependency>
+
+ <!-- Provided Spring dependencies -->
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>4.1.9.Final</version>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${version.spring}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
+ <artifactId>spring-tx</artifactId>
<version>${version.spring}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
+ <artifactId>spring-jdbc</artifactId>
<version>${version.spring}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
+ <artifactId>spring-beans</artifactId>
<version>${version.spring}</version>
+ <scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${version.spring}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-jpa</artifactId>
- <version>1.2.0.RELEASE</version>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
</dependency>
+
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp-spring</artifactId>
<version>0.7.1.RELEASE</version>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- <version>2.1.7</version>
- <exclusions>
- <exclusion>
- <groupId>c3p0</groupId>
- <artifactId>c3p0</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <!-- BoneCP depends on Guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
+ <scope>test</scope>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.9</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
- <version>1.7.2</version>
+ <version>${version.slf4j}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.2</version>
+ <version>${version.slf4j}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1002-jdbc4</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- </dependency>
- <dependency>
- <groupId>org.easytesting</groupId>
- <artifactId>fest-assert</artifactId>
- <version>1.4</version>
+ <scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
@@ -102,17 +100,18 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.2</version>
+ <version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
- <version>1.7.2</version>
+ <version>${version.slf4j}</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<version.spring>3.2.2.RELEASE</version.spring>
+ <version.slf4j>1.7.2</version.slf4j>
</properties>
<build>
<plugins>
diff --git a/src/main/java/io/trygvis/async/spring/SpringJdbcAsyncService.java b/src/main/java/io/trygvis/async/spring/SpringJdbcAsyncService.java
index 8517c68..327dffa 100644
--- a/src/main/java/io/trygvis/async/spring/SpringJdbcAsyncService.java
+++ b/src/main/java/io/trygvis/async/spring/SpringJdbcAsyncService.java
@@ -7,7 +7,6 @@ import io.trygvis.queue.Queue;
import io.trygvis.queue.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
@@ -15,7 +14,6 @@ import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionTemplate;
-import javax.annotation.PostConstruct;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.Executors;
diff --git a/src/main/java/io/trygvis/data/QueueRepository.java b/src/main/java/io/trygvis/data/QueueRepository.java
deleted file mode 100755
index 4ea6707..0000000
--- a/src/main/java/io/trygvis/data/QueueRepository.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package io.trygvis.data;
-
-import io.trygvis.queue.Queue;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface QueueRepository extends JpaRepository<Queue, Long> {
- Queue findByName(String name);
-}
diff --git a/src/main/java/io/trygvis/data/TaskRepository.java b/src/main/java/io/trygvis/data/TaskRepository.java
deleted file mode 100755
index c0df329..0000000
--- a/src/main/java/io/trygvis/data/TaskRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.trygvis.data;
-
-import io.trygvis.queue.Queue;
-import io.trygvis.queue.Task;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.util.List;
-
-public interface TaskRepository extends JpaRepository<Task, Long> {
- List<Task> findByQueueAndCompletedIsNull(Queue queue);
-}
diff --git a/src/test/java/io/trygvis/test/Article.java b/src/test/java/io/trygvis/test/Article.java
index d4f54ce..bf52e41 100755
--- a/src/test/java/io/trygvis/test/Article.java
+++ b/src/test/java/io/trygvis/test/Article.java
@@ -1,17 +1,8 @@
package io.trygvis.test;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
import java.util.Date;
-@Entity
public class Article {
- @Id
- @SequenceGenerator(name="id_seq", sequenceName="id_seq")
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_seq")
private Integer id;
private Date created;
private Date updated;
diff --git a/src/test/java/io/trygvis/test/CreateArticleCallable.java b/src/test/java/io/trygvis/test/CreateArticleCallable.java
index f68cd5b..a822a51 100755
--- a/src/test/java/io/trygvis/test/CreateArticleCallable.java
+++ b/src/test/java/io/trygvis/test/CreateArticleCallable.java
@@ -17,9 +17,6 @@ import static org.springframework.transaction.annotation.Propagation.MANDATORY;
public class CreateArticleCallable implements AsyncService.AsyncCallable {
private final Logger log = LoggerFactory.getLogger(getClass());
-// @PersistenceContext
-// private EntityManager entityManager;
-
private Random random = new Random();
public void run(List<String> arguments) throws Exception {
diff --git a/src/test/java/io/trygvis/test/Main.java b/src/test/java/io/trygvis/test/Main.java
index 721df61..d274101 100755
--- a/src/test/java/io/trygvis/test/Main.java
+++ b/src/test/java/io/trygvis/test/Main.java
@@ -3,7 +3,6 @@ package io.trygvis.test;
import io.trygvis.async.AsyncService;
import io.trygvis.queue.Queue;
import io.trygvis.queue.Task;
-import org.hibernate.dialect.PostgreSQL82Dialect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
@@ -31,9 +30,6 @@ public class Main {
setProperty("database.url", getProperty("jdbc.url", "jdbc:postgresql://localhost/" + username));
setProperty("database.username", username);
setProperty("database.password", username);
-// setProperty("hibernate.showSql", "true");
- setProperty("hibernate.hbm2ddl.auto", "create"); // create
- setProperty("hibernate.dialect", PostgreSQL82Dialect.class.getName());
log.info("Starting context");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
diff --git a/src/test/java/io/trygvis/test/UpdateArticleCallable.java b/src/test/java/io/trygvis/test/UpdateArticleCallable.java
index aae28b9..f50c10a 100755
--- a/src/test/java/io/trygvis/test/UpdateArticleCallable.java
+++ b/src/test/java/io/trygvis/test/UpdateArticleCallable.java
@@ -16,10 +16,6 @@ public class UpdateArticleCallable
private final Random r = new Random();
-// @PersistenceContext
-// private EntityManager entityManager;
-
-// @Transactional(propagation = REQUIRES_NEW)
public void run(List<String> arguments) throws Exception {
log.info("UpdateArticeJob.run: BEGIN");