I am having one config file as below,
@Slf4j
@Configuration
@EnableJms
public class MyQpidConfig {
@Bean("myQpidConn")
public AMQConnectionFactory amqConnectionFactory() throws URLSyntaxException {
AMQConnectionFactory amqConnectionFactory = new AMQConnectionFactory("URL");
return amqConnectionFactory;
}
@Bean("myJmsContainer")
public DefaultMessageListenerContainer defaultMessageListenerContainer(@Qualifier("myQpidAdaptor") MessageListenerAdapter messageListenerAdapter ,@Qualifier("myQpidConn")AMQConnectionFactory connectionFactory) {
DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
messageListenerContainer.setConnectionFactory(connectionFactory);
messageListenerContainer.setDestinationName(destinationName);
messageListenerContainer.setMessageListener(messageListenerAdapter);
messageListenerContainer.setPubSubDomain(false);
messageListenerContainer.setSessionTransacted(true);
messageListenerContainer.setDurableSubscriptionName("MYSUBSCRIBER");
messageListenerContainer.setSubscriptionDurable(true);
messageListenerContainer.setAutoStartup(true);
messageListenerContainer.setDestination((Queue) () -> "MYQUEUE");
return messageListenerContainer;
}
@Bean("myQpidAdaptor")
public MessageListenerAdapter messageListenerAdapter() {
Preconditions.checkNotNull(qpidMessageListner, "Consumer listener not set");
MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(new MyQpidMessageListner());
messageListenerAdapter.setDefaultListenerMethod("onMessage");
messageListenerAdapter.setDefaultResponseQueueName("MYQUEUE");
return messageListenerAdapter;
}
}
where destinationName is equal to
ADDR:MYSUBSCRIBER:MYQUEUE; {"create":"receiver",
"node":{"durable":true,"x-declare":
{"exclusive":true,"auto-delete":false,
"x-bindings":[{"exchange":"amq.topic","key":"MYQUEUE"}]}}}
and my Listener class is as below,
@Slf4j
@Component
public class MyQpidMessageListner implements MessageListener{
@Override
public void onMessage(Message jmsBytesMessage) {
log.info("Control Inside");
//to do
}
}
as a async consumer when i am running the my application at that time getting exception related to destination,
DefaultMessageListenerContainer -
Setup of JMS message listener invoker failed for destination 'com.my.MyQpidConfig$$Lambda$637/429515253@3aa1975' - trying to recover. Cause: com.my.MyQpidConfig$$Lambda$637/429515253 cannot be cast to org.apache.qpid.client.AMQDestination
If its related to AMQDestination then how can i create the AMQDestination in java code. I am not getting any resource for this QPID issue. Any suggestion help must be appreciated.
For some reason you're passing a lambda to
org.springframework.jms.listener.DefaultMessageListenerContainer.setDestination(Destination)
, i.e.:This method needs a
javax.jms.Destination
implementation (e.g.org.apache.qpid.client.AMQDestination
), not a lambda.You're already setting the destination name, i.e.:
So it's not clear why you're also trying to set the destination as well. These are two ways to configure the same thing.
I recommend you simply remove the code attempting to set the destination and leave the code setting the destination name.