Deepboy
Deepboy

Reputation: 531

Add 'application.errorChannel' to config in Spring Integration

I have written a program to read messages from a Solace queue. I am getting the below error.

Can you please help?

enter image description here Code given below:

My main config is given below:

public class ReadFromQueueConfig {

    @Autowired
    private PrintMessageFromQueue printMessageFromQueue;

    String queueName = "MY.SAMPLE.SOLACE.QUEUE";

    @Bean
    public CachingConnectionFactory jmsConnectionFactory() {
        CachingConnectionFactory ccf = new CachingConnectionFactory();
        try {
            SolConnectionFactory scf = SolJmsUtility.createConnectionFactory();
            scf.setHost("host");
            scf.setUsername("username");
            scf.setVPN("vpm");
            scf.setPassword("password");
            scf.setDirectTransport(false);

            ccf.setTargetConnectionFactory(scf);

        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
        return ccf;
    }

    @Bean
    public IntegrationFlow handleJsmInput() {
        return IntegrationFlows
                .from(Jms.inboundAdapter(jmsConnectionFactory()).destination(queueName))
                        .handle(printMessageFromQueue)
                        .get();
    }
}

PrintMessageFromQueue.java: enter image description here

UPDATE: My main class:

@SpringBootApplication
@EnableIntegration
@IntegrationComponentScan
public class TestReadFromQueueApplication {
    public static void main(String[] args) {
        SpringApplication.run(TestReadFromQueueApplication.class, args);
    }
}

Upvotes: 0

Views: 385

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121262

You can do something like this in the main() after creating an ApplicationContext:

final Scanner scanner = new Scanner(System.in);
context.close();

So, you application is not going to exit until some input from the console.

Also you can wait for the messages to be consumed, e.g. via the QueueChannel.receive(). Some sample to block a main in done in the Apache Kafka sample in the Spring Integration Samples: https://github.com/spring-projects/spring-integration-samples/blob/master/basic/kafka/src/main/java/org/springframework/integration/samples/kafka/Application.java

Upvotes: 1

Related Questions