Remote addr: solaceuat.bos.group.intranet:55443) - Error Response (400) - Already Exists
Want to consume solace message from que using multiple consumers and multiple threads
public Connection connection() {
Connection connection = null;
javax.jms.Session session;
try {
logger.info(">>>>>>>>>>>>>>>>connectionFactory.setHost:" + solConnectionFactory().getHost());
logger.info(">>>>>>>>>>>>>>>getProperty(spring.datasource.solaceQue):" + environment.getProperty("spring.datasource.solaceQue"));
session = ((Connection) solConnectionFactory().createConnection()).createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
Destination queue = session.createQueue(environment.getProperty("spring.datasource.solaceQue"));
DefaultMessageListenerContainer defaultMessageContainer=new DefaultMessageListenerContainer();
defaultMessageContainer.setConnectionFactory(solConnectionFactory());
defaultMessageContainer.setConcurrency("5-20");
defaultMessageContainer.setDestination(queue);;
defaultMessageContainer.setMaxConcurrentConsumers(20);
defaultMessageContainer.setDestinationName("spring.datasource.solaceQue");
defaultMessageContainer.setExceptionListener(exceptionListener);
defaultMessageContainer.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
defaultMessageContainer.setMessageListener(jmsMessageListener());
defaultMessageContainer.afterPropertiesSet();
defaultMessageContainer.start();
logger.info(">>>>>Solace Connected. Awaiting message...");
} catch (Exception e) {
logger.error("JMS connection failed with Solace." + ExceptionUtils.getFullStackTrace(e));
e.printStackTrace();
}
return connection;
}
@Bean public SolConnectionFactory solConnectionFactory() { SolConnectionFactory connectionFactory = new SolConnectionFactoryImpl(); connectionFactory.setHost(environment.getProperty("solace_url")); connectionFactory.setAuthenticationScheme(JCSMPProperties.AUTHENTICATION_SCHEME_CLIENT_CERTIFICATE); connectionFactory.setVPN(environment.getProperty("solace_vpn")); connectionFactory.setSSLKeyStoreFormat("jks"); connectionFactory.setSSLTrustStoreFormat("jks"); connectionFactory.setSSLKeyStore(environment.getProperty("solace_certs_keystore")); connectionFactory.setSSLKeyStorePassword(environment.getProperty("solace_certs_keystore_password")); connectionFactory.setSSLTrustStore(environment.getProperty("solace_certs_trust")); connectionFactory.setSSLTrustStorePassword(environment.getProperty("solace_certs_trust_password")); connectionFactory.setSSLPrivateKeyAlias(environment.getProperty("keyStoreAlias")); connectionFactory.setSSLValidateCertificate(false); connectionFactory.setSSLValidateCertificateDate(false); connectionFactory.setDynamicDurables(true); connectionFactory.setDirectTransport(false); logger.info(environment.getProperty("solace_url") + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); return connectionFactory; }
Comments
-
Hello @arthirajan , Can you pl add a line summarizing your issue? Are you getting this as an JMSException? Are you looking for explanation of this log?
I assume you are trying to create the same queue each time you start a new connection with session.createQueue(). This will get 400 response from broker for all but the first attempt. You can simply log this and continue.
FYI, typically, queue creation is an administrative activity done once. In this model, an administrator creates the queue and the application does JNDI lookup.
A sample implementation is here:
https://tutorials.solace.dev/jms/using-jndi/.You may also find this blog post useful:
https://solace.com/blog/create-message-queue-in-solace/Adding createQueue doc for your reference:
https://appdoc.app/artifact/com.solacesystems/sol-jms/10.2.1/javax/jms/Session.html#createQueue(java.lang.String)0 -
@nram . Thanks for your reply.
i want to have multiple consumers for the same que as huge volume is expected in my que. Above code tried to create multiple connection to the same que. Kindly advice the right approach for multiple consumers or multiple threads to handle the huge volume0 -
Hi @arthirajan , If the queue is already in place, does subsequent consumers exit with condition? My understanding is that this is an API log and not an exception.
0 -
@nram. The listener not reading message from the que for the above code . Message is piled up in que.No other errors
0