SolaceMessageProducer Not Blocking Send call while sending on incorrect queue

Options
dpratik23
dpratik23 Member Posts: 1
edited January 2022 in General Discussions #1

I am using solace-jms-spring-boot-starter (4.1.0) with all default properties

solace:
  jms:
    msgVpn: default
    host: smf://default:55555}
    clientName: default
    clientPassword: 
    directTransport: false

I am autowiring @ConnectionFactory and @JmsTemplate and using it directly to consumer and publish messages on Solace. I was able to consume messages correctly

but while publishing message on solace if I configure queue name incorrectly on purpose publisher is not throwing exception right away, it executes the next line as well

if try{
   publisher.send(message, queueNotAvailable); <----- if wrong queue name mentioned 
   log.info("message sent"); <--- it still prints this
}catch(Exception e){
   log.error("exception caught"); <--- control flow not coming here
} 

just after printing "message sent"

I get below exception but not in catch block

com.solacesystems.jcsmp.JCSMPErrorResponseException: 400: Queue Not Found

and then transaction gets rolled back and message gets redelivered again.

note : When I use MQ approach ibm-mq-spring-starter This works as expected.


Am I missing something here ? I want the control flow to go in the exception block instead of going to next line and then print exception


Any help is much appreciated


Thanks

Tagged:

Answers

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    Options

    Hi @dpratik23 ,

    What type of object is your publisher mentioned here?

    `   publisher.send(message, queueNotAvailable); <----- if wrong queue name mentioned `
    


    I tried sending with a org.springframework.jms.core.JmsTemplate object and it seems to work how you expected - the send threw an exception and the println didn't get hit. I just slightly modified this example.

    	@Value("SpringTestQueueInvalid")
    
    	private String queueName;
    
    
    
    	@Scheduled(fixedRate = 15000)
    
    	public void sendEvent() throws Exception {
    
    		String msg = "Hello World " + System.currentTimeMillis();
    
    		System.out.println("==========SENDING MESSAGE========== " + msg);
    
    		jmsTemplate.convertAndSend(queueName, msg);
    
    		System.out.println("==========MESSAGE SENT========== " + msg);
    
    	}
    


      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
    
    [32m :: Spring Boot :: [39m      [2m (v2.1.4.RELEASE)[0;39m
    
    [2m2022-01-28 11:35:16.300[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.s.s.spring.boot.SpringBootSender      [0;39m [2m:[0;39m Starting SpringBootSender on MJD-MacBook-Pro.localdomain with PID 85697 (/Users/marcdipasquale/dev/git/solace-samples-spring/spring-boot-autoconfig-sender/target/classes started by marcdipasquale in /Users/marcdipasquale/dev/git/solace-samples-spring/spring-boot-autoconfig-sender)
    [2m2022-01-28 11:35:16.304[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.s.s.spring.boot.SpringBootSender      [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
    [2m2022-01-28 11:35:16.945[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mfaultConfiguringBeanFactoryPostProcessor[0;39m [2m:[0;39m No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
    [2m2022-01-28 11:35:16.960[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mfaultConfiguringBeanFactoryPostProcessor[0;39m [2m:[0;39m No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
    [2m2022-01-28 11:35:17.019[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration$$EnhancerBySpringCGLIB$$7fb362bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    [2m2022-01-28 11:35:17.040[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    [2m2022-01-28 11:35:17.514[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.s.c.ThreadPoolTaskScheduler         [0;39m [2m:[0;39m Initializing ExecutorService 'taskScheduler'
    [2m2022-01-28 11:35:17.602[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.i.endpoint.EventDrivenConsumer      [0;39m [2m:[0;39m Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
    [2m2022-01-28 11:35:17.602[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.i.channel.PublishSubscribeChannel   [0;39m [2m:[0;39m Channel 'application.errorChannel' has 1 subscriber(s).
    [2m2022-01-28 11:35:17.602[0;39m [32m INFO[0;39m [35m85697[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.i.endpoint.EventDrivenConsumer      [0;39m [2m:[0;39m started _org.springframework.integration.errorLogger
    ==========SENDING MESSAGE========== Hello World 1643387717608
    2022-01-28 11:35:17.610  INFO 85697 --- [           main] c.s.s.spring.boot.SpringBootSender       : Started SpringBootSender in 1.578 seconds (JVM running for 2.163)
    2022-01-28 11:35:17.671  INFO 85697 --- [   scheduling-1] c.s.j.protocol.impl.TcpClientChannel     : Connecting to host 'orig=tcp://localhost:4444, scheme=tcp://, host=localhost, port=4444' (host 1 of 1, smfclient 1, attempt 1 of 1, this_host_attempt: 1 of 1)
    2022-01-28 11:35:17.704  INFO 85697 --- [   scheduling-1] c.s.j.protocol.impl.TcpClientChannel     : Connected to host 'orig=tcp://localhost:4444, scheme=tcp://, host=localhost, port=4444' (smfclient 1)
    2022-01-28 11:35:17.892  INFO 85697 --- [2_ReactorThread] c.s.jcsmp.impl.JCSMPXMLMessageProducer   : Error Response (400) - Queue Not Found - Topic '#P2P/QUE/SpringTestQueueInvalid'
    2022-01-28 11:35:17.909 ERROR 85697 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.
    
    
    org.springframework.jms.InvalidDestinationException: Error sending message - queue not found (400: Queue Not Found - Topic '#P2P/QUE/SpringTestQueueInvalid'); nested exception is javax.jms.InvalidDestinationException: Error sending message - queue not found (400: Queue Not Found - Topic '#P2P/QUE/SpringTestQueueInvalid')
    	at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:280) ~[spring-jms-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:185) ~[spring-jms-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:507) ~[spring-jms-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584) ~[spring-jms-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:661) ~[spring-jms-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at com.solace.samples.spring.boot.SpringBootSender.sendEvent(SpringBootSender.java:46) ~[classes/:na]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
    	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
    	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_201]
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_201]
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_201]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
    	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
    Caused by: javax.jms.InvalidDestinationException: Error sending message - queue not found (400: Queue Not Found - Topic '#P2P/QUE/SpringTestQueueInvalid')
            ...