首页 » 2019年7月

这个报错是因为kafka server的版本过低,建议更换kafka server

完整报错

java.lang.IllegalArgumentException: Magic v1 does not support record headers
    at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:403)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:442)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:499)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:522)
    at org.apache.kafka.clients.producer.internals.ProducerBatch.tryAppend(ProducerBatch.java:107)
    at org.apache.kafka.clients.producer.internals.RecordAccumulator.append(RecordAccumulator.java:222)
    at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:814)
    at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:768)
    at org.springframework.kafka.core.DefaultKafkaProducerFactory$CloseSafeProducer.send(DefaultKafkaProducerFactory.java:384)
    at brave.kafka.clients.TracingProducer.send(TracingProducer.java:106)
    at org.springframework.kafka.core.KafkaTemplate.doSend(KafkaTemplate.java:368)
    at org.springframework.kafka.core.KafkaTemplate.send(KafkaTemplate.java:183)
    at tv.rr.messaging.KafkaMessageProducer.sendMessage(KafkaMessageProducer.java:38)
    at tv.rr.messaging.KafkaMessageProducer$$FastClassBySpringCGLIB$$8cc6427f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
    at org.springframework.cloud.sleuth.instrument.async.TraceAsyncAspect.traceBackgroundThread(TraceAsyncAspect.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.run(TraceRunnable.java:62)
    at java.lang.Thread.run(Thread.java:748)

1.mysql 的隔离级别和锁

  • mysql 的锁分为共享锁(又叫S锁)和拍他锁(又叫X锁),S锁----允许多个事务并发的读取同一个资源,互补干扰。X锁----事务T加上排他锁后,其他事务不能再加任何锁。
  • read uncommit ---没有锁,所以会出现脏读
  • read commit ----共享锁,允许读,但是不允许写。---会出现,不可重复读(一个事务范围内,多次读取的结果不一样)
  • 可重复读--- X锁,读写都不允许,保证了可重复读。但是不能保证幻读,mysql引入了mvcc来解决这个问题。

2.Spring bean的生命周期

  • instantiation ---实例化
  • properties injection ---属性注入
  • setBeanName ---of bean name Aware接口的实现调用
  • setBeanClassLoader----BeanClassLoaderAare接口的方法
  • setBeanFactory ----BeanFactoryAware接口
  • PostProcessBeforeInitialization-----BeanPostProcessor接口
  • afterPropertiesSet-----InitializingBean 接口
  • 自定义的init-method----在spring xml中
  • postProcessAfterInitilazation ---BeanPostProcessor接口
  • destroy----DisposableBean 接口
  • 自定义的destroy method