[ 
https://issues.apache.org/jira/browse/NIFI-2701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15700135#comment-15700135
 ] 

Raymond commented on NIFI-2701:
-------------------------------

I agree that the title was a little bit too broad. More precise (but a little 
long) would be: Can't consume JMS Messages from a remote fault tolerant Sonic 
MQ broker. 

JNDI support is a great idea, as its a more generic way to connect to a broker. 
 However I do think there is an issue connecting with the regular CF, because I 
am able to connect directly to the remote SonicMQ broker with a regular CF. For 
example connecting to SonicMQ from a Java client:

     try
        {
            factory = new progress.message.jclient.ConnectionFactory (broker);
            connection = factory.createConnection(username, password);
            sendSession = connection.createSession(false, 
javax.jms.Session.AUTO_ACKNOWLEDGE);
            receiveSession = connection.createSession(false, 
javax.jms.Session.AUTO_ACKNOWLEDGE);
        }
     catch (javax.jms.JMSException jmse)
        {
            System.err.println ("error: Cannot connect to broker- " + broker + 
".\n");
            jmse.printStackTrace ();
            System.exit(1);
        }

In Talend the following is enough:

jmsConnectionFactory = new progress.message.jclient.ConnectionFactory 
("tcp://host:port","username", "password");       

Example with Camel (sjms component):

ConnectionFactory connection = new ConnectionFactory (url,username, password);  
try {
        Boolean.parseBoolean(faultTolerant);
  } catch (Exception e) {
     faultTolerant = "false";
}
connection.setFaultTolerant(Boolean.parseBoolean(faultTolerant));
connection.setConnectID("Camel/" + connectorId.replaceAll("\\.", "/") + "/" + 
new Random().nextInt(100000));                    
connection.setPrefetchCount(10);
SjmsComponent jms = new SjmsComponent();
                                
jms.setConnectionFactory(connection);
jms.setCamelContext(context);
                                
jms.start();
context.addComponent(componentName, jms)

The above examples were all tested from the same server (SERVERA) to the remote 
broker. Only with NiFi I get the error as earlier described. I may missed 
something in the configuration, but the current error "connection refused" I 
find strange. I may has something to do with the Spring singleconnection and 
the fact that the remote broker pair is configured fault tolerant. If you need 
extra logging, testing or other assistance just let me know. Would be great to 
get this working.

> Can’t consume JMS Messages from remote broker
> ---------------------------------------------
>
>                 Key: NIFI-2701
>                 URL: https://issues.apache.org/jira/browse/NIFI-2701
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.0.0, 0.7.0
>         Environment: Windows 7
>            Reporter: Raymond
>            Assignee: Oleg Zhurakousky
>
> I’m using the ConsumeJMS together with JMSConnectionFactoryProvider service 
> to consume message from a SonicMQ broker. If I’m using a NiFi instance and 
> the broker on the same machine this works. I can consume the messages from 
> the queue on the broker (using the broker url: tcp://localhost:2506). 
> If the broker is on another machine I get the following error:
> 08:55:48 CEST
> WARNING
> d6d8ec67-0156-1000-006c-054ada0ce528
> ConsumeJMS - JMSConsumer[destination:q.testconnector.inbox; pub-sub:false;] 
> Processor Administratively Yielded for 1 sec due to processing failure
> 08:55:51 CEST
> ERROR
> d6d8ec67-0156-1000-006c-054ada0ce528
> ConsumeJMS - JMSConsumer[destination:q.testconnector.inbox; pub-sub:false;] 
> ConsumeJMS - JMSConsumer[destination:q.testconnector.inbox; pub-sub:false;] 
> failed to process due to org.springframework.jms.UncategorizedJmsException: 
> Uncategorized exception occured during JMS processing; nested exception is 
> javax.jms.JMSException: java.net.ConnectException: Connection refused: 
> connect: ServerA; rolling back session: 
> org.springframework.jms.UncategorizedJmsException: Uncategorized exception 
> occured during JMS processing; nested exception is javax.jms.JMSException: 
> java.net.ConnectException: Connection refused: connect: ServerA
> Server A is the machine where the NiFi instance is running. So the connection 
> is not refused by the machine where the broker is running. The broker is 
> running correctly and I can connect from the same machine with other JMS 
> Clients with same credentials. This problem occurred with a NiFi 0.6.1 and 
> 1.0B instance.
> Log:
> org.springframework.jms.UncategorizedJmsException: Uncategorized exception 
> occured during JMS processing; nested exception is javax.jms.JMSException: 
> java.net.ConnectException: Connection refused: connect: SERVERA
>       at 
> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
>  ~[na:na]
>       at 
> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
>  ~[na:na]
>       at 
> org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:497) 
> ~[na:na]
>       at 
> org.springframework.jms.core.JmsTemplate.receiveSelected(JmsTemplate.java:764)
>  ~[na:na]
>       at 
> org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:738) 
> ~[na:na]
>       at 
> org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:727) 
> ~[na:na]
>       at 
> org.apache.nifi.jms.processors.JMSConsumer.consume(JMSConsumer.java:65) 
> ~[na:na]
>       at 
> org.apache.nifi.jms.processors.ConsumeJMS.rendezvousWithJms(ConsumeJMS.java:79)
>  ~[na:na]
>       at 
> org.apache.nifi.jms.processors.AbstractJMSProcessor.onTrigger(AbstractJMSProcessor.java:136)
>  ~[na:na]
>       at 
> org.apache.nifi.jms.processors.ConsumeJMS.onTrigger(ConsumeJMS.java:50) 
> ~[na:na]
>       at 
> org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
>  ~[nifi-api-1.0.0-BETA.jar:1.0.0-BETA]
>       at 
> org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1060)
>  ~[nifi-framework-core-1.0.0-BETA.jar:1.0.0-BETA]
>       at 
> org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136)
>  [nifi-framework-core-1.0.0-BETA.jar:1.0.0-BETA]
>       at 
> org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
>  [nifi-framework-core-1.0.0-BETA.jar:1.0.0-BETA]
>       at 
> org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:127)
>  [nifi-framework-core-1.0.0-BETA.jar:1.0.0-BETA]
>       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
> [na:1.8.0_102]
>       at java.util.concurrent.FutureTask.runAndReset(Unknown Source) 
> [na:1.8.0_102]
>       at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown
>  Source) [na:1.8.0_102]
>       at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
>  Source) [na:1.8.0_102]
>       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
> [na:1.8.0_102]
>       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
> [na:1.8.0_102]
>       at java.lang.Thread.run(Unknown Source) [na:1.8.0_102]
> Caused by: javax.jms.JMSException: java.net.ConnectException: Connection 
> refused: connect: SERVERA
>       at 
> progress.message.jimpl.JMSExceptionUtil.createJMSException(JMSExceptionUtil.java:42)
>  ~[na:na]
>       at progress.message.jimpl.Connection.<init>(Connection.java:964) 
> ~[na:na]
>       at 
> progress.message.jclient.ConnectionFactory.createConnection(ConnectionFactory.java:2305)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:178)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:152)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:365)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:305)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:283)
>  ~[na:na]
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:224)
>  ~[na:na]
>       at 
> org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
>  ~[na:na]
>       at 
> org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484) 
> ~[na:na]
>       ... 19 common frames omitted
> Caused by: progress.message.client.ENetworkFailure: 
> java.net.ConnectException: Connection refused: connect: SERVERA
>       at 
> progress.message.zclient.Connection.connectWithRecoveryOpt(Connection.java:1178)
>  ~[na:na]
>       at 
> progress.message.zclient.ReconnectHelper.connectAndChaseSingleFailoverRedirect(ReconnectHelper.java:534)
>  ~[na:na]
>       at progress.message.zclient.Connection.connect(Connection.java:1600) 
> ~[na:na]
>       at progress.message.jimpl.Connection.<init>(Connection.java:845) 
> ~[na:na]
>       ... 28 common frames omitted
> Caused by: java.net.ConnectException: Connection refused: connect
>       at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) 
> ~[na:1.8.0_102]
>       at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) 
> ~[na:1.8.0_102]
>       at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) 
> ~[na:1.8.0_102]
>       at java.net.AbstractPlainSocketImpl.connect(Unknown Source) 
> ~[na:1.8.0_102]
>       at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_102]
>       at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_102]
>       at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_102]
>       at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_102]
>       at java.net.Socket.<init>(Unknown Source) ~[na:1.8.0_102]
>       at java.net.Socket.<init>(Unknown Source) ~[na:1.8.0_102]
>       at 
> progress.message.net.tcp.ProgressTcpSocket.openSocket(ProgressTcpSocket.java:87)
>  ~[na:na]
>       at 
> progress.message.net.tcp.AbstractTcpSocket.<init>(AbstractTcpSocket.java:87) 
> ~[na:na]
>       at 
> progress.message.net.tcp.ProgressTcpSocket.<init>(ProgressTcpSocket.java:62) 
> ~[na:na]
>       at 
> progress.message.net.tcp.ProgressTcpSocketFactory.createProgressSocket(ProgressTcpSocketFactory.java:55)
>  ~[na:na]
>       at 
> progress.message.net.ProgressSocketFactory.createProgressSocket(ProgressSocketFactory.java:180)
>  ~[na:na]
>       at progress.message.zclient.Connection.openSocket(Connection.java:3570) 
> ~[na:na]
>       at 
> progress.message.zclient.Connection.connectWithRecoveryOpt(Connection.java:850)
>  ~[na:na]
>       ... 31 common frames omitted



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to