I am using spring boot version 2.0.0.
and I am using applicationInsight-web and core jar 2.1.0.
I have put instrumantation key in applicaionInsight.xml also.
Please refer to https://learn.microsoft.com/en-us/azure/application-insights/app-insights-java-get-started#4-add-an-http-filter
It shows how to configure Application Insights Java SDK for SpringBoot Applications.
Here are the configurations for me to make Spring-cloud + Azure Application Insight.
pom.xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>1.2.0-BETA</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.4.0-BETA</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.brave</groupId>
<artifactId>brave-opentracing</artifactId>
</dependency>
and dependenciesManagement
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>1.1.0.RC5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
logback-spring.xml
<appender name="aiAppender"
class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
<instrumentationKey>YOUR_INSTRUMENTATION_KEY</instrumentationKey>
</appender>
application.yml
azure:
application-insights:
instrumentation-key: YOUR_INSTRUMENTATION_KEY
Good luck!
Related
I am trying to upload files to oracle Object Storage using Spring Boot 3.0 and Java 17. I am getting the following exception
java.util.NoSuchElementException: No http provider available; add dependency on one of the oci-java-sdk-common-httpclient-* choices, e.g. oci-java-sdk-common-httpclient-jersey
The dependency I used:
<dependencies>
<dependency>
<groupId>com.oracle.oci.sd`your text`k</groupId>
<artifactId>oci-java-sdk-objectstorage</artifactId>
</dependency>
</dependencies>`
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-bom</artifactId>
<version>3.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I was able to upload files to Object storage with Spring Boot 2.x.x and Java 11 with the above dependency.
Just add the dependency suggested in the exception's message:
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
<version>3.2.0</version>
</dependency>
to your pom.xml file
Thank you #devwebcl. oci-java-sdk-common-httpclient-jersey was required but it wasn't sufficient. I had to add following dependency additionally.
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-addons-resteasy-client-configurator</artifactId>
</dependency>
So if someone want to upload files to object storage from Spring Boot 3, include the three dependencies below.
<dependencies>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-addons-resteasy-client-configurator</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-objectstorage</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-bom</artifactId>
<version>3.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
<version>3.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
enter code here
I'm trying to use Camel Clustering using a File lock (active/standby nodes) approach. Based on the documentation (https://camel.apache.org/manual/latest/clustering.html) it appears that in spring boot configuration file we can define the cluster details as below. The problem I have is, I don’t know which maven dependency I need to add in order to configure the below properties.
camel.component.file.cluster.service.enabled = true
camel.component.file.cluster.service.id = ${random.uuid}
camel.component.file.cluster.service.root = ${java.io.tmpdir}
My IDE is not able to recognize any such property.
pom.xml
....
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-master-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-file-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
....
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>3.4.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
....
Spring-boot version: 2.2.5.RELEASE
Any pointers would be helpful.
Currently we are upgrading our app to use spring boot 2.0.3.
The app is deployed to PCF and uses circuit breaker, also we use AbstractCloudConfig in our code in order to initialize a session and retrieve the properties for cassandra from the user provided service.
We noticed that when checking the health using actuator/health , rabbit fails and the cause is due to connection refused.
It's trying to connect to localhost instead of the host provided by the rabbit service in pcf.
After testing and debugging the app , we came to a conclusion that the issue is due to AbstractCloudConfig.
In order to verify this conclusion , we created a demo app that uses circuit breaker and also AbstractCloudConfig and we noticed the same issue, When we removed the use of AbstractCloudConfig everything was fine.
Is there a different way to use AbstractCloudConfig in spring boot 2.0.3 or this is an issue?
${spring.boot.version} = 2.0.3.RELEASE
Dependencies in pom.xml:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Kay-SR8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-circuit-breaker</artifactId>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
CloudCassandraConnectionConfig class:
#Configuration
#Profile("cloud")
public class CloudCassandraConnectionConfig extends AbstractCloudConfig
{
}
SpringCloud version:Dalston.SR1,
rabbitMQ version:3.6.10,ElasticSearch version:6.2.4
There was nothing unusual when I use MySQL as a storage.
Now I use ElasticSearch.I can't find any services.
I lost something?
here is the picture:
application.properties
server.port=11008
spring.application.name=microservice-zipkin-stream-server-es
spring.sleuth.enabled=false
spring.sleuth.sampler.percentage=1.0
zipkin.storage.StorageComponent = elasticsearch
zipkin.storage.type=elasticsearch
zipkin.storage.elasticsearch.cluster=elasticsearch-zipkin-cluster
zipkin.storage.elasticsearch.hosts=127.0.0.1:9300
zipkin.storage.elasticsearch.max-requests=64
zipkin.storage.elasticsearch.index=zipkin
zipkin.storage.elasticsearch.index-shards=5
zipkin.storage.elasticsearch.index-replicas=1
spring.rabbitmq.host=192.168.0.162
spring.rabbitmq.port=5672
spring.rabbitmq.username=basefrm
spring.rabbitmq.password=basefrm
eureka.instance.hostname=192.168.0.162
eureka.client.serviceUrl.defaultZone=http://192.168.0.162:8761/eureka/
management.security.enabled=false
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>2.4.1</version>
<optional>true</optional>
</dependency>
You're using an ancient version of Sleuth, can you please upgrade? Why do you provide Zipkin's version manually? Also as far as I see you're using the Sleuth's Zipkin server (that is deprecated in Edgware and removed in Finchley). My suggestion is that you stop using the Sleuth's Stream server (you can read more about this here https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_sleuth_with_zipkin_via_rabbitmq_or_kafka).
<dependencyManagement> (1)
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${release.train.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency> (2)
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency> (3)
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
1) In order not to pick versions by yourself it’s much better if you add the dependency management via the Spring BOM
2) Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded
3) To automatically configure rabbit, simply add the spring-rabbit dependency
I am missing AvroSchemaMessageConverter class in spring-cloud-stream-schema - 1.2.0.RC1. I want through this link Missing schema module for spring-cloud-stream.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-schema</artifactId>
<version>1.2.0.RC1</version>
</dependency>
When I looked at the pom.xml, I was anticipating the class AvroSchemaMessageConverter.java will be available in spring-cloud-stream-1.2.0.RC1.jar. But it does not exist as per the picture below:
Can someone point to the dependency I am missing. My maven dependencies for spring-cloud-stream to post to Kafka topics.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Apache avro serialization support -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-schema</artifactId>
</dependency>
</dependencies>
It's in the schema jar:
<!-- Apache avro serialization support -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-schema</artifactId>
</dependency>
Notice the full hierarchy of that GitHub Artifact...
spring-cloud-stream/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroSchemaMessageConverter.java
The link you posted explicitly mentions that you need to include org.springframework.cloud:spring-cloud-stream-schema, where AvroSchemaMessageConverter lives. You will also need to add an Avro version explicitly.