{"record":{"id":"4856aad2e50626c9","repo":"apache/beam","slug":"error-creating-jms-consumer","errorCode":null,"errorMessage":"Error creating JMS consumer","messagePattern":"Error creating JMS consumer","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java","lineNumber":731,"sourceCode":"        int ackMode = getAckModeCode(source.spec.getAcknowledgeMode());\n        this.session = this.connection.createSession(false, ackMode);\n      } catch (Exception e) {\n        throw new IOException(\"Error creating JMS session\", e);\n      }\n\n      Read<T> spec = source.spec;\n      Duration receiveTimeout =\n          MoreObjects.firstNonNull(source.spec.getReceiveTimeout(), Duration.ZERO);\n      receiveTimeoutMillis = receiveTimeout.getMillis();\n\n      try {\n        if (source.spec.getTopic() != null) {\n          consumer = session.createConsumer(session.createTopic(spec.getTopic()));\n        } else {\n          consumer = session.createConsumer(session.createQueue(spec.getQueue()));\n        }\n      } catch (Exception e) {\n        throw new IOException(\"Error creating JMS consumer\", e);\n      }\n    }\n\n    private int getAckModeCode(AcknowledgeMode mode) {\n      if (mode == AcknowledgeMode.CLIENT_ACKNOWLEDGE\n          || mode == AcknowledgeMode.CLIENT_ACKNOWLEDGE_UNSAFE) {\n        return Session.CLIENT_ACKNOWLEDGE;\n      } else if (mode == AcknowledgeMode.INDIVIDUAL_ACKNOWLEDGE) {\n        Integer configuredCode = source.spec.getIndividualAcknowledgeModeCode();\n        if (configuredCode != null) {\n          return configuredCode;\n        }\n        String connectionClassName = this.connection.getClass().getName();\n        if (connectionClassName.contains(\"org.apache.activemq.ActiveMQConnection\")) {\n          return 4;\n        } else if (connectionClassName.contains(\"org.apache.qpid.jms\")) {\n          return 101;\n        } else if (connectionClassName.contains(\"org.apache.activemq.artemis\")) {","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java#L713-L749","documentation":"UnboundedJmsReader.recreateSession() wraps failures from session.createConsumer(...) (on a Topic or Queue) in an IOException with the message 'Error creating JMS consumer'. The session was created but the broker refused or failed to create the MessageConsumer for the configured topic/queue.","triggerScenarios":"recreateSession() executing session.createConsumer(session.createTopic(topic)) or (session.createQueue(queue)) when the destination does not exist/cannot be created, the destination name is invalid, or the broker rejects the consumer (permissions, limits, connection issues).","commonSituations":"Typo in topic/queue name or destination not provisioned on the broker; insufficient permissions to consume from the destination; broker-side consumer limits reached; destination name containing invalid characters for the broker (e.g. SQL Server/Azure Service Bus style names on ActiveMQ).","solutions":["Check the wrapped cause to see whether it is destination-not-found, security, or connection related and fix accordingly","Verify the topic/queue name in JmsIO.read().withTopic()/withQueue() exactly matches a destination on the broker (or enable auto-creation)","Ensure the JMS user has consume permission on the destination","Check broker consumer limits and drop stale consumers if exhausted"],"exampleFix":"// before\nJmsIO.<String>read().withQueue(\"order.Events\") // destination doesn't exist / invalid name\n// after\nJmsIO.<String>read().withQueue(\"order.events\") // matches actual broker destination\n// (or pre-create the destination / grant consume permission)","handlingStrategy":"retry","validationCode":"// preflight: verify destination exists and is consumable\nDestination d = session.createQueue(queueName);\ntry (MessageConsumer probe = session.createConsumer(d)) { /* ok */ }","typeGuard":null,"tryCatchPattern":"try {\n  reader.recreateSession();\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().equals(\"Error creating JMS consumer\")) {\n    // inspect e.getCause(): destination missing, permissions, or limits; fix and retry\n  } else throw e;\n}","preventionTips":["Pre-create topics/queues (or enable auto-creation) and confirm exact names in config","Grant the JMS user consume permissions on all destinations used by the pipeline","Watch broker consumer limits; avoid leaking consumers across restarts"],"tags":["jms","consumer","ioexception","beam","broker"],"backgroundTag":"connection-refused","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}