Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit d98cb0c

Browse files
authored
Merge pull request #12 from Senzing/caceres.version-0.0.2
Version 0.0.2 pre-release
2 parents d4da71b + fe01414 commit d98cb0c

24 files changed

+591
-306
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
.project
44
.classpath
55
/.settings/
6-
6+
.idea

CHANGELOG.md

+12-17
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
[markdownlint](https://dlaa.me/markdownlint/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9-
## [Unreleased]
9+
## [0.0.2] - 2021-10-06
1010

11-
- Thing 5
12-
- Thing 4
11+
### Changed in 0.0.2
1312

14-
## [1.0.1] - yyyy-mm-dd
13+
- Prep for central repo
14+
- Added Javadoc
15+
- Refactored constants for initialization parameters to make them specific to
16+
the messaging vendor
17+
- Removed some unused classes
18+
- Changed `cleanUp()` functions to `destroy()`
19+
- Changed lower case / camelCase enums to UPPER_CASE
20+
- Renamed `com.senzing.listener.senzing.*` packages to `com.senzing.listener.*`
1521

16-
### Added to 1.0.1
22+
## [0.0.1] - 2021-02-17
1723

18-
- Thing 3
19-
20-
### Fixed in 1.0.1
21-
22-
- Thing 2
23-
24-
## [1.0.0] - yyyy-mm-dd
25-
26-
### Added to 1.0.0
27-
28-
- Thing 2
29-
- Thing 1
24+
### Initial pre-release

README.md

+25-23
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Before using the Senzing Listener to create applications you will need to build
1313
To build the Senzing Listener you will need Apache Maven (recommend version 3.6.1 or later)
1414
as well as OpenJDK version 11.0.x (recommend version 11.0.6+10 or later).
1515

16-
You will also need the Senzing `g2.jar` file installed in your Maven repository.
17-
The Senzing REST API Server requires version 1.13.x or later of the Senzing API and Senzing App.
18-
In order to install `g2.jar` you must:
16+
The Senzing Listener depends on `g2.jar`. Version 2.9.0 and later of `g2.jar`
17+
is available from the Central Maven Repository. Version `2.9.x` of `g2.jar`
18+
supports all Senzing 2.x product versions. However, the Senzing Listener
19+
supports version 1.14.x or later. If you need version 1.x then you must install
20+
`g2.jar` version 1.x in your local Maven repository via the following steps:
1921

2022
1. Locate your
2123
[SENZING_G2_DIR](https://github.com/Senzing/knowledge-base/blob/master/lists/environment-variables.md#senzing_g2_dir)
@@ -133,9 +135,9 @@ This "Hello World" example will read messages from RabbitMQ and print "Hello Wor
133135
With the content:
134136

135137
```console
136-
import com.senzing.listener.senzing.service.ListenerService;
137-
import com.senzing.listener.senzing.service.exception.ServiceExecutionException;
138-
import com.senzing.listener.senzing.service.exception.ServiceSetupException;
138+
import com.senzing.listener.service.ListenerService;
139+
import com.senzing.listener.service.exception.ServiceExecutionException;
140+
import com.senzing.listener.service.exception.ServiceSetupException;
139141

140142
public class HelloWorldService implements ListenerService {
141143
@Override
@@ -155,12 +157,12 @@ This "Hello World" example will read messages from RabbitMQ and print "Hello Wor
155157
1. src/main/java/HelloWorldAPP.java
156158

157159
```console
158-
import com.senzing.listener.senzing.communication.ConsumerType;
159-
import com.senzing.listener.senzing.communication.MessageConsumer;
160-
import com.senzing.listener.senzing.communication.MessageConsumerFactory;
161-
import com.senzing.listener.senzing.service.ListenerService;
162-
import com.senzing.listener.senzing.service.exception.ServiceExecutionException;
163-
import com.senzing.listener.senzing.service.exception.ServiceSetupException;
160+
import com.senzing.listener.communication.ConsumerType;
161+
import com.senzing.listener.communication.MessageConsumer;
162+
import com.senzing.listener.communication.MessageConsumerFactory;
163+
import com.senzing.listener.service.ListenerService;
164+
import com.senzing.listener.service.exception.ServiceExecutionException;
165+
import com.senzing.listener.service.exception.ServiceSetupException;
164166

165167
public class HelloWorldApp {
166168
public static void main(String[] args) {
@@ -303,13 +305,13 @@ This example adds access to G2 to the Hello World example above.
303305
1. Modify `In your current directory create a pom file:` by adding ini file to the config (that sould be the only change)
304306

305307
```console
306-
import com.senzing.listener.senzing.communication.ConsumerType;
307-
import com.senzing.listener.senzing.communication.MessageConsumer;
308-
import com.senzing.listener.senzing.communication.MessageConsumerFactory;
309-
import com.senzing.listener.senzing.service.ListenerService;
310-
import com.senzing.listener.senzing.service.exception.ServiceExecutionException;
311-
import com.senzing.listener.senzing.service.exception.ServiceSetupException;
312-
308+
import com.senzing.listener.communication.ConsumerType;
309+
import com.senzing.listener.communication.MessageConsumer;
310+
import com.senzing.listener.communication.MessageConsumerFactory;
311+
import com.senzing.listener.service.ListenerService;
312+
import com.senzing.listener.service.exception.ServiceExecutionException;
313+
import com.senzing.listener.service.exception.ServiceSetupException;
314+
313315
public class HelloWorldApp {
314316
public static void main(String[] args) {
315317
// The required configuration, mq name and the host RabbitMQ runs on.
@@ -341,10 +343,10 @@ This example adds access to G2 to the Hello World example above.
341343
import org.json.JSONException;
342344
import org.json.JSONObject;
343345
344-
import com.senzing.listener.senzing.service.g2.G2Service;
345-
import com.senzing.listener.senzing.service.ListenerService;
346-
import com.senzing.listener.senzing.service.exception.ServiceExecutionException;
347-
import com.senzing.listener.senzing.service.exception.ServiceSetupException;
346+
import com.senzing.listener.service.g2.G2Service;
347+
import com.senzing.listener.service.ListenerService;
348+
import com.senzing.listener.service.exception.ServiceExecutionException;
349+
import com.senzing.listener.service.exception.ServiceSetupException;
348350
349351
public class HelloWorldService implements ListenerService {
350352

pom.xml

+103-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,47 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.senzing</groupId>
44
<artifactId>senzing-listener</artifactId>
5-
<version>0.0.1-SNAPSHOT</version>
5+
<packaging>jar</packaging>
6+
<version>0.0.2-SNAPSHOT</version>
67
<name>Senzing Listener Framework</name>
78
<description>Framework for creating applications receiving messages from G2 through queue</description>
8-
<properties>
9-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<maven.compiler.source>11</maven.compiler.source>
11-
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
12-
</properties>
9+
<url>http://github.com/Senzing/senzing-listener</url>
10+
<licenses>
11+
<license>
12+
<name>The Apache License, Version 2.0</name>
13+
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
14+
</license>
15+
</licenses>
16+
<distributionManagement>
17+
<snapshotRepository>
18+
<id>ossrh</id>
19+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
20+
</snapshotRepository>
21+
<repository>
22+
<id>ossrh</id>
23+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
24+
</repository>
25+
</distributionManagement>
26+
<developers>
27+
<developer>
28+
<name>Oskar Thorbjornsson</name>
29+
<email>[email protected]</email>
30+
<organization>Senzing</organization>
31+
<organizationUrl>http://www.senzing.com</organizationUrl>
32+
</developer>
33+
<developer>
34+
<name>Michael Dockter</name>
35+
<email>[email protected]</email>
36+
<organization>Senzing</organization>
37+
<organizationUrl>http://www.senzing.com</organizationUrl>
38+
</developer>
39+
<developer>
40+
<name>Pavel Alexeev</name>
41+
<email>[email protected]</email>
42+
<organization>EPAM</organization>
43+
<organizationUrl>http://hubbitus.info</organizationUrl>
44+
</developer>
45+
</developers>
1346
<dependencyManagement>
1447
<dependencies>
1548
<dependency>
@@ -30,7 +63,7 @@
3063
<dependency>
3164
<groupId>com.senzing</groupId>
3265
<artifactId>g2</artifactId>
33-
<version>[1.14.0-SNAPSHOT,)</version>
66+
<version>[1.14.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
3467
</dependency>
3568
<dependency>
3669
<groupId>com.rabbitmq</groupId>
@@ -62,15 +95,75 @@
6295
<version>1.7.5</version>
6396
</dependency>
6497
</dependencies>
98+
<properties>
99+
<gpg.skip>true</gpg.skip> <!-- skip GPG unless release profile -->
100+
<maven.compiler.source>11</maven.compiler.source>
101+
<maven.compiler.target>11</maven.compiler.target>
102+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
103+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
104+
</properties>
65105
<build>
66106
<plugins>
67107
<plugin>
68-
<artifactId>maven-compiler-plugin</artifactId>
69-
<version>3.1</version>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-source-plugin</artifactId>
110+
<version>3.2.1</version>
111+
<executions>
112+
<execution>
113+
<id>attach-sources</id>
114+
<goals>
115+
<goal>jar-no-fork</goal>
116+
</goals>
117+
</execution>
118+
</executions>
119+
</plugin>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-javadoc-plugin</artifactId>
123+
<version>3.3.0</version>
124+
<executions>
125+
<execution>
126+
<id>attach-javadocs</id>
127+
<goals>
128+
<goal>jar</goal>
129+
</goals>
130+
</execution>
131+
</executions>
132+
</plugin>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-gpg-plugin</artifactId>
136+
<version>3.0.1</version>
137+
<executions>
138+
<execution>
139+
<id>sign-artifacts</id>
140+
<phase>verify</phase>
141+
<goals>
142+
<goal>sign</goal>
143+
</goals>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
<plugin>
148+
<groupId>org.sonatype.plugins</groupId>
149+
<artifactId>nexus-staging-maven-plugin</artifactId>
150+
<version>1.6.7</version>
151+
<extensions>true</extensions>
70152
<configuration>
71-
<encoding>UTF-8</encoding>
153+
<serverId>ossrh</serverId>
154+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
155+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
72156
</configuration>
73157
</plugin>
74158
</plugins>
75159
</build>
160+
161+
<profiles>
162+
<profile>
163+
<id>release</id>
164+
<properties>
165+
<gpg.skip>false</gpg.skip>
166+
</properties>
167+
</profile>
168+
</profiles>
76169
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.senzing.listener.communication;
2+
3+
/**
4+
* Enumerates the supported consumer types.
5+
*/
6+
public enum ConsumerType {
7+
/**
8+
* Used for Rabbit MQ.
9+
*/
10+
RABBIT_MQ,
11+
12+
/**
13+
* Used for Amazon SQS.
14+
*/
15+
SQS
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.senzing.listener.communication;
2+
3+
import com.senzing.listener.communication.exception.MessageConsumerSetupException;
4+
import com.senzing.listener.service.ListenerService;
5+
6+
/**
7+
* Interface for a queue consumer.
8+
*/
9+
10+
public interface MessageConsumer {
11+
/**
12+
* Initializes the consumer.
13+
*
14+
* @param config Configuration string. It can be in JSON or other appropriate format.
15+
*
16+
* @throws MessageConsumerSetupException If a failure occurs.
17+
*/
18+
void init(String config) throws MessageConsumerSetupException;
19+
20+
/**
21+
* Consumer main function. Receives messages from message source and processes.
22+
*
23+
* @param service Processes messages
24+
*
25+
* @throws Exception If a failure occurs.
26+
*/
27+
void consume(ListenerService service) throws Exception;
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.senzing.listener.communication;
2+
3+
import com.senzing.listener.communication.exception.MessageConsumerSetupException;
4+
import com.senzing.listener.communication.rabbitmq.RabbitMQConsumer;
5+
import com.senzing.listener.communication.sqs.SQSConsumer;
6+
7+
/**
8+
* A factory class for creating instances of {@link MessageConsumer}.
9+
*/
10+
public class MessageConsumerFactory {
11+
/**
12+
* Generates a message consumer based on consumer type.
13+
*
14+
* @param consumerType The consumer type.
15+
*
16+
* @param config The configuration string for the {@link MessageConsumer}.
17+
*
18+
* @return The {@link MessageConsumer} that was created.
19+
*
20+
* @throws MessageConsumerSetupException If a failure occurs.
21+
*/
22+
public static MessageConsumer generateMessageConsumer(
23+
ConsumerType consumerType,
24+
String config)
25+
throws MessageConsumerSetupException
26+
{
27+
MessageConsumer consumer = null;
28+
29+
switch (consumerType) {
30+
case RABBIT_MQ:
31+
consumer = RabbitMQConsumer.generateRabbitMQConsumer();
32+
break;
33+
case SQS:
34+
consumer = SQSConsumer.generateSQSConsumer();
35+
break;
36+
}
37+
if (consumer == null) {
38+
StringBuilder errorMessage
39+
= new StringBuilder("Invalid message consumer specified: ")
40+
.append(consumerType);
41+
throw new MessageConsumerSetupException(errorMessage.toString());
42+
}
43+
else {
44+
consumer.init(config);
45+
return consumer;
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.senzing.listener.communication.exception;
2+
3+
/**
4+
* Exception thrown when message consumer fails initialization.
5+
*/
6+
public class MessageConsumerSetupException extends Exception {
7+
8+
private static final long serialVersionUID = 1L;
9+
10+
/**
11+
* Constructs with the specified message.
12+
* @param message The message with which to construct.
13+
*/
14+
public MessageConsumerSetupException(String message) {
15+
super(message);
16+
}
17+
18+
/**
19+
* Constructs with the specified {@link Exception} describing the
20+
* underlying failure that occurred.
21+
*
22+
* @param e The {@link Exception} descrbing the underlying failure that
23+
* occurred.
24+
*/
25+
public MessageConsumerSetupException(Exception e) {
26+
super(e);
27+
}
28+
}

0 commit comments

Comments
 (0)