diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-06-09 23:51:39 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-06-09 23:51:39 +0200 |
commit | abb0b2aaf4ee5e6f147987401c9b059e5a7679d2 (patch) | |
tree | bf8aeed0f29a2b81896cd48df399e133b7ebb4e0 /src/test/java | |
parent | 1c0fc92c719f3856653d0efcc5fe4a1fa30b7bac (diff) | |
download | quartz-based-queue-abb0b2aaf4ee5e6f147987401c9b059e5a7679d2.tar.gz quartz-based-queue-abb0b2aaf4ee5e6f147987401c9b059e5a7679d2.tar.bz2 quartz-based-queue-abb0b2aaf4ee5e6f147987401c9b059e5a7679d2.tar.xz quartz-based-queue-abb0b2aaf4ee5e6f147987401c9b059e5a7679d2.zip |
wip
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/io/trygvis/test/DbUtil.java | 13 | ||||
-rw-r--r-- | src/test/java/io/trygvis/test/PlainJavaExample.java | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/test/java/io/trygvis/test/DbUtil.java b/src/test/java/io/trygvis/test/DbUtil.java index a2c41d3..46459b0 100644 --- a/src/test/java/io/trygvis/test/DbUtil.java +++ b/src/test/java/io/trygvis/test/DbUtil.java @@ -6,7 +6,10 @@ import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; import javax.sql.DataSource; import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import static java.lang.System.getProperty; @@ -48,4 +51,14 @@ public class DbUtil { public static DataSource springifyDataSource(DataSource ds) { return new TransactionAwareDataSourceProxy(new LazyConnectionDataSourceProxy(ds)); } + + public static int getPid(Connection c) throws SQLException { + int pid; + try (Statement statement = c.createStatement()) { + ResultSet rs = statement.executeQuery("SELECT pg_backend_pid()"); + rs.next(); + pid = rs.getInt(1); + } + return pid; + } } diff --git a/src/test/java/io/trygvis/test/PlainJavaExample.java b/src/test/java/io/trygvis/test/PlainJavaExample.java index 488ee35..788d8a0 100644 --- a/src/test/java/io/trygvis/test/PlainJavaExample.java +++ b/src/test/java/io/trygvis/test/PlainJavaExample.java @@ -4,6 +4,7 @@ import io.trygvis.async.SqlEffect; import io.trygvis.async.SqlEffectExecutor; import io.trygvis.queue.JdbcQueueService; import io.trygvis.queue.Queue; +import io.trygvis.queue.QueueService; import io.trygvis.queue.QueueSystem; import io.trygvis.queue.Task; import io.trygvis.queue.TaskEffect; @@ -51,7 +52,9 @@ public class PlainJavaExample { final Queue input = queues[0]; final Queue output = queues[1]; - queueService.consumeAll(input, new TaskEffect() { + QueueService.TaskExecutionRequest req = new QueueService.TaskExecutionRequest(false); + + queueService.consumeAll(input, req, new TaskEffect() { public List<Task> apply(Task task) throws Exception { System.out.println("PlainJavaExample$Consumer.consumeAll: arguments = " + task.arguments); Long a = Long.valueOf(task.arguments.get(0)); |