Code Monkey home page Code Monkey logo

java_nats's People

Contributors

aosalias avatar tyagihas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java_nats's Issues

Reconnect under load fails sometimes with StackOverFlowError, or by getting stuck

I've created a gist with the test code: https://gist.github.com/adamhonen/04070d59159e09174658

Here's the setup:

I have 4 t2.micro machines named dev-stream-01 to dev-stream-04
dev-stream-01 is used to run the loader program.using the following command:

java -cp stream.jar NatsLoader 100000 1000 > out.log 2>&1 &

(stream.jar is of course just an arbitrary name I've picked)

dev-stream-02 to dev-stream-04 are configured to form a cluster.
They all point to each other in configuration.

So, for example, this is dev-stream-02's configuration file:

port: 4242
http_port: 8222

cluster {
host: 'dev-stream-02' # host/net interface
port: 4244 # port for inbound route connections

routes = [
nats-route://dev-stream-03:4244
nats-route://dev-stream-04:4244
]
}

And the other two are similar, with the expected changes.

I launch the java process and then check which server is being used to publish messages and which is sending them back to us.
I do this using iftop from dev-stream-01, although there might be better ways. I just happened to be using it anyway in order to see how much data was being moved around for various similar products.

Anyway, I then kill the gnatsd process on the producer server and immediately bring it back up.
In some rare cases, re-connection happens.
More often, I just see that no more messages are being sent.

The java process remains alive, so I run kill -3 on it in order to see the stacktrace.
The results vary a lot.
Before extracting the test code from my entire POC application (which does a whole lot of stuff that are irrelevant to nats) I saw that either the producer thread, or one of the MsgProcessor threads, was holding the sendBuffer lock and stuck on read while other threads were waiting to lock it.
Now with the extracted code, I mainly see StackOverFlow errors.
It still gets stuck sometimes, but the thread dump still shows the signs of a StackOverFlow error, which repeats the following:

at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)
at org.nats.Connection.access$300(Connection.java:20)
at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)
at org.nats.Connection.access$300(Connection.java:20)
at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)
at org.nats.Connection.access$300(Connection.java:20)
at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)
at org.nats.Connection.access$300(Connection.java:20)
at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)
at org.nats.Connection.access$300(Connection.java:20)
at org.nats.Connection$MsgProcessor.run(Connection.java:703)
at org.nats.Connection.reconnect(Connection.java:638)

I assume the difference in how reconnecting failed between my larger application and this smaller one, is that the larger application also had other threads doing work (e.g. tracking various metrics), so the nats client threads and the producer thread were getting scheduled differently.

Catching Error/Exceptions

Hello,

I am trying to use this library (through it's scala api, but I think this problem is caused by the java api), and I am running into some problems when there are some exceptions, for example when the server goes down.

java_nats indeed tries to reconnect, but if the reconnection fails, it just logs the problem and never throws an exception, and never tries again either. This is a problem because the code calling this library cannot act on the error as it never receives an indication that there is an error, like an exception or an error callback.

Is this intended?

Thanks,
Simao

BufferUnderflowException when handling large messages

I'm struggling with the same issue as the author of this mail:
https://groups.google.com/a/cloudfoundry.org/d/msg/vcap-dev/GPvXpyNCW7A/-DBpY_EFi24J
Basically we can't consume large messages fast enough without having a BufferUnderflowException:

Exception in thread "Thread-0" java.nio.BufferUnderflowException
    at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:265)
    at org.nats.Connection$MsgProcessor.processMessage(Connection.java:751)
    at org.nats.Connection$MsgProcessor.run(Connection.java:698)

My message handler looks like this (sorry for the Scala):

val suid = conn.subscribe("events",
  new MsgHandler {
    override def execute(msg: String) {
      println(s"Received update : $msg")
    }
  }
)

Any ideas?

Binary data

Is there a way to publish/receive binary data (byte[]) instead of strings? Any intention of adding this functionality?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.