amqp appender and log4j2 - amqp

I am trying to use amqpappender from spring amqp project in our project
See here:
http://docs.spring.io/spring-amqp/api/org/springframework/amqp/rabbit/log4j/AmqpAppender.html
But we are currently using log4j2 which I do not think amqp appender supports.
Does anyone know if amqp appender works with log4j2?

You can use Spring AMQP v.1.6.0.M1 (or hight) and log4j2 xml configuration.
Appender example:
<RabbitMQ name="rabbitmq"
host="localhost" port="5672" user="guest" password="guest" virtualHost="/"
exchange="log4j2Test" exchangeType="fanout" declareExchange="true" durable="true" autoDelete="false"
applicationId="testAppId" routingKeyPattern="%X{applicationId}.%c.%p"
contentType="text/plain" contentEncoding="UTF-8" generateId="true" deliveryMode="NON_PERSISTENT"
charset="UTF-8"
senderPoolSize="3" maxSenderRetries="5">
</RabbitMQ>

As #Illiahat pointed out, you have to use the latest (unreleased yet) version, such as 1.6.0.M2. The current version (1.5.5) does not support log4j2, that's why you'd get a RabbitMQ is not recognizable message (it cannot use the AppenderSkeleton class).
Here's a gradle configuration example that will get the logger working:
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
compile 'org.springframework.amqp:spring-rabbit:1.6.0.M2'
}
For the logger, you can use the configuration from #Illiahat.

If you are using Log4j 2, you should be able to go through an AMQP JMS provider.
For example, Apache Qpid JMS is a complete AMQP 1.0 Java Message Service 1.1 client built using Qpid Proton.
Qpid also provides an alternate JMS client supporting earlier AMQP versions.
See https://qpid.apache.org/components/jms/

Related

Netty HTTP/3 codec dependency giving an error in Gradle

I'm currently working on implementing HTTP3 server using the Gradle version 7.3 on a Ubuntu 20.04 VM. But QUIC codec (0.0.20.Final) and HTTP/3 codec (0.0.11.Final) dependencies produce the following error.
Could not find netty-incubator-codec-native-quic-0.0.25.Final-${os.detected.name}-${os.detected.arch}.jar (io.netty.incubator:netty-incubator-codec-native-quic:0.0.25.Final).
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Following are the dependencies I used
implementation 'io.netty.incubator:netty-incubator-codec-quic:0.0.20.Final:linux-x86_64'
implementation 'io.netty.incubator:netty-incubator-codec-http3:0.0.11.Final'
As a temporary solution I downloaded the jar of the dependency from here and referenced it in the build.gradle file.
implementation ("io.netty.incubator:netty-incubator-codec-quic:0.0.20.Final:linux-x86_64")
implementation (files("libs/netty-incubator-codec-http3-0.0.11.Final.jar"))
Gradle is struggling to parse the classifier for the quic dependency, which is a property defined in terms of other properties, which are meant to be detected at build-time.
To work around that, exclude the quic dependency from your http3 dependency, and instead pull in quic directly:
implementation ( "io.netty.incubator:netty-incubator-codec-http3:0.0.11.Final" ) {
exclude group: "io.netty.incubator"
}
implementation "io.netty.incubator:netty-incubator-codec-native-quic:0.0.27.Final"
runtimeOnly ( group: "io.netty.incubator", name: "netty-incubator-codec-native-quic", classifier: "osx-x86_64" )
runtimeOnly ( group: "io.netty.incubator", name: "netty-incubator-codec-native-quic", classifier: "linux-x86_64" )

Forcing flink to use different kafka-clients jar

i am using Flink Connector Kafka 1.8.0. (depends on kafka-clients 2.0.1)
https://mvnrepository.com/artifact/org.apache.flink/flink-connector-kafka_2.12/1.8.0
using gradle:
// https://mvnrepository.com/artifact/org.apache.flink/flink-connector-kafka
compile group: 'org.apache.flink', name: 'flink-connector-kafka_2.12', version: '1.8.0'
i wonder if i can force it to use kafka-clients 2.4.0
i wodering if flink supports it, and even so, how it can be configured through
gradle?
can you assist?
Yes, you can configure that by simply explicitly including the dependency with the version that you want
compile group: 'org.apache.flink', name: 'flink-connector-kafka_2.12', version: '1.8.0'
compile group: 'org.apache.kafka', name: 'kafka_2.13', version: '2.4.0'
You can test which version has been chosen with
gradle dependencies

Spark integration with spring boot web starter

I am trying to integrate Spark application with spring boot but since spark core also has jetty server and servlet packages, they are conflicting with spring boot web starter servlet packages.
I already followed the post below to exclude starter-logging
https://www.linkedin.com/pulse/integrating-spark-spring-boot-neeraj-malhotra
I tried excluding servlet from spark core package, but it wouldn't start up or build using gradle build.
My goal is to run this app as a Rest API using spring boot web starter.
Thanks
I found the solution a long time ago, but couldn't post this.
I had to exclude a bunch of packages from spark-core that contain servlet packages
compile(group: 'org.apache.spark', name: 'spark-core_2.11', version: '1.6.0') {
exclude group: 'org.slf4j', module: 'slf4j-simple'
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
exclude group: 'com.sun.jersey', module: 'jersey-server'
exclude group: 'com.sun.jersey', module: 'jetty-core'
exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
//exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}

Opentok SDK not Spring-boot compliant due new Jackson 2.9 release

My Spring-boot application started failing once Jackson 2.9 was released on 2nd of March. I am using Gradle for building and Spring boot version 1.5.2 which depends on Jackson-core 2.8.7.
In addition I need Opentok SDK which I have added as dependency:
compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '2.3.2'
I suppose the reason is the Opentok SDK dependency definition which allows downloading newer JAR for Jackson which then creates a mismatch of libraries as several versions of Jackson JARs are downloaded:
https://github.com/opentok/Opentok-Java-SDK/blob/master/build.gradle
dependencies {
...
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '[2.3.1,2.99999)'
How to sort this out?
I am not an expert of Gradle but could I somehow force Opentok to use 2.8.7 version?
I cannot deliver at the moment at all so please help.
I think this should be useful: https://docs.gradle.org/current/userguide/dependency_management.html#sub:version_conflicts
As well as the guide here: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html#N1627D
Approaches might differ, but you can set Gradle to force = true for Spring's jackson-databind dependency.
This is how I sorted it out
compile ('com.tokbox:opentok-server-sdk:2.3.2')
{
// Jackson 2.9 is not compatible with Spring boot 1.4.4 - 1.5.2
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}

How to specify redis client dependency for logback-redis-appender

How to specify latest redis client dependency for logback-redis-appender in gradle
https://mvnrepository.com/artifact/com.cwbase/logback-redis-appender/1.1.5
I want to use 2.9.0 dependency of https://mvnrepository.com/artifact/redis.clients/jedis instead of 2.5.2 being used right now.
Add to build.gradle:
compile group: 'redis.clients', name: 'jedis', version: '2.9.0'
or
dependencies {
compile "redis.clients:jedis:2.9.0"
}

Resources