Difference between quartz and quartz-jobs - quartz-scheduler

There are 2 dependencies for quartz. The dependency quartz(1st option below) has all the basic required classes needed for a basic job scheduling and execution. What is quartz-jobs used for?
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>2.3.0</version>
</dependency>

quartz-jobs.jar contains various optional Quartz job implementation classes that you can use in your application. There are jobs that can:
invoke an EJB method
run a native process (i.e. executable app/script)
invoke a listener if a configured file's "last modified at" timestamp changes
enqueue a JMS message in a configured JMS destination / topic
invoke a JMX bean method
send an SMTP message (email) to the configured recipient
For details, please refer to Quartz javadoc (check all classes in org.quartz.jobs package and sub-packages).

Related

Necessity for declaring RestEasy dependencies although bundled with WildFly?

According to the RESTEasy modules in WildFly documentation:
In WildFly, RESTEasy and the JAX-RS API are automatically loaded into
your deployment's classpath if and only if you are deploying a JAX-RS
application (as determined by the presence of JAX-RS annotations).
However I don't really understand this paragraph. What does it exactly mean? As an exmaple, let's say I want to use ResteasyClient in a class. My IDE tells me that I must add this dependency in the corresponding pom.xml. But then how does that go with the above quote?
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
My pom.xml already includes this:
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>20.0.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
When looking at this BOM it looks as if the resteasy-client is already included?
My IDE tells me that I must add this dependency in the corresponding pom.xml
Yes, you must declare this dependency in your pom.xml if you use the API of it, but you only need provided-scope, because as the documentation said, it is already included in your deployment's classpath. If you use only the standard api defined in wildfly-jakartaee8, you do not need this dependency.

Vertx is not available in Quarkus vertx munity web client extesions

I tried to test the reactive web client provided by vertx munity web client.
I followed the official guide Quarkus - Getting Started with Reactive.
And added the following in dependencies.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-mutiny-vertx-web-client</artifactId>
</dependency>
But when I injected Vertx as mentioned in the article, and got the CDI unsatisfied dependency exception. Vertx is not available.
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.vertx.mutiny.core.Vertx and qualifiers [#Default]
- java member: com.example.PostResourceClient#vertx
The complete codes are here.
You need to add the io.quarkus:quarkus-vertx dependency to your POM to activate the Vertx extension. io.smallrye.reactive:smallrye-mutiny-vertx-web-client is an external dependency that does not activate any extension.

How to send trace ID through kafka

Microservice1 -> kafka -> Microservice2
How do I pass the trace ID when transferring data?
and i'm using spring sleuth for makeing trace ID.
and i'm using "compile('org.springframework.kafka:spring-kafka:2.1.2.RELEASE')"
Please read the docs https://cloud.spring.io/spring-cloud-static/Finchley.SR2/single/spring-cloud.html#_sleuth_with_zipkin_over_rabbitmq_or_kafka
48.3.3 Sleuth with Zipkin over RabbitMQ or Kafka If you want to use RabbitMQ or Kafka instead of HTTP, add the spring-rabbit or
spring-kafka dependency. The default destination name is zipkin.
If using Kafka, you must set the property spring.zipkin.sender.type
property accordingly:
spring.zipkin.sender.type: kafka [Caution] Caution
spring-cloud-sleuth-stream is deprecated and incompatible with these
destinations.
If you want Sleuth over RabbitMQ, add the spring-cloud-starter-zipkin
and spring-rabbit dependencies.
The following example shows how to do so for Gradle:
Maven.
<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
We recommend that you add the dependency management through the Spring
BOM so that you need not manage versions yourself.
2
Add the dependency to spring-cloud-starter-zipkin. That way, all
nested dependencies get downloaded.
3
To automatically configure RabbitMQ, add the spring-rabbit dependency.
Gradle.
dependencyManagement { 1
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
} }
dependencies {
compile "org.springframework.cloud:spring-cloud-starter-zipkin" 2
compile "org.springframework.amqp:spring-rabbit" 3 } 1
We recommend that you add the dependency management through the Spring
BOM so that you need not manage versions yourself.
2
Add the dependency to spring-cloud-starter-zipkin. That way, all
nested dependencies get downloaded.
3
To automatically configure RabbitMQ, add the spring-rabbit dependency.

REST with JAX-RS tomcat server returning "requested resource is not available"

I was following short tutorial on creating REST api using JAX-RS. I am using Tomcat server v7.0. When I run the application on the server I get error 404-requested resource is not available.
The project is Maven based, and my pom.xml file includes the following line
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
I do not have web.xml file as a result. That was how the tutorial was achieved. I do not have index.html/jsp file. I have created two classes RESTconfig.java and BookResources.java
...import statements
#ApplicationPath("api")
public class RESTconfig extends Application {
}
...import statements
#Path("books")
public class BookResources {
#GET
#Produces(MediaType.TEXT_PLAIN)
public String books() {
return "Hello world";
}
}
My pom.xml file looks like this
<groupId>com.dere</groupId>
<artifactId>myrest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Once I run the application on the server and go to http://localhost:9090 I am able to see Tomcat home page, but if try to get data http://localhost:9090/myrest/api/books I get the 404 error, i.e requested resource is not available, I mentioned above.
Most of the examples or usage I saw online involve using web.xml and providing root of the application and using a servlet. This is my first exposure to building REST api. I may have misunderstood the whole thing or I skipped some step. I look forward for your help.
I am using Eclipse Photon for Java EE
Look at this
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
This is nothing more than basically a bunch of interfaces for the EE spec. There is no implementation. Java EE servers will have the implementation. Tomcat is not an EE server. The only part of the EE spec it will definitely have the implementation for is Servlets and JSP (the web profile). If you want an EE server, checkout Glassfish or Wildfly.
You are trying to work with the JAX-RS spec, where Tomcat for sure by default does not have an implementation for. So you need to add that implementation. The easiest implementation, IMO to get started with, is Jersey. You can simply add this dependency
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
</dependency>
and it will get you up and running. Keep the Jersey User Guide handy. It will come in use.

How to output the generated request and response from Groovy RestClient?

i am currently using the RestClient and cannot seem to figure out how to output the request xml and response xml for debugging and informational purpose...
I tried the solution mentioned here:
http://agileice.blogspot.com/2009/09/pretty-printing-xml-results-returned.html
But that fails to work, any other suggestions?
The accepted answer (turn on wire logging using log4j) is basically correct, but I've had a fair bit of trouble turning on wire logging for HTTP builder in my Groovy script. For some reason, dropping a log4j.xml file in my $GROOVY_HOME/conf directory isn't working. Ultimately, I had to just add the appropriate logging options to the groovy command when I was running it.
groovy
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
-Dorg.apache.commons.logging.simplelog.showdatetime=true
-Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG
myscript.groovy
Since it depends on HTTPClient, you could try enabling header and wire logging for your script.
http://blog.techstacks.com/2009/12/configuring-wire-logging-in-groovy-httpbuilder.html
http://hc.apache.org/httpcomponents-client-ga/logging.html
If you're using spring-boot you can set logging.level in your application properties file and use an slf4j back-end.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>