logstash-plugins / logstash-input-jms

12 stars 27 forks source link

Reconnect opportunity #25

Open ghost opened 6 years ago

ghost commented 6 years ago

Hello guys,

is it possible add functionality to reconnect to queue manager in case with some network partitions or problem with queue manager?

ghost commented 6 years ago

because some time occure next exception: [2018-01-05T10:24:52,132][WARN ][logstash.inputs.jms ] JMS Exception has occurred: JMSWMQ1107: A problem with this connection has occurred. [2018-01-05T10:24:52,132][WARN ][logstash.inputs.jms ] JMS Exception has occurred: JMSWMQ1107: A problem with this connection has occurred. [2018-01-05T10:24:52,132][WARN ][logstash.inputs.jms ] JMS Exception has occurred: JMSWMQ1107: A problem with this connection has occurred.

ghost commented 6 years ago

is it possible to add some functionality to try catch some java exception in run method:

import java.net.ConnectException
import com.ibm.msg.client.jms.DetailedIllegalStateException
import com.ibm.mq.MQException
import com.ibm.mq.jmqi.JmqiException

....

 public
  def run(output_queue)
    maxTries=5
    currentTries=1
    while (currentTries <= maxTries)
      begin
        case @runner
          when "consumer" then
            run_consumer(output_queue)
          when "async" then
            run_async(output_queue)
          when "thread" then
            run_thread(output_queue)
        end
      rescue ConnectException, DetailedIllegalStateException, MQException, JmqiException  => connectException
        @logger.warn("current attempt is #{currentTries}")
        @logger.warn("#{connectException}")
        @logger.warn("Message: #{connectException.message}")
        @logger.warn(puts "Backtrace: #{connectException.backtrace}")
      end
    end

  end
aleskovets commented 6 years ago

It would be quite useful to be able to automatically recover after network incident and not silently die.

peruzzof commented 6 years ago

I am facing the same problem... sometimes I am losing the connectivity with my JMS server (Tibco EMS), I can find the error below on logstash-plain.txt and would be excelent if the logstash could retry connect to it.

[logstash.inputs.jms ] JMS Exception has occurred: Connection has been terminated due to missing server heartbeats

jonathanmza commented 5 years ago

If you have set a mq connection factory you can do this (the code below comes from one of my java projects) :

mqQueueConnectionFactory.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);

NaturesProphet commented 5 years ago

I have the same problem here. i 'm getting messages from an Apache ActiveMQ server and i'm using those confs:

input 
{
    jms 
    {
        yaml_file => "/usr/share/logstash/activemq/jms.yml"
        yaml_section => "activemq"
        destination => "MyTopic"
        runner => "async"
        pub_sub => true
    }
}

yml:

activemq:
  :factory: org.apache.activemq.ActiveMQConnectionFactory
  :broker_url: failover:(tcp://IP:PORT)?initialReconnectDelay=100&maxReconnectDelay=2000
  :username: usr
  :password: pass
  :require_jars:
    - /usr/share/logstash/activemq/activemq-all-5.15.8.jar

Every time the server goes down, the logstash crashes and i have to manually restart the pipelines. Hell! theres' no try/catch on this?

robbavey commented 5 years ago

This should have been resolved by #35