连接到Sonic Broker时,我确实喜欢下面的工作正常,
TopicConnectionFactory factory = new progress.message.jclient.TopicConnectionFactory(brokerURL);
TopicConnection connection = factory.createTopicConnection(brokerUserName, brokerPassword);
javax.jms.TopicSession subSession = (TopicSession) connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Topic topic = subSession.createTopic(topicNameToListen);
MessageConsumer subscriber = subSession.createSubscriber(topic);
subscriber.setMessageListener(msgListener);
connection.start();
所以当我使用弹簧靴做的时候,我做了,
@Bean
TopicConnectionFactory connectionFactory() throws JMSException {
TopicConnectionFactory factory = new progress.message.jclient.TopicConnectionFactory(brokerURL);
TopicConnection connection = factory.createTopicConnection(brokerUserName, brokerPassword);
connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
return factory;
}
@Bean
JmsListenerContainerFactory<?> myJmsContainerFactory(ConnectionFactory connectionFactory) {
SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
return factory;
}
@JmsListener(destination = "topic.name.for.receiving.message", containerFactory = "myJmsContainerFactory")
public void messageReceiver(String message) {
LogService.info(this.getClass().getName(), "A Message Received");
LogService.info(this.getClass().getName(), message);
}
但是,如果我运行这个,我得到Exception
,
javax.jms.JMSSecurityException: Inauthentic Client
at progress.message.jimpl.JMSExceptionUtil.createJMSSecurityException(JMSExceptionUtil.java:134)
at progress.message.jimpl.JMSExceptionUtil.createJMSSecurityException(JMSExceptionUtil.java:117)
at progress.message.jimpl.JMSExceptionUtil.createJMSSecurityException(JMSExceptionUtil.java:103)
at progress.message.jimpl.Connection.<init>(Connection.java:836)
at progress.message.jclient.ConnectionFactory.createConnection(ConnectionFactory.java:2110)
at progress.message.jclient.ConnectionFactory.createConnection(ConnectionFactory.java:2083)
注意:我已经多次检查过凭据并使用之前的代码运行它,它运行正常。我还添加了sonic_Client.jar, sonic_Crypto.jar and sonic_XMessage.jar
。如果我尝试弹簧启动,我会收到此错误。
这可能是什么原因?