Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1863#discussion_r124466131
  
    --- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java
 ---
    @@ -71,10 +71,27 @@ public Void doInJms(Session session) throws 
JMSException {
                      * delivery and restarts with the oldest unacknowledged 
message
                      */
                     session.recover();
    +                boolean isPubSub = 
JMSConsumer.this.jmsTemplate.isPubSubDomain();
                     Destination destination = 
JMSConsumer.this.jmsTemplate.getDestinationResolver().resolveDestinationName(
    -                        session, destinationName, 
JMSConsumer.this.jmsTemplate.isPubSubDomain());
    -                MessageConsumer msgConsumer = 
session.createConsumer(destination, null,
    -                        JMSConsumer.this.jmsTemplate.isPubSubDomain());
    +                        session, destinationName, isPubSub);
    +                MessageConsumer msgConsumer;
    +                if (isPubSub) {
    +                    if (shared) {
    --- End diff --
    
    When I tested shared consumer with ActiveMQ 5, I got following error as it 
only supports JMS 1.1:
    
    ```
    2017-06-28 15:56:02,325 WARN [Timer-Driven Process Thread-4] 
o.a.n.c.t.ContinuallyRunProcessorTask java.lang.AbstractMethodError: 
org.apache.activemq.ActiveMQSession.createSharedConsumer(Ljavax/jms/Topic;Ljava/lang/String;Ljava/lang/String;)Ljavax/jms/MessageConsumer;
            at sun.reflect.GeneratedMethodAccessor781.invoke(Unknown Source)
            at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at 
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.getCachedConsumer(CachingConnectionFactory.java:428)
            at 
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:366)
            at com.sun.proxy.$Proxy123.createSharedConsumer(Unknown Source)
            at 
org.apache.nifi.jms.processors.JMSConsumer$1.doInJms(JMSConsumer.java:83)
            at 
org.apache.nifi.jms.processors.JMSConsumer$1.doInJms(JMSConsumer.java:65)
            at 
org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:494)
            at 
org.apache.nifi.jms.processors.JMSConsumer.consume(JMSConsumer.java:65)
            at 
org.apache.nifi.jms.processors.ConsumeJMS.rendezvousWithJms(ConsumeJMS.java:156)
            at 
org.apache.nifi.jms.processors.AbstractJMSProcessor.onTrigger(AbstractJMSProcessor.java:147)
            at 
org.apache.nifi.jms.processors.ConsumeJMS.onTrigger(ConsumeJMS.java:58)
            at 
org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
            at 
org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1120)
    ```
    
    Can we make the error message more user friendly like this:
    
    ```
                        if (shared) {
                            try {
                                if (durable) {
                                    msgConsumer = 
session.createSharedDurableConsumer((Topic)destination, subscriberName);
                                } else {
                                    msgConsumer = 
session.createSharedConsumer((Topic)destination, subscriberName);
                                }
                            } catch (AbstractMethodError e) {
                                throw new ProcessException("Failed to create a 
shared consumer. Make sure the target broker is JMS 2.0 compliant.", e);
                            }
                        } else {
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to