Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 处理队列的NoSuchMethodException_Java_Spring_Spring Amqp - Fatal编程技术网

Java 处理队列的NoSuchMethodException

Java 处理队列的NoSuchMethodException,java,spring,spring-amqp,Java,Spring,Spring Amqp,我尝试实现不同的队列来处理Java对象: @SpringBootApplication @ComponentScan("org.gateway.context") public class ContextServer extends SpringBootServletInitializer { protected static String QUEUE_DATABASE_API_ATTEMPT = "database-apiattempts-queue"; protected

我尝试实现不同的队列来处理Java对象:

@SpringBootApplication
@ComponentScan("org.gateway.context")
public class ContextServer extends SpringBootServletInitializer {

    protected static String QUEUE_DATABASE_API_ATTEMPT = "database-apiattempts-queue";
    protected static final String EXCHANGE_DATABASE = "database";
    protected static final String ROUTING_KEY_DATABASE_TRANSACTION = "database.event.transa";

    protected CachingConnectionFactory connectionFactory;
    protected RabbitTemplate databaseApiAttemptTemplate;
    protected RabbitTemplate databaseEventLogsTemplate;

    private static Class<ContextServer> applicationClass = ContextServer.class;

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {        
        connectionFactory = new CachingConnectionFactory(HOST);
        admin = new RabbitAdmin(connectionFactory);
        .....

        return application.sources(applicationClass);
    }

    @Bean
    public SimpleMessageListenerContainer apiAttemptContainer(ConnectionFactory cf, ApiAttemptListener listener) {
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
        container.setQueueNames(QUEUE_DATABASE_API_ATTEMPT);
        container.setExclusive(true);
        container.setConcurrentConsumers(1);
        container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        container.setMessageListener(new MessageListenerAdapter(listener, "apiattemptTransaction"));
        container.setMessageConverter(new SerializerMessageConverter());
        return container;
    }

    @Component
    class ApiAttemptListener {

        public ApiAttemptsBean apiattemptTransaction(ApiAttemptsBean ro) {
            ApiAttemptsBean obj = new ApiAttemptsBean();
            System.out.println("!!!! Performing ApiAttempts processing !!!!");
            obj.setMerchant_id(454545);
            return obj;
        }
    }

    @Bean
    public SimpleMessageListenerContainer eventLogsContainer(ConnectionFactory cf, EventLogstListener listener) {
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
        container.setQueueNames(QUEUE_DATABASE_EVENT_LOGS);
        container.setExclusive(true);
        container.setConcurrentConsumers(1);
        container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        container.setMessageListener(new MessageListenerAdapter(listener, "eventLogsTransaction"));
        container.setMessageConverter(new SerializerMessageConverter());
        return container;
    }

    @Component
    class EventLogstListener {

        public EventLogsBean eventLogsTransaction(EventLogsBean ro) {
            EventLogsBean obj = new EventLogsBean();
            System.out.println("!!!! Performing EventLogs processing !!!!");
            obj.setEntity_id(454545);
            return obj;
        }
    }   
}
deployment.datalis_db.war//org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:386) ... 还有12个

全堆栈跟踪


我想我不能在方法的名称中使用大写字母?您能告诉我问题出在哪里吗?

内部类必须是静态的才能成为bean。否则,它们依赖于外部类实例。使它们成为静态的或将它们移出。

内部类必须是静态的才能成为bean。否则,它们依赖于外部类实例。使其静止或移出

23:37:52,782 WARN  [org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler] (apiAttemptContainer-1) Execution of Rabbit message listener failed.: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'apiattemptTransaction' with argument type = [class org.datalis.plugin.database.bean.TransactionsBean], value = [{org.datalis.plugin.database.bean.TransactionsBean@1fc52440}]
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoSuchMethodException: org.datalis.database.context.ContextServer$ApiAttemptListener.apiattemptTransaction(org.datalis.plugin.database.bean.TransactionsBean)    
    ... 12 more

23:37:52,782 WARN  [org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler] (eventLogsContainer-1) Execution of Rabbit message listener failed.: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'eventLogsTransaction' with argument type = [class org.datalis.plugin.database.bean.TransactionsBean], value = [{org.datalis.plugin.database.bean.TransactionsBean@52900dd1}]       
Caused by: java.lang.NoSuchMethodException: org.datalis.database.context.ContextServer$EventLogstListener.eventLogsTransaction(org.datalis.plugin.database.bean.TransactionsBean)
    at java.base/java.lang.Class.getMethod(Class.java:2067)