如何不消费删除JMS Topic消息及主题名称配置问题
问题:WebLogic JMS Topic消息删除失败(主题名称格式错误)
我需要在不触发数据库消费的前提下删除JMS Topic中的消息(数据库存在异常)。由于没有直接删除Topic消息的专用方法,我尝试通过创建JMS连接、主题和消费者来实现删除操作,但在创建主题阶段报错。
已知Fusion环境中列出的主题格式为myJMSModule!MyJMSServer@MyManasgedServer_osb1@My.TOPIC.NAME,但使用该格式创建主题无效,也找不到正确的语法示例。
代码示例
context = InitialContext(jndi_props) connection_factory = context.lookup("my/connectionFactory") connection = connection_factory.createConnection() session = connection.createSession(False, javax.jms.Session.AUTO_ACKNOWLEDGE) # 此处主题名称格式有误 topic = session.createTopic("Where im having issues") consumer = session.createConsumer(topic, selector) connection.start() try: while True: message = consumer.receiveNoWait() if message is None: break if isinstance(message, JMSMessageInfo): print("Removing message: %s " % message.getJMSMessageID()) session.deleteMessage(message) # 通过确认消息实现删除 finally: consumer.close() session.close() connection.close()
报错信息
weblogic.jms.common.JMSException: weblogic.jms.common.JMSException: [JMSExceptions:045103]While trying to find a topic or a queue, the specific JMS server requested could not be found. The linked exception may contain more information about the reason for failure.
已尝试的主题格式
My.TOPIC.NAME/My.TOPIC.NAMEmyJMSServer/My.TOPIC.NAMEmyJMSModule/My.TOPIC.NAME
求助需求
- 正确的WebLogic JMS主题名称格式,解决
session.createTopic的报错问题 - 更优的不触发数据库消费的JMS Topic消息删除方案
内容的提问来源于stack exchange,提问作者john williams
相关产品推荐
相关产品推荐

