Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
883d9519
authored
Jan 09, 2020
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
adjust test
parent
adaa72f1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
24 deletions
build.gradle
src/main/java/microservice/services/IPubSubServicePulsarImpl.java → src/main/java/microservice/service/pubsub/service/microservice/IPubSubServicePulsarImpl.java
src/test/java/microservice/TestMicroserviceApp.java
build.gradle
View file @
883d9519
...
...
@@ -47,6 +47,13 @@ sourceSets {
compileClasspath
+=
sourceSets
.
clients
.
runtimeClasspath
}
test
{
compileClasspath
+=
sourceSets
.
common
.
runtimeClasspath
compileClasspath
+=
sourceSets
.
servicePubsub
.
runtimeClasspath
compileClasspath
+=
sourceSets
.
clients
.
runtimeClasspath
compileClasspath
+=
sourceSets
.
app
.
runtimeClasspath
}
}
dependencies
{
...
...
@@ -110,7 +117,7 @@ dependencies {
task
commonJar
(
type:
Jar
)
{
from
configurations
.
commonCompile
.
collect
{
zipTree
it
}
from
sourceSets
.
common
.
output
version
=
'1.0.
0
'
version
=
'1.0.
1
'
archiveName
=
"microservice-common.jar"
destinationDir
=
file
(
"build/common"
)
}
...
...
@@ -119,7 +126,7 @@ task commonJar(type: Jar) {
task
servicePubsubJar
(
type:
Jar
)
{
dependsOn
commonJar
mustRunAfter
commonJar
from
configurations
.
servicePubsubCompile
.
collect
{
zipTree
it
}
//
from configurations.servicePubsubCompile.collect { zipTree it }
from
sourceSets
.
servicePubsub
.
output
version
=
'1.0.0'
archiveName
=
"microservice-service-pubsub.jar"
...
...
@@ -130,7 +137,7 @@ task servicePubsubJar(type: Jar) {
task
clientsJar
(
type:
Jar
)
{
dependsOn
commonJar
mustRunAfter
commonJar
from
configurations
.
clientsCompile
.
collect
{
zipTree
it
}
//
from configurations.clientsCompile.collect { zipTree it }
from
sourceSets
.
clients
.
output
version
=
'1.0.0'
archiveName
=
"microservice-clients.jar"
...
...
@@ -233,6 +240,14 @@ publishing {
// adding dependencies
pom
.
withXml
{
def
dependenciesNode
=
asNode
().
appendNode
(
'dependencies'
)
configurations
.
clientsCompile
.
dependencies
.
each
{
if
(
it
.
group
!=
null
&&
it
.
name
!=
null
){
def
dependencyNode
=
dependenciesNode
.
appendNode
(
'dependency'
)
dependencyNode
.
appendNode
(
'groupId'
,
it
.
group
)
dependencyNode
.
appendNode
(
'artifactId'
,
it
.
name
)
dependencyNode
.
appendNode
(
'version'
,
it
.
version
)
}
}
}
artifact
clientsJar
}
...
...
@@ -243,6 +258,14 @@ publishing {
// adding dependencies
pom
.
withXml
{
def
dependenciesNode
=
asNode
().
appendNode
(
'dependencies'
)
configurations
.
servicePubsubCompile
.
dependencies
.
each
{
if
(
it
.
group
!=
null
&&
it
.
name
!=
null
){
def
dependencyNode
=
dependenciesNode
.
appendNode
(
'dependency'
)
dependencyNode
.
appendNode
(
'groupId'
,
it
.
group
)
dependencyNode
.
appendNode
(
'artifactId'
,
it
.
name
)
dependencyNode
.
appendNode
(
'version'
,
it
.
version
)
}
}
}
artifact
servicePubsubJar
}
...
...
src/main/java/microservice/service
s
/IPubSubServicePulsarImpl.java
→
src/main/java/microservice/service
/pubsub/service/microservice
/IPubSubServicePulsarImpl.java
View file @
883d9519
package
microservice
.
services
;
package
service
.
microservice
;
import
common.microservice.context.PubSubMsg
;
import
common.microservice.defs.Constants
;
import
common.microservice.defs.Enums
;
import
common.microservice.io.iface.IApp
;
import
common.microservice.io.iface.ILogger
;
import
common.microservice.io.iface.IServiceDiscovery
;
import
common.microservice.services.CommonServices
;
import
common.microservice.utils.IDGenerator
;
import
microservice.MicroserviceApp
;
import
microservice.handlers.Reactor
;
import
microservice.params.PulsarParams
;
import
common.microservice.params.PulsarParams
;
import
org.apache.pulsar.client.admin.PulsarAdmin
;
import
org.apache.pulsar.client.admin.PulsarAdminException
;
import
org.apache.pulsar.client.admin.Tenants
;
...
...
@@ -28,6 +27,8 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
java.util.regex.Pattern
;
import
static
common
.
microservice
.
services
.
CommonServices
.
buildServiceKey
;
/**
* This class implements PubSubService for Apache Pulsar
...
...
@@ -81,16 +82,16 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
}
@Override
public
boolean
init
()
{
public
boolean
init
(
IApp
app
)
{
final
MicroserviceApp
microserviceApp
=
MicroserviceApp
.
getsInstance
()
;
if
(
microserviceA
pp
!=
null
)
{
clientId
=
microserviceA
pp
.
getAppName
()
+
'-'
+
microserviceA
pp
.
getServerName
()
+
'-'
+
microserviceA
pp
.
getId
();
this
.
app
=
app
;
if
(
a
pp
!=
null
)
{
clientId
=
a
pp
.
getAppName
()
+
'-'
+
a
pp
.
getServerName
()
+
'-'
+
a
pp
.
getId
();
logger
=
MicroserviceApp
.
getsInstance
()
.
getLogger
();
namespacePrefix
=
TOPIC_PREFIX
+
"/"
+
microserviceA
pp
.
getAppName
();
logger
=
app
.
getLogger
();
namespacePrefix
=
TOPIC_PREFIX
+
"/"
+
a
pp
.
getAppName
();
}
else
{
// for tests where there is no MicroserviceApp
namespacePrefix
=
TOPIC_PREFIX
+
"/"
+
"testApp"
;
...
...
@@ -167,7 +168,7 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
if
(
topic
.
length
()
>
namespacePrefix
.
length
()
&&
topic
.
startsWith
(
namespacePrefix
))
{
topic
=
topic
.
substring
(
namespacePrefix
.
length
());
String
key
=
Reactor
.
buildServiceKey
(
Enums
.
EnumServiceType
.
E_PUBSUB
,
String
key
=
buildServiceKey
(
Enums
.
EnumServiceType
.
E_PUBSUB
,
CommonServices
.
EnumPubSubCommands
.
E_NOTIFY
,
topic
);
reactor
.
delegate
(
this
,
key
,
msgCtx
);
...
...
@@ -334,9 +335,8 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
* wildcard topic:
* {persistent|non-persistent}://<tenant>/<namespace>/<regular expression>
*/
final
MicroserviceApp
microserviceApp
=
MicroserviceApp
.
getsInstance
();
String
pattern
=
namespacePrefix
+
"/.*"
;
adminValidateTenantAndNamespace
(
Constants
.
DEFAULT_TENANT
,
microserviceA
pp
.
getAppName
());
adminValidateTenantAndNamespace
(
Constants
.
DEFAULT_TENANT
,
a
pp
.
getAppName
());
Pattern
allTopicsInNamespace
=
Pattern
.
compile
(
pattern
);
consumer
=
client
.
newConsumer
(
JSONSchema
.
of
(
PubSubMsg
.
class
))
.
subscriptionName
(
clientId
)
...
...
src/test/java/microservice/TestMicroserviceApp.java
View file @
883d9519
package
microservice
;
import
clients.microservice.impl.IRestClientHttpImpl
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.JsonNodeFactory
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
common.microservice.context.RestContext
;
import
common.microservice.defs.Enums
;
import
common.microservice.io.iface.IRestClient
;
import
common.microservice.params.*
;
import
common.microservice.services.CommonServices
;
import
common.microservice.io.iface.IRestClient
;
import
microservice.io.impl.*
;
import
services.impl.IRestServiceHttpImpl
;
import
services.impl.IRestServiceZmqImpl
;
import
common.microservice.types.BaseRestResponse
;
import
microservice.io.impl.IRestServerRMQImpl
;
import
microservice.io.impl.IRestServerUndertowImpl
;
import
microservice.io.impl.IServiceDiscoveryConsulImpl
;
import
microservice.service.pubsub.impl.IRestServiceHttpImpl
;
import
microservice.service.pubsub.impl.IRestServiceZmqImpl
;
import
microservice.utils.ServiceBuilderFactory
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.junit.Test
;
...
...
@@ -37,7 +39,7 @@ public class TestMicroserviceApp {
String
appName
=
"testApp"
;
//ILogger logger = new ILogger4jImpl(appName);
microservice
.
MicroserviceApp
msApp
=
new
microservice
.
MicroserviceApp
(
appName
);
MicroserviceApp
msApp
=
new
microservice
.
MicroserviceApp
(
appName
);
msApp
.
withMetrics
()
//.withDefaultServiceAuthorization()
.
withPubSub
(
new
microservice
.
io
.
impl
.
IPubSubMQTTImpl
(
"tcp://localhost"
,
0
,
null
,
0
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment