Running Locally
Requirements
In order to run this service locally, you will need the following:
- Maven 3.6.0+
- AdoptOpenJDK8
- Infrastructure dependencies, deployable through the relevant infrastructure template
- While not a strict dependency, example commands in this document use bash
General Tips
Environment Variable Management The following tools make environment variable configuration simpler
- direnv - for a shell/terminal environment
- EnvFile - for Intellij IDEA
Lombok This project uses Lombok for code generation. You may need to configure your IDE to take advantage of this tool.
Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
Note The following command can be useful to pull secrets from keyvault:
az keyvault secret show --vault-name $KEY_VAULT_NAME --name $KEY_VAULT_SECRET_NAME --query value -otsv
Required to run service
name | value | description | sensitive? | source |
---|---|---|---|---|
AZURE_TENANT_ID |
******** |
AAD tenant ID | yes | output of infrastructure deployment |
AZURE_CLIENT_ID |
******** |
AAD client ID | yes | output of infrastructure deployment |
AZURE_CLIENT_SECRET |
******** |
AAD client secret | yes | output of infrastructure deployment |
aad_client_id |
******** |
AAD client application ID | yes | output of infrastructure deployment |
KEYVAULT_URI |
ex https://foo-keyvault.vault.azure.net/
|
URI of KeyVault that holds application secrets | no | output of infrastructure deployment |
appinsights_key |
******** |
API Key for App Insights | yes | output of infrastructure deployment |
cosmosdb_database |
ex OSDU-foo | Cosmos db name having subscriptions | no | output of infrastructure deployment |
LOG_PREFIX |
notification |
Logging prefix | no | - |
entitlements_service_endpoint |
ex https://foo-entitlements.azurewebsites.net
|
Entitlements API endpoint | no | output of infrastructure deployment |
registeration_service_endpoint |
ex https://foo-register.azurewebsites.net
|
Registration Service API endpoint | no | output of infrastructure deployment |
partition_service_endpoint |
ex https://foo-partition.azurewebsites.net
|
Partition Service API endpoint | no | output of infrastructure deployment |
server_port |
8089 | Port to host service locally | no | application-specific |
maxCacheSize |
200 | cache size | no | application-specific |
spring_application_name |
notification-azure | application name | no | - |
executor_n_threads |
15 | no of executor threads running at a time | no | application-specific |
max_concurrent_calls |
15 | max concurrent calls | no | application-specific |
max_lock_renew_duration_seconds |
15 | max lock duration before time out of a message | no | application-specific |
initial_subscription_manager_delay_seconds |
0 | delay in first listening of new subscriptions | no | application-specific |
consecutive_subscription_manager_delay_seconds |
0 | delay in consecutive listening of new subscriptions | no | application-specific |
service_bus_enabled |
true | feature flag for notification V2 | no | application-specific |
event_grid_to_service_bus_enabled |
false | will be deprecated | no | application-specific |
event_grid_enabled |
false | feature flag for notification V1 | no | application-specific |
azure_entitlements_factory_enabled |
false | set to false | no | application-specific |
Configure Maven
Check that maven is installed:
$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b04/jre
...
You will need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within ~/.m2/settings.xml
:
$ cat ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>os-core</id>
<username>mvn-pat</username>
<!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
<password>$PERSONAL_ACCESS_TOKEN_GOES_HERE</password>
</server>
</servers>
</settings>
Build and run the application
After configuring your environment as specified above, you can follow these steps to build and run the application.
- Navigate to the root of the schema project, os-schema. For building the project using command line, run below command :
mvn clean install
mvn --projects notification-core,provider/notification-azure clean install
- Run schema service in command line. We need to select which cloud vendor specific schema-service we want to run. For example, if we want to run schema-service for Azure, run the below command :
# Running Azure : java -jar provider\schema-azure\target\os-notification-azure-0.0.1-SNAPSHOT-spring-boot.jar
- The port and path for the service endpoint can be configured in
application.properties
in the provider folder as following. If not specified, then the web container (ex. Tomcat) default is used:server.servlet.contextPath=/api/notification/v1/ server.port=8080
Debugging
Jet Brains - the authors of Intellij IDEA, have written an excellent guide on how to debug java programs.
Deploying service
TBD
License
Copyright © Microsoft Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.